Find a Tender API client updates
- Convert OCDS releases to types.Opportunity (internal/types); FetchOnce and FetchAll now return opportunities, built from each ocid's latest release - Include each item's main classification as well as its additional ones - Return ErrUnexpectedStatus for non-200 responses and ErrRateLimitExceeded for a repeated 429; close discarded bodies - Stop fetchAll on a repeated next link and close each page's body once read rather than deferring in the loop - Default a zero Since to 24 hours ago - Merge date repair and releaseIDs into api.go - Filter --planning/--opportunities/--awards on each procedure's current stage, using OCDS release tags; --opportunities previously matched a nonexistent "opportunity" tag and returned nothing - Reject conflicting filters before fetching (cobra flag group)
This commit is contained in:
1 parent
69620e5f7d
commit
399eccf2de
8 files changed
+567
-86
No files matched your search
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.avsdev.uk/Go/job-search/internal/config"
|
||||
"git.avsdev.uk/Go/job-search/internal/findATender/ocds"
|
||||
"git.avsdev.uk/Go/job-search/internal/types"
|
||||
resty "resty.dev/v3"
|
||||
)
|
||||
|
||||
@@ -29,7 +29,6 @@ func New(conf *config.JobSearchConfig, apiRoot string) FindATender {
|
||||
|
||||
func (ft *FindATender) ReloadConfig(conf *config.JobSearchConfig) {
|
||||
ft.config = conf
|
||||
// TODO: any reloading required for configuration change handling
|
||||
}
|
||||
|
||||
func (ft *FindATender) With(ctx context.Context) *FindATender {
|
||||
@@ -49,27 +48,27 @@ func (ft *FindATender) Shutdown() {
|
||||
func (ft *FindATender) FetchOnce(
|
||||
since time.Time,
|
||||
allowRateLimit bool,
|
||||
) ([]ocds.Release, error) {
|
||||
reqs, err := ft.fetchOnce(RequestOptions{
|
||||
) ([]*types.Opportunity, error) {
|
||||
releases, err := ft.fetchOnce(RequestOptions{
|
||||
Since: since,
|
||||
AllowRateLimit: allowRateLimit,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return reqs, nil
|
||||
return Convert(releases), nil
|
||||
}
|
||||
|
||||
func (ft *FindATender) FetchAll(
|
||||
since time.Time,
|
||||
allowRateLimit bool,
|
||||
) ([]ocds.Release, error) {
|
||||
reqs, err := ft.fetchAll(RequestOptions{
|
||||
) ([]*types.Opportunity, error) {
|
||||
releases, err := ft.fetchAll(RequestOptions{
|
||||
Since: since,
|
||||
AllowRateLimit: allowRateLimit,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return reqs, nil
|
||||
return Convert(releases), nil
|
||||
}
|
||||
Reference in new issue
Block a user