ted one-time api
This commit is contained in:
+55
-2
@@ -103,6 +103,7 @@ import (
|
||||
"tm/internal/feedback"
|
||||
"tm/internal/inquiry"
|
||||
"tm/internal/kanban"
|
||||
"tm/internal/notice"
|
||||
"tm/internal/notification"
|
||||
"tm/internal/scraper"
|
||||
"tm/internal/tender"
|
||||
@@ -115,6 +116,56 @@ import (
|
||||
"tm/cmd/web/router"
|
||||
)
|
||||
|
||||
func buildTEDConfig(c *bootstrap.TEDConfig) *scraper.TEDConfig {
|
||||
if c == nil {
|
||||
return &scraper.TEDConfig{
|
||||
BaseURL: "https://ted.europa.eu",
|
||||
Timeout: 30 * time.Second,
|
||||
MaxRetries: 3,
|
||||
RetryDelay: 5 * time.Second,
|
||||
UserAgent: "TM-TED-Scraper/1.0",
|
||||
MaxConcurrency: 5,
|
||||
DownloadDir: "./downloads",
|
||||
CleanupAfter: 24 * time.Hour,
|
||||
ScrapingInterval: "* * 10 * * *",
|
||||
AlertMail: "alerts@opplens.com",
|
||||
}
|
||||
}
|
||||
baseURL := c.BaseURL
|
||||
if baseURL == "" {
|
||||
baseURL = "https://ted.europa.eu"
|
||||
}
|
||||
userAgent := c.UserAgent
|
||||
if userAgent == "" {
|
||||
userAgent = "TM-TED-Scraper/1.0"
|
||||
}
|
||||
downloadDir := c.DownloadDir
|
||||
if downloadDir == "" {
|
||||
downloadDir = "./downloads"
|
||||
}
|
||||
scrapingInterval := c.ScrapingInterval
|
||||
if scrapingInterval == "" {
|
||||
scrapingInterval = "* * 10 * * *"
|
||||
}
|
||||
alertMail := c.AlertMail
|
||||
if alertMail == "" {
|
||||
alertMail = "alerts@opplens.com"
|
||||
}
|
||||
return &scraper.TEDConfig{
|
||||
BaseURL: baseURL,
|
||||
Timeout: c.Timeout,
|
||||
MaxRetries: c.MaxRetries,
|
||||
RetryDelay: c.RetryDelay,
|
||||
UserAgent: userAgent,
|
||||
MaxConcurrency: c.MaxConcurrency,
|
||||
DownloadDir: downloadDir,
|
||||
CleanupAfter: c.CleanupAfter,
|
||||
ScrapingInterval: scrapingInterval,
|
||||
MaxNoticesPerDay: c.MaxNoticesPerDay,
|
||||
AlertMail: alertMail,
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
conf := bootstrap.InitConfig()
|
||||
|
||||
@@ -168,11 +219,12 @@ func main() {
|
||||
inquiryRepository := inquiry.NewRepository(mongoManager, logger)
|
||||
contactRepository := contact.NewContactRepository(mongoManager, logger)
|
||||
cmsRepository := cms.NewRepository(mongoManager, logger)
|
||||
noticeRepository := notice.NewRepository(mongoManager, logger)
|
||||
boardRepository := kanban.NewBoardRepository(mongoManager, logger)
|
||||
columnRepository := kanban.NewColumnRepository(mongoManager, logger)
|
||||
cardRepository := kanban.NewCardRepository(mongoManager, logger)
|
||||
logger.Info("Repositories initialized successfully", map[string]interface{}{
|
||||
"repositories": []string{"customer", "user", "company", "category", "tender", "feedback", "tender_approval", "inquiry", "contact", "cms", "kanban_board", "kanban_column", "kanban_card"},
|
||||
"repositories": []string{"customer", "user", "company", "category", "tender", "feedback", "tender_approval", "inquiry", "contact", "cms", "notice", "kanban_board", "kanban_column", "kanban_card"},
|
||||
})
|
||||
|
||||
// Initialize validation services
|
||||
@@ -193,7 +245,8 @@ func main() {
|
||||
notificationService := notification.NewService(notificationSDK, userService, customerService, logger)
|
||||
contactService := contact.NewService(contactRepository, logger, notificationSDK)
|
||||
cmsService := cms.NewService(cmsRepository, logger)
|
||||
scraperService := scraper.NewService(conf.Scraper.BaseURL, conf.Scraper.Timeout, logger)
|
||||
tedConfig := buildTEDConfig(&conf.TED)
|
||||
scraperService := scraper.NewServiceWithTED(conf.Scraper.BaseURL, conf.Scraper.Timeout, logger, mongoManager, noticeRepository, notificationSDK, tedConfig)
|
||||
kanbanService := kanban.NewService(boardRepository, columnRepository, cardRepository, logger)
|
||||
logger.Info("Services initialized successfully", map[string]interface{}{
|
||||
"services": []string{"customer", "user", "company", "category", "tender", "feedback", "tender_approval", "inquiry", "flag", "notification", "contact", "cms", "scraper", "kanban"},
|
||||
|
||||
Reference in New Issue
Block a user