feat: daily vani
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user