Made the fetcher save what it fetches, with fetcher.WithStore
With WithStore, the Find a Tender and mock workers save each run's opportunities with SaveOpportunities and log what changed; a failed save fails the run, so the checkpoint stays put and the next run retries. Without a store nothing is persisted. The mock's opportunities are saved with Source "FTSMock" rather than the converter's "FindATender". fetcher service and job-search serve open the store at database.file (cli.OpenConfiguredStore), or warn and run without one. A missing file isn't created, and a database needing migration says to run job-search migrate. Fixed upsertOpportunity, which never wrote the source column, so every saved opportunity had an empty Source.
This commit is contained in:
1 parent
eba6af680f
commit
b3d20c1db0
10 files changed
+407
-38
No files matched your search
@@ -32,13 +32,13 @@ const upsertOpportunity = `
|
||||
INSERT INTO opportunities (
|
||||
uuid, uuid_type, title, status, description, buyer_name, buyer_id,
|
||||
main_category, procurement_method, multi_lot, sme_suitable,
|
||||
vcse_suitable, start_date, end_date, gross_value, has_documents,
|
||||
vcse_suitable, start_date, end_date, gross_value, has_documents, source,
|
||||
latest_release_date
|
||||
) VALUES (
|
||||
:uuid, :uuid_type, :title, :status, :description, :buyer_name, :buyer_id,
|
||||
:main_category, :procurement_method, :multi_lot, :sme_suitable,
|
||||
:vcse_suitable, :start_date, :end_date, :gross_value, :has_documents,
|
||||
:latest_release_date
|
||||
:source, :latest_release_date
|
||||
)
|
||||
ON CONFLICT (uuid) DO UPDATE SET
|
||||
uuid_type = excluded.uuid_type,
|
||||
@@ -56,6 +56,7 @@ ON CONFLICT (uuid) DO UPDATE SET
|
||||
end_date = excluded.end_date,
|
||||
gross_value = excluded.gross_value,
|
||||
has_documents = excluded.has_documents,
|
||||
source = excluded.source,
|
||||
latest_release_date = excluded.latest_release_date`
|
||||
|
||||
// selectOpportunityByUUID reads one opportunity into a opportunityRow.
|
||||
|
||||
@@ -52,6 +52,7 @@ func opportunity(
|
||||
EndDate: &end,
|
||||
GrossValue: 125000.50,
|
||||
HasDocuments: true,
|
||||
Source: "FindATender",
|
||||
Classifications: []types.ClassificationCode{
|
||||
{
|
||||
IsCPV: true,
|
||||
@@ -144,7 +145,8 @@ func TestSaveAndGetRoundTrip(t *testing.T) {
|
||||
got.ProcurementMethod != in.ProcurementMethod || got.UUIDType != "ocid" ||
|
||||
got.Status != "active" || got.Description != in.Description ||
|
||||
!got.MultiLot || !got.SMESuitable || got.VCSESuitable ||
|
||||
!got.HasDocuments || got.GrossValue != in.GrossValue {
|
||||
!got.HasDocuments || got.GrossValue != in.GrossValue ||
|
||||
got.Source != in.Source {
|
||||
t.Errorf("opportunity fields differ:\n got %+v\nwant %+v", got, in)
|
||||
}
|
||||
if got.StartDate == nil || !got.StartDate.Equal(day(20)) ||
|
||||
|
||||
Reference in new issue
Block a user