Refactor document scraper service to support multiple country codes for pending tenders retrieval.

This commit is contained in:
Mazyar
2026-06-01 11:14:18 +03:30
parent cc6c0e1660
commit 4beb57f42e
2 changed files with 24 additions and 11 deletions
+9 -5
View File
@@ -32,7 +32,7 @@ type TenderRepository interface {
Search(ctx context.Context, form *SearchForm, pagination *response.Pagination) (*SearchPageResult, error)
GetExpiredTenders(ctx context.Context, beforeDate int64) ([]Tender, error)
GetUnScrapedTenders(ctx context.Context, limit, skip int) ([]Tender, int64, error)
GetPendingDocumentScrapeTenders(ctx context.Context, countryCode string, minDeadline int64, limit, skip int) ([]Tender, bool, error)
GetPendingDocumentScrapeTenders(ctx context.Context, countryCodes []string, minDeadline int64, limit, skip int) ([]Tender, bool, error)
GetUnSummarizedTenders(ctx context.Context, limit, skip int) ([]Tender, int64, error)
GetUnTranslatedTenders(ctx context.Context, language string, limit, skip int) ([]Tender, int64, error)
Update(ctx context.Context, tender *Tender) error
@@ -579,10 +579,14 @@ func (r *tenderRepository) GetUnScrapedTenders(ctx context.Context, limit, skip
return result.Items, result.TotalCount, nil
}
// GetPendingDocumentScrapeTenders returns unscraped tenders for one country with an active deadline.
func (r *tenderRepository) GetPendingDocumentScrapeTenders(ctx context.Context, countryCode string, minDeadline int64, limit, skip int) ([]Tender, bool, error) {
// GetPendingDocumentScrapeTenders returns unscraped tenders for the given countries with an active deadline.
func (r *tenderRepository) GetPendingDocumentScrapeTenders(ctx context.Context, countryCodes []string, minDeadline int64, limit, skip int) ([]Tender, bool, error) {
if len(countryCodes) == 0 {
return nil, false, nil
}
filter := bson.M{
"country_code": countryCode,
"country_code": bson.M{"$in": countryCodes},
"tender_deadline": bson.M{
"$gt": minDeadline,
},
@@ -601,7 +605,7 @@ func (r *tenderRepository) GetPendingDocumentScrapeTenders(ctx context.Context,
result, err := r.ormRepo.FindAll(ctx, filter, pagination)
if err != nil {
r.logger.Error("Failed to get pending document scrape tenders", map[string]interface{}{
"country_code": countryCode,
"country_codes": countryCodes,
"min_deadline": minDeadline,
"limit": limit,
"skip": skip,