mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-22 08:37:13 +00:00
hotfix
This commit is contained in:
parent
b761e47abb
commit
81b2eef486
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
/tmp
|
/tmp
|
||||||
config.yml
|
config.yml
|
||||||
relay_metadata.json
|
relay_metadata.json
|
||||||
|
grain.exe
|
@ -97,7 +97,13 @@ func PrependDir(dir string, files []string) []string {
|
|||||||
func FetchTopTenRecentEvents(client *mongo.Client) ([]relay.Event, error) {
|
func FetchTopTenRecentEvents(client *mongo.Client) ([]relay.Event, error) {
|
||||||
var results []relay.Event
|
var results []relay.Event
|
||||||
|
|
||||||
collection := client.Database("grain").Collection("events")
|
collections, err := client.Database("grain").ListCollectionNames(context.TODO(), bson.M{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, collectionName := range collections {
|
||||||
|
collection := client.Database("grain").Collection(collectionName)
|
||||||
filter := bson.D{}
|
filter := bson.D{}
|
||||||
opts := options.Find().SetSort(bson.D{{Key: "createdat", Value: -1}}).SetLimit(10)
|
opts := options.Find().SetSort(bson.D{{Key: "createdat", Value: -1}}).SetLimit(10)
|
||||||
|
|
||||||
@ -118,6 +124,7 @@ func FetchTopTenRecentEvents(client *mongo.Client) ([]relay.Event, error) {
|
|||||||
if err := cursor.Err(); err != nil {
|
if err := cursor.Err(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user