Add TED Scraper Configuration and Cron Scheduler Implementation
- Introduced a new configuration file for the TED scraper, defining database connection settings, logging preferences, and scraping parameters. - Implemented a CronScheduler to manage scheduled tasks for TED operations, utilizing the robfig/cron library for scheduling. - Added new entities and structures for handling TED XML data, including eForms and tender-related information, enhancing the scraper's functionality. - Updated the main application to initialize the TED scraper with the new configuration and set up graceful shutdown handling. - Removed the deprecated scraping implementation to streamline the codebase and focus on the new architecture.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package eform
|
||||
|
||||
import "time"
|
||||
|
||||
// =====================================================
|
||||
// MODIFICATION STRUCTURE
|
||||
// =====================================================
|
||||
|
||||
// Modification represents changes to existing contracts
|
||||
type Modification struct {
|
||||
ID string `json:"id" xml:"id" validate:"required,modIDFormat"`
|
||||
OriginalContractID string `json:"original_contract_id" xml:"original_contract_id" validate:"required,conIDFormat"`
|
||||
Reason ModificationReason `json:"reason" xml:"reason" validate:"required"`
|
||||
ReasonDescription string `json:"reason_description" xml:"reason_description" validate:"required,max=10000"`
|
||||
ValueBefore Money `json:"value_before" xml:"value_before" validate:"required"`
|
||||
ValueAfter Money `json:"value_after" xml:"value_after" validate:"required"`
|
||||
ValueChange Money `json:"value_change" xml:"value_change"`
|
||||
PercentageChange float64 `json:"percentage_change" xml:"percentage_change"`
|
||||
DurationBefore *Duration `json:"duration_before,omitempty" xml:"duration_before,omitempty"`
|
||||
DurationAfter *Duration `json:"duration_after,omitempty" xml:"duration_after,omitempty"`
|
||||
ModificationDescription string `json:"modification_description" xml:"modification_description" validate:"required,max=10000"`
|
||||
ModificationDate time.Time `json:"modification_date" xml:"modification_date" validate:"required"`
|
||||
ContractorChange bool `json:"contractor_change" xml:"contractor_change"`
|
||||
NewContractorIDs []string `json:"new_contractor_ids,omitempty" xml:"new_contractor_ids,omitempty"`
|
||||
}
|
||||
|
||||
// ModificationReason represents the reason for contract modification
|
||||
type ModificationReason string
|
||||
|
||||
const (
|
||||
ModReasonAdditionalWorks ModificationReason = "add-wks"
|
||||
ModReasonUnforeseen ModificationReason = "unforeseen"
|
||||
ModReasonDesignDefect ModificationReason = "design-defect"
|
||||
ModReasonAdditionalNeed ModificationReason = "additional-need"
|
||||
ModReasonRepeatSimilar ModificationReason = "repeat-similar"
|
||||
ModReasonRatePriceUpdate ModificationReason = "rate-price-update"
|
||||
ModReasonSuspendCall ModificationReason = "suspend-call"
|
||||
ModReasonOther ModificationReason = "other"
|
||||
)
|
||||
|
||||
// CalculateModificationChange calculates value change for modifications
|
||||
func (m *Modification) CalculateModificationChange() {
|
||||
if m.ValueBefore.Currency == m.ValueAfter.Currency {
|
||||
change := m.ValueAfter.Amount - m.ValueBefore.Amount
|
||||
m.ValueChange = Money{
|
||||
Amount: change,
|
||||
Currency: m.ValueBefore.Currency,
|
||||
}
|
||||
if m.ValueBefore.Amount != 0 {
|
||||
m.PercentageChange = (change / m.ValueBefore.Amount) * 100
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user