listenbrainz: Read data from newest first

Very low min_ts parameters lead to empty results from LB and there is no
easy way to determine the oldest valid timestamp.
This commit is contained in:
Philipp Wolfer 2023-11-10 00:56:43 +01:00
parent 6047a9b274
commit 49cb2774e2
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
2 changed files with 19 additions and 10 deletions

View file

@ -52,13 +52,14 @@ func New(token string) Client {
return client
}
func (c Client) GetListens(user string, minTs time.Time) (GetListensResult, error) {
func (c Client) GetListens(user string, maxTime time.Time, minTime time.Time) (GetListensResult, error) {
const path = "/user/{username}/listens"
result := &GetListensResult{}
_, err := c.resty.R().
SetPathParam("username", user).
SetQueryParams(map[string]string{
"min_ts": strconv.FormatInt(minTs.Unix(), 10),
"max_ts": strconv.FormatInt(maxTime.Unix(), 10),
"min_ts": strconv.FormatInt(minTime.Unix(), 10),
"count": strconv.FormatInt(int64(c.MaxResults), 10),
}).
SetResult(result).