Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) FetchAndStoreUsers(ctx context.Context) error
- func (c *Client) GetDbClient() db.DBClient
- func (c *Client) GetHTTPClient() *http.Client
- func (c *Client) GetLastDownloadTime(ctx context.Context) (time.Time, error)
- func (c *Client) GetLoTWUserActivity(ctx context.Context, callsign string) (*UserActivity, error)
- func (c *Client) IsLoTWUser(ctx context.Context, callsign string) (bool, error)
- func (c *Client) ReplaceUsersInDB(users []UserActivity) error
- func (c *Client) SetHTTPClient(h *http.Client)
- func (c *Client) StartUpdater(ctx context.Context)
- func (c *Client) StopUpdater()
- type HTTPDoer
- type UserActivity
Constants ¶
const (
DBFileName = "lotw.db" // Made public for use in main and tests
)
const DBTableName = dbTableName
DBTableName is exported for tests.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Exported testing hooks
HTTPClient HTTPDoer
DbClient db.DBClient
// contains filtered or unexported fields
}
Client manages LoTW user activity data.
func (*Client) FetchAndStoreUsers ¶
FetchAndStoreUsers calls the internal fetch and store.
func (*Client) GetDbClient ¶
GetDbClient exposes the db client for tests.
func (*Client) GetHTTPClient ¶
GetHTTPClient exposes the internal http client for tests.
func (*Client) GetLastDownloadTime ¶
GetLastDownloadTime retrieves when LoTW data was last downloaded.
func (*Client) GetLoTWUserActivity ¶
GetLoTWUserActivity retrieves a user's activity details. Returns nil, nil if not found.
func (*Client) IsLoTWUser ¶
IsLoTWUser checks if a callsign is in the LoTW database. Returns true if found, false otherwise, and an error if the lookup fails.
func (*Client) ReplaceUsersInDB ¶
func (c *Client) ReplaceUsersInDB(users []UserActivity) error
ReplaceUsersInDB exposes the replace operation for tests.
func (*Client) SetHTTPClient ¶
SetHTTPClient allows tests to inject a custom *http.Client (including custom Transport).
func (*Client) StartUpdater ¶
func (*Client) StopUpdater ¶
func (c *Client) StopUpdater()
StopUpdater halts the periodic update and releases resources.
type UserActivity ¶
UserActivity represents a single entry from the LoTW user activity CSV.
func ParseLoTWCSV ¶
func ParseLoTWCSV(r io.Reader) ([]UserActivity, error)
ParseLoTWCSV is exported for tests to parse CSV input.