Commit Graph

94 Commits

Author SHA1 Message Date
Mazyar 7aacb7dfc9 Enhance pagination and repository functionality for MongoDB
continuous-integration/drone/push Build is passing
- Updated the ListPaginationOptions struct to include SkipCount and IncludeCount fields, allowing for more flexible pagination behavior.
- Modified the BuildListPagination function to handle cursor pagination with count options, improving performance by running count queries in parallel with data retrieval.
- Enhanced the FindAll method in the repository to support concurrent counting of documents, reducing overall latency for list operations.
- Added tests for pagination behavior, ensuring accurate handling of count scenarios in both offset and cursor pagination.

This update improves the efficiency and flexibility of pagination in the MongoDB repository, enhancing the overall performance of list operations.
2026-06-30 18:35:34 +03:30
Mazyar 92c6c7d99a Refactor Elasticsearch client error handling and introduce bulk index action marshaling
- Updated error handling in the Elasticsearch client to utilize a new `readErrorBody` function for better diagnostics when pinging and searching.
- Refactored the `flushBatch` method to marshal bulk index actions using a dedicated `marshalBulkIndexAction` function, improving code clarity and error handling.
- Enhanced the overall structure of the Elasticsearch client for improved maintainability and readability.

This update enhances the robustness of the Elasticsearch client, ensuring more informative error messages and cleaner code organization.
2026-06-30 13:03:39 +03:30
Mazyar 241e3b5f2d Implement audit logging functionality across services and middleware
- Introduced a new `auditlog` package to handle audit logging for user actions, including creation, updates, deletions, and authentication events.
- Enhanced existing services (customer, user) to log relevant actions using the new audit logger, capturing details such as actor ID, action type, target type, and success status.
- Added middleware to enrich request context with metadata for audit logging, ensuring comprehensive tracking of user interactions.
- Integrated Elasticsearch for persistent storage of audit logs, with fallback to file-only logging if Elasticsearch is unavailable.
- Updated API documentation to include new audit log endpoints for administrative access.

This update significantly improves the system's ability to track and audit user actions, enhancing security and accountability within the application.
2026-06-29 21:11:33 +03:30
Mazyar 39ac76e7b0 Add scrapedDocumentsScanner interface and enhance document scanning logic
continuous-integration/drone/push Build is passing
- Introduced the `scrapedDocumentsScanner` interface to facilitate scanning of scraped documents from MinIO, returning both procedure summaries and daily document counts.
- Updated the `ListProceduresWithDocuments` method to utilize the new scanning functionality, improving data retrieval efficiency.
- Enhanced the `scrapedDocumentsPerDay` method to filter daily counts based on a specified start date, ensuring accurate reporting of document statistics.
- Added unit tests for the new scanning logic and daily counts filtering, ensuring robust functionality and error handling.

This update enhances the dashboard's document management capabilities, providing better insights into scraped documents and their daily counts.
2026-06-28 00:28:45 +03:30
Mazyar 582f8b5c02 Enhance TED scraper and worker initialization with startup catch-up logic
continuous-integration/drone/push Build is passing
- Introduced a mutex to ensure only one TED scraper run executes at a time, preventing concurrent executions during startup and scheduled runs.
- Implemented a mechanism to check if today's TED scrape has already been completed during startup, logging appropriate messages for both completed and new runs.
- Added startup catch-up logic for tender translations and unprocessed notices, ensuring that any missed tasks are executed without blocking the application startup.

This update improves the reliability and efficiency of the TED scraper and worker processes, ensuring that all necessary tasks are completed after a server restart.
2026-06-28 00:05:10 +03:30
Mazyar 5fbfcd4149 Enhance company document management with file ID sanitization and detachment functionality
continuous-integration/drone/push Build is passing
- Updated the `UploadDocuments` method to sanitize document file IDs before saving, ensuring only valid references are stored.
- Introduced `DetachDocumentFileID` method in the `companyService` to remove file IDs from all companies referencing a deleted file, improving data integrity.
- Enhanced the `companyRepository` with a new method to handle the removal of document file IDs from the database.
- Updated the `filestore` handler to utilize the new detachment functionality when files are deleted, ensuring consistent state across domain entities.

This update improves the management of document file IDs within the company domain, enhancing data integrity and reference handling.
2026-06-22 22:37:50 +03:30
Mazyar 2b6e25f979 Update rank field type in tender and onboarding response structures
continuous-integration/drone/push Build is passing
- Changed the `Rank` field type from `string` to `int` in the `RecommendedTenderResponse` struct within the `company` domain for better data representation.
- Updated the `Rank` field type from `string` to `int` in the `TenderResponse` struct within the `tender` domain to ensure consistency in ranking data.
- Modified the `Rank` field type from `string` to `int` in the `RecommendedTender` struct within the AI summarizer package to align with the updated data structure.

This update enhances the data integrity and consistency across the tender management system by standardizing the rank representation as an integer.
2026-06-21 15:24:19 +03:30
Mazyar 6fb57c41c1 Refactor ScrapePortalsResponse structure and update API documentation
continuous-integration/drone/push Build is passing
- Changed the ScrapePortalsResponse type to return a slice of strings representing portal identifiers instead of a structured object.
- Updated the Swagger documentation for the GetScrapePortals endpoint to reflect the new response format, ensuring clarity in API usage.

This update simplifies the response structure for the scraping portals, enhancing the API's usability and consistency.
2026-06-18 20:56:31 +03:30
Mazyar e5fa0dfe47 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.
2026-06-18 19:53:07 +03:30
Mazyar 2e112fe08c Update MinIO bucket configuration and enhance dashboard service caching
continuous-integration/drone/push Build is passing
- Changed the default MinIO bucket name from "opplens-documents" to "opplens" across multiple configuration files.
- Introduced caching for dashboard statistics in the service layer to improve performance and reduce redundant data fetching.
- Implemented a mutex for thread-safe access to cached statistics, ensuring data integrity during concurrent requests.

This update streamlines the configuration for the AI summarizer and optimizes the dashboard service, enhancing overall system efficiency.
2026-06-14 15:14:02 +03:30
Mazyar ca35eb5f15 Enhance worker configuration and error handling for AI summarizer
continuous-integration/drone/push Build is passing
- Added `TranslationEnabled` and `TranslationInterval` fields to the worker configuration to manage automatic translation scheduling.
- Updated the worker initialization to log when the translation worker is disabled.
- Improved error handling in the AI summarizer client by introducing `APIStatusError` for better context on API failures, replacing direct error messages with structured error responses.

This update enhances the configurability of the worker and improves error reporting for AI service interactions, contributing to better maintainability and user experience.
2026-06-14 14:02:35 +03:30
Mazyar dcf19b91cd Implement AI pipeline operations in the admin API
- Added new routes and handlers for AI pipeline operations, including scraping documents, batch summarization, translation, and syncing with the Opplens AI service.
- Introduced request forms for handling tender references and batch operations.
- Enhanced the AI service with methods for triggering batch operations and managing pipeline runs.
- Updated Swagger documentation to reflect the new AI pipeline endpoints and their functionalities.

This update integrates comprehensive AI pipeline capabilities into the tender management system, improving operational efficiency and user experience.
2026-06-14 12:54:13 +03:30
Mazyar 3b26c4f5e1 Implement AI onboarding and recommendation features in company service
- Added new AI onboarding and recommendation endpoints in the company handler for starting onboarding and retrieving ranked tender recommendations.
- Introduced `StartAIOnboarding` and `GetAIRecommendations` methods in the company service to handle AI interactions.
- Updated the company service constructor to include the AI recommendation client.
- Enhanced the AI summarizer client with methods for onboarding and fetching recommendations.
- Added response structures for onboarding and recommended tenders in the company form.

This update enhances the tender management system by integrating AI capabilities for onboarding and tender recommendations, improving user experience and operational efficiency.
2026-06-11 01:08:59 +03:30
Mazyar 9cd22c24b6 Refactor queue management by removing deprecated components and updating configuration
- Removed the QueueConfig structure and related queue management files as they are no longer in use.
- Updated the worker initialization to reflect the removal of queue-related configurations.
- Cleaned up the bootstrap process by eliminating deprecated logging related to the queue system.

This update streamlines the worker's configuration and prepares the codebase for future enhancements without the legacy queue management components.
2026-06-08 23:49:51 +03:30
Mazyar 7d383c36c3 Implement AI analysis trigger endpoint and refactor related components
- Added a new endpoint to trigger on-demand agentic analysis for tenders via the AI service.
- Introduced `TriggerAIAnalyze` method in the `TenderHandler` to handle requests and responses for AI analysis.
- Updated the `tenderService` to include `TriggerAIAnalyze` method, which validates input and interacts with the AI summarizer client.
- Enhanced the `AIAnalyzeResponse` and `AIAnalyzeDocument` structures to support the new analysis feature.
- Refactored the `DocumentSummarizationWorker` and `TranslationWorker` to remove deprecated MinIO dependencies, streamlining the AI service interactions.

This update improves the functionality of the tender management system by allowing users to trigger AI analysis on-demand, enhancing the overall user experience and system capabilities.
2026-06-08 18:01:15 +03:30
Mazyar 3f0935ee3f Enhance duplicate key error handling in MongoDB operations
- Improved the `IsDuplicateKeyError` function to utilize structured error messages for better accuracy in identifying duplicate key errors.
- Introduced `duplicateKeyMessages` and `hasStructuredWriteException` functions to parse and extract relevant information from MongoDB error messages.
- Updated `DuplicateKeyMatchesField` to match duplicate key errors against specific fields by analyzing error messages rather than relying on substring matching.

This refactor enhances the clarity and reliability of duplicate key error handling, ensuring more precise identification of conflicts in MongoDB operations.
2026-06-07 14:40:42 +03:30
m.nazemi 550fd36db1 Merge branch 'develop' into Phone-Uniqueness 2026-06-07 14:33:48 +03:30
m.nazemi a75e4743f0 Merge pull request 'Refactor AI summarizer client initialization to include MongoDB manager and add statistics endpoint' (#36) from TM-602 into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/36
2026-06-07 14:32:37 +03:30
Mazyar c91b525e7e Refactor MongoDB index creation to use NonEmptyStringPartialFilter for improved clarity and consistency. Update GetOJS function to utilize context and user agent for HTTP requests, enhancing error handling and response management. 2026-06-06 21:36:43 +03:30
Mazyar 68b170126d Refactor AI summarizer client initialization to include MongoDB manager and add statistics endpoint
- Updated `InitAISummarizerClient` to accept `mongoManager` for tracking translation success.
- Introduced new `Statistics` endpoint in the dashboard to fetch scraping and translation statistics.
- Enhanced `TranslationWorker` to utilize the new success counter for tracking successful translations.
- Added necessary data structures and query forms for statistics reporting.

This refactor improves the tracking of AI translation success and provides new insights through the dashboard statistics.
2026-06-06 21:20:53 +03:30
Mazyar 22487eaef5 fix(user,customer): return 409 on phone duplicate-key races
Map E11000 from the per-collection phone index to friendly conflict
errors and skip redundant GetByPhone when the phone is unchanged.

Not blocking: IAT test DB may need a one-off dedupe for index build;
phone uniqueness is per collection (users vs customers), not global.
2026-06-06 20:34:45 +03:30
Mazyar 5af3bfaa1a Allow address.country and address.state as company sort fields.
Frontend sends nested address field names for sorting; accept them alongside the existing country and state aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 09:41:12 +03:30
Mazyar a9f1611c48 Added curso test 2026-06-03 12:43:12 +03:30
m.nazemi cf77e90f84 Merge branch 'develop' into sort 2026-06-03 12:38:12 +03:30
Mazyar 2090cc05ba Enhance company and company category search forms by adding new sortable fields (email, phone, country, state, language, currency) and updating related API documentation. 2026-06-02 22:07:49 +03:30
Mazyar a4c04912c8 Implement multi-file upload functionality for companies and enhance file upload routes 2026-06-02 21:24:39 +03:30
Mazyar bca94cd69a go-rules temporarily disabled 2026-05-30 16:19:21 +03:30
m.nazemi e869e149c5 Merge pull request 'kanban dashboard refactor' (#21) from kanban into develop
Reviewed-on: https://repo.ravanertebat.com/TM/tm_back/pulls/21
Reviewed-by: Hadi Barzegar <barzagarhadi@gmail.com>
2026-05-30 14:19:24 +03:30
Mazyar ad702f24bf fixed blocking important issues 2026-05-30 12:29:45 +03:30
Mazyar bb221f3cda Add admin password reset functionality for users and customers 2026-05-29 20:15:09 +03:30
Mazyar ce2dc7a61b kanban dashboard refactor 2026-05-27 22:06:23 +03:30
Mazyar da2d50bd70 fixed critical security issues 2026-05-25 13:23:49 +03:30
Mazyar f7763cf997 get all tenders with documeents scraped API 2026-05-19 19:23:18 +03:30
Mazyar fcf2cae6bc tender summary refactor 2026-05-19 19:03:50 +03:30
Mazyar 6dac5b482a hybrid pagination 2026-05-17 17:21:36 +03:30
Mazyar 42d0a47226 tender summary response fix 2026-05-17 17:02:12 +03:30
Mazyar 70f581da09 cursor pagination 2026-05-16 15:51:18 +03:30
Mazyar bcb345103f minio connection log 2026-05-16 14:08:58 +03:30
Mazyar 6701428b09 AI translate refactor 2026-05-16 12:56:10 +03:30
Mazyar ca490f3acf get aiSummary and documents refactor 2026-05-16 11:01:13 +03:30
Mazyar f08982afb5 pagination optimization 2026-05-14 14:18:34 +03:30
Mazyar eaa681814d Minio document json 2026-05-13 18:24:45 +03:30
Mazyar 5ab6b2714e AI scraper prefix 2026-05-13 17:32:37 +03:30
Mazyar 584992f0b6 translation body update 2026-05-13 14:50:37 +03:30
Mazyar c518cd3afb pagination offset bug fix 2026-05-13 00:07:31 +03:30
Mazyar 7c42b343ce document scraper logic and API refactor 2026-05-11 15:52:32 +03:30
Mazyar b4efb97f47 merge tenders which have the same procedure id - worker performance fix 2026-05-11 15:10:01 +03:30
Mazyar e136f0eaa7 List and download tender documents - worker auto translation to english job 2026-05-10 02:14:53 +03:30
Mazyar b480ed2371 Integrated AI translation 2026-05-08 16:17:33 +03:30
Mazyar 65a19d1514 Integrated AI summary 2026-05-05 17:47:31 +03:30