feat: daily vani

This commit is contained in:
Krispire Admin
2026-07-11 00:44:08 +05:30
parent c26904b61e
commit d29eb5d844
2 changed files with 24 additions and 7 deletions
+16
View File
@@ -87,6 +87,22 @@ func (r *VaniRepo) Insert(ctx context.Context, pick *model.VaniPick) error {
return nil
}
// BookTitle resolves a book code to its display title (from book_meta.data.title),
// or "" if unknown. Used to label a prose pick with its book name.
func (r *VaniRepo) BookTitle(ctx context.Context, book string) string {
var raw bson.M
if err := r.mongo.Collection("book_meta").
FindOne(ctx, bson.D{{Key: "book", Value: book}}).Decode(&raw); err != nil {
return ""
}
if data, ok := raw["data"].(bson.M); ok {
if t, ok := data["title"].(string); ok {
return t
}
}
return ""
}
// --- Mongo: random candidate sampling ---
// excludeIDs turns hex _id strings into a $nin ObjectID array.