tender duplication fix

This commit is contained in:
Mazyar
2026-05-12 17:02:39 +03:30
parent 29b4aa50bd
commit 5e8d4f67b2
7 changed files with 290 additions and 22 deletions
+36 -4
View File
@@ -138,8 +138,9 @@ func (s *TEDScraper) mapToTender(cn *ContractNotice, sourceFileURL, sourceFileNa
now := time.Now().Unix()
t := &notice.Notice{
ContractNoticeID: cn.ID,
ContractFolderID: cn.ContractFolderID,
ContractNoticeID: cn.ID,
ContractFolderID: cn.ContractFolderID,
ProcurementProjectID: procurementProjectIDFromContractNotice(cn),
NoticeTypeCode: strings.TrimSpace(cn.GetNoticeType()),
FormType: cn.GetNoticeFormType(),
NoticeSubTypeCode: cn.GetNoticeSubType(),
@@ -297,8 +298,9 @@ func (s *TEDScraper) mapContractAwardNoticeToTender(can *ContractAwardNotice, so
now := time.Now().Unix()
t := &notice.Notice{
ContractNoticeID: can.ID,
ContractFolderID: can.ContractFolderID,
ContractNoticeID: can.ID,
ContractFolderID: can.ContractFolderID,
ProcurementProjectID: procurementProjectIDFromContractAwardNotice(can),
NoticeTypeCode: strings.TrimSpace(can.GetNoticeType()),
FormType: can.GetNoticeFormType(),
NoticeSubTypeCode: can.GetNoticeSubType(),
@@ -428,6 +430,36 @@ func (s *TEDScraper) mapContractAwardNoticeToTender(can *ContractAwardNotice, so
return t
}
func procurementProjectIDFromContractNotice(cn *ContractNotice) string {
if cn == nil {
return ""
}
if cn.ProcurementProject != nil {
if id := strings.TrimSpace(cn.ProcurementProject.ID); id != "" {
return id
}
}
if lot := cn.firstLot(); lot != nil && lot.ProcurementProject != nil {
return strings.TrimSpace(lot.ProcurementProject.ID)
}
return ""
}
func procurementProjectIDFromContractAwardNotice(can *ContractAwardNotice) string {
if can == nil {
return ""
}
if can.ProcurementProject != nil {
if id := strings.TrimSpace(can.ProcurementProject.ID); id != "" {
return id
}
}
if lot := can.firstAwardLot(); lot != nil && lot.ProcurementProject != nil {
return strings.TrimSpace(lot.ProcurementProject.ID)
}
return ""
}
// mapOrganization maps a TED Organization to tender Organization
func (s *TEDScraper) mapOrganization(tedOrg *Organization, role string) *notice.Organization {
if tedOrg == nil || tedOrg.Company == nil {