Add GetScrapePortals endpoint and related service functionality
continuous-integration/drone/push Build is passing

- Introduced the GetScrapePortals method in the AI pipeline handler to list document scraping portals supported by the Opplens AI service.
- Updated the service layer to include GetScrapePortals, which retrieves the portals from the client and handles errors appropriately.
- Enhanced the routes to register the new endpoint for retrieving scrape portals.
- Added a new error type for invalid date ranges in the document scraper, improving validation and error handling.

This update expands the AI pipeline capabilities, allowing for better management of document scraping portals within the tender management system.
This commit is contained in:
Mazyar
2026-06-18 19:53:07 +03:30
parent 2f19ecae55
commit e5fa0dfe47
10 changed files with 192 additions and 53 deletions
+20
View File
@@ -78,6 +78,26 @@ func (h *Handler) ScrapeDocumentsBatch(c echo.Context) error {
return response.Accepted(c, result, "Scrape batch accepted")
}
// GetScrapePortals lists document scraping portals supported by the Opplens AI service.
// @Summary List document scraping portals
// @Description Retrieve the list of document scraping portals supported by the Opplens AI service
// @Tags Admin-AI-Pipeline
// @Produce json
// @Success 200 {object} response.APIResponse{data=ai_summarizer.ScrapePortalsResponse} "Scrape portals retrieved successfully"
// @Failure 401 {object} response.APIResponse
// @Failure 500 {object} response.APIResponse
// @Failure 503 {object} response.APIResponse
// @Security BearerAuth
// @Router /admin/v1/ai-pipeline/scrape/portals [get]
func (h *Handler) GetScrapePortals(c echo.Context) error {
result, err := h.service.GetScrapePortals(c.Request().Context())
if err != nil {
return mapPipelineHTTPError(c, err, "Get scrape portals")
}
return response.Success(c, result, "Scrape portals retrieved successfully")
}
// SummarizeBatch enqueues background summarization for many tenders.
// @Summary Batch summarize tenders
// @Description Enqueue background AI summarization for multiple tenders via the Opplens AI service
+20
View File
@@ -12,6 +12,7 @@ import (
type Client interface {
ScrapeDocuments(ctx context.Context, reqBody ai_summarizer.ScrapeDocumentsRequest) (*ai_summarizer.ScrapeDocumentsResponse, error)
ScrapeDocumentsBatch(ctx context.Context, tenders []ai_summarizer.TenderRef) (*ai_summarizer.BatchAcceptedResponse, error)
GetScrapePortals(ctx context.Context) (*ai_summarizer.ScrapePortalsResponse, error)
TriggerSummarizeBatch(ctx context.Context, tenders []ai_summarizer.TenderRef) (*ai_summarizer.BatchAcceptedResponse, error)
TriggerTranslateBatch(ctx context.Context, tenders []ai_summarizer.TenderRef, languages []string) (*ai_summarizer.BatchAcceptedResponse, error)
PipelineSync(ctx context.Context) (*ai_summarizer.PipelineSyncResponse, error)
@@ -31,6 +32,7 @@ type Client interface {
type Service interface {
ScrapeDocuments(ctx context.Context, form ScrapeDocumentsForm) (*ai_summarizer.ScrapeDocumentsResponse, error)
ScrapeDocumentsBatch(ctx context.Context, form TenderBatchForm) (*ai_summarizer.BatchAcceptedResponse, error)
GetScrapePortals(ctx context.Context) (*ai_summarizer.ScrapePortalsResponse, error)
SummarizeBatch(ctx context.Context, form TenderBatchForm) (*ai_summarizer.BatchAcceptedResponse, error)
TranslateBatch(ctx context.Context, form TranslateBatchForm) (*ai_summarizer.BatchAcceptedResponse, error)
Sync(ctx context.Context) (*ai_summarizer.PipelineSyncResponse, error)
@@ -128,6 +130,24 @@ func (s *service) ScrapeDocumentsBatch(ctx context.Context, form TenderBatchForm
return resp, nil
}
func (s *service) GetScrapePortals(ctx context.Context) (*ai_summarizer.ScrapePortalsResponse, error) {
if err := s.requireClient(); err != nil {
return nil, err
}
s.logger.Info("Admin get scrape portals requested", map[string]interface{}{})
resp, err := s.client.GetScrapePortals(ctx)
if err != nil {
s.logger.Error("Admin get scrape portals failed", map[string]interface{}{
"error": err.Error(),
})
return nil, fmt.Errorf("get scrape portals failed: %w", err)
}
return resp, nil
}
func (s *service) SummarizeBatch(ctx context.Context, form TenderBatchForm) (*ai_summarizer.BatchAcceptedResponse, error) {
if err := s.requireClient(); err != nil {
return nil, err