get scraped documents list performance update

This commit is contained in:
Mazyar
2026-05-20 11:43:14 +03:30
parent 2d5df8556f
commit 06ab5830e2
3 changed files with 125 additions and 26 deletions
+5 -2
View File
@@ -5,6 +5,7 @@ import (
"mime"
"net/http"
"strconv"
"strings"
"time"
"tm/pkg/logger"
orm "tm/pkg/mongo"
@@ -661,11 +662,12 @@ func (h *TenderHandler) TriggerPublicAITranslate(c echo.Context) error {
// ListTendersWithScrapedDocuments lists tenders that have scraped documents in the database
// @Summary List tenders with scraped documents
// @Description Lists database tenders whose contract_folder_id has documents in MinIO (PROC_<contract_folder_id>/…) and syncs scraped document metadata
// @Description Lists database tenders whose contract_folder_id has documents in MinIO. By default returns quickly using the procedure scan only. Use sync=1 to re-list each procedure in MinIO and update Mongo scraped document metadata (slow).
// @Tags Admin-Tenders
// @Produce json
// @Param limit query int false "Number of items per page (default: 10, max: 100)"
// @Param offset query int false "Number of items to skip (default: 0)"
// @Param sync query bool false "When true or 1, list each tender's documents in MinIO and persist scraped metadata to Mongo (slow)"
// @Success 200 {object} response.APIResponse{data=TendersWithScrapedDocumentsResponse}
// @Failure 400 {object} response.APIResponse
// @Failure 500 {object} response.APIResponse
@@ -677,7 +679,8 @@ func (h *TenderHandler) ListTendersWithScrapedDocuments(c echo.Context) error {
return response.PaginationBadRequest(c, err)
}
result, err := h.service.ListTendersWithScrapedDocuments(c.Request().Context(), pagination)
syncMongo := c.QueryParam("sync") == "1" || strings.EqualFold(c.QueryParam("sync"), "true")
result, err := h.service.ListTendersWithScrapedDocuments(c.Request().Context(), pagination, syncMongo)
if err != nil {
return response.InternalServerError(c, "Failed to list tenders with scraped documents")
}