lotw

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBFileName = "lotw.db" // Made public for use in main and tests

)
View Source
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 NewClient

func NewClient(ctx context.Context, cfg config.Config, dbClient db.DBClient) (*Client, error)

NewClient creates and returns a new LoTW client.

func (*Client) FetchAndStoreUsers

func (c *Client) FetchAndStoreUsers(ctx context.Context) error

FetchAndStoreUsers calls the internal fetch and store.

func (*Client) GetDbClient

func (c *Client) GetDbClient() db.DBClient

GetDbClient exposes the db client for tests.

func (*Client) GetHTTPClient

func (c *Client) GetHTTPClient() *http.Client

GetHTTPClient exposes the internal http client for tests.

func (*Client) GetLastDownloadTime

func (c *Client) GetLastDownloadTime(ctx context.Context) (time.Time, error)

GetLastDownloadTime retrieves when LoTW data was last downloaded.

func (*Client) GetLoTWUserActivity

func (c *Client) GetLoTWUserActivity(ctx context.Context, callsign string) (*UserActivity, error)

GetLoTWUserActivity retrieves a user's activity details. Returns nil, nil if not found.

func (*Client) IsLoTWUser

func (c *Client) IsLoTWUser(ctx context.Context, callsign string) (bool, error)

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

func (c *Client) SetHTTPClient(h *http.Client)

SetHTTPClient allows tests to inject a custom *http.Client (including custom Transport).

func (*Client) StartUpdater

func (c *Client) StartUpdater(ctx context.Context)

func (*Client) StopUpdater

func (c *Client) StopUpdater()

StopUpdater halts the periodic update and releases resources.

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer is a minimal interface for http clients used in tests.

type UserActivity

type UserActivity struct {
	Callsign      string
	LastUploadUTC time.Time
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL