Update MinIO bucket configuration and enhance dashboard service caching
continuous-integration/drone/push Build is passing
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.
This commit is contained in:
@@ -26,7 +26,7 @@ type Config struct {
|
||||
MinioSecretKey string // MinIO secret access key
|
||||
MinioUseSSL bool // Whether to use SSL for MinIO connection
|
||||
MinioRegion string // MinIO region
|
||||
MinioBucket string // MinIO bucket name (default: "opplens-documents")
|
||||
MinioBucket string // MinIO bucket name (default: "opplens")
|
||||
MinioTimeout time.Duration // Timeout for MinIO operations
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func DefaultConfig() *Config {
|
||||
APIRetryCount: 2,
|
||||
APIRetryDelay: 3 * time.Second,
|
||||
|
||||
MinioBucket: "opplens-documents",
|
||||
MinioBucket: "opplens",
|
||||
MinioRegion: "us-east-1",
|
||||
MinioUseSSL: false,
|
||||
MinioTimeout: 30 * time.Second,
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
// procedurePrefix is prepended to every contract folder id in the MinIO key.
|
||||
// The AI team's storage layout in bucket opplens-documents is:
|
||||
// The AI team's storage layout in bucket opplens is:
|
||||
//
|
||||
// PROC_<contractFolderID>/<noticePublicationID>/tender.json
|
||||
// PROC_<contractFolderID>/<noticePublicationID>/documents/{files}
|
||||
|
||||
+39
-6
@@ -104,14 +104,47 @@ func (c *Counter) GetDailyCounts(ctx context.Context, startDay, endDay time.Time
|
||||
return map[string]int64{}, nil
|
||||
}
|
||||
|
||||
counts := make(map[string]int64)
|
||||
keys := make([]string, 0)
|
||||
dates := make([]string, 0)
|
||||
for day := startDay; !day.After(endDay); day = day.AddDate(0, 0, 1) {
|
||||
date := day.Format("2006-01-02")
|
||||
value, err := c.Get(ctx, AITranslationSuccessDailyCounterKey(day))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
dates = append(dates, day.Format("2006-01-02"))
|
||||
keys = append(keys, AITranslationSuccessDailyCounterKey(day))
|
||||
}
|
||||
|
||||
counts := make(map[string]int64, len(dates))
|
||||
for _, date := range dates {
|
||||
counts[date] = 0
|
||||
}
|
||||
|
||||
cursor, err := c.mongo.GetCollection(metricsCountersCollection).Find(ctx, bson.M{
|
||||
"_id": bson.M{"$in": keys},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("mongo counter get daily counts: %w", err)
|
||||
}
|
||||
defer cursor.Close(ctx)
|
||||
|
||||
keyToDate := make(map[string]string, len(keys))
|
||||
for i, key := range keys {
|
||||
keyToDate[key] = dates[i]
|
||||
}
|
||||
|
||||
for cursor.Next(ctx) {
|
||||
var doc struct {
|
||||
ID string `bson:"_id"`
|
||||
Count int64 `bson:"count"`
|
||||
}
|
||||
counts[date] = value
|
||||
if err := cursor.Decode(&doc); err != nil {
|
||||
return nil, fmt.Errorf("mongo counter decode daily count: %w", err)
|
||||
}
|
||||
date, ok := keyToDate[doc.ID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
counts[date] = doc.Count
|
||||
}
|
||||
if err := cursor.Err(); err != nil {
|
||||
return nil, fmt.Errorf("mongo counter iterate daily counts: %w", err)
|
||||
}
|
||||
|
||||
return counts, nil
|
||||
|
||||
Reference in New Issue
Block a user