Skip to content

Commit

Permalink
add open stats for bucket info and fixed the aggregate per api key
Browse files Browse the repository at this point in the history
  • Loading branch information
alvin-reyes committed May 23, 2023
1 parent 9da8ef4 commit afa8ac1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions api/open_status_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ func ConfigureOpenStatusCheckRouter(e *echo.Group, node *core.LightNode) {
"content": content,
})
})

e.GET("/status/bucket/:uuid", func(c echo.Context) error {
var bucket core.Bucket
node.DB.Model(&core.Bucket{}).Where("uuid = ?", c.Param("uuid")).Scan(&bucket)
if bucket.ID == 0 {
return c.JSON(404, map[string]interface{}{
"message": "Bucket not found. Please check if you have the proper API key or if the bucket uuid is valid",
})
}

bucket.RequestingApiKey = ""
return c.JSON(200, map[string]interface{}{
"bucket": bucket,
})
return nil
})

e.GET("/status/bucket/contents/:uuid", func(c echo.Context) error {
var bucket core.Bucket
node.DB.Model(&core.Bucket{}).Where("uuid = ?", c.Param("uuid")).Scan(&bucket)
Expand Down
2 changes: 1 addition & 1 deletion jobs/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *AggregateProcessor) Run() error {

for _, bucket := range buckets {
var content []core.Content
r.LightNode.DB.Model(&core.Content{}).Where(query, bucket.Uuid, bucket.RequestingApiKey).Find(&content)
r.LightNode.DB.Model(&core.Content{}).Where(query, bucket.Uuid, r.Content.RequestingApiKey).Find(&content)
var totalSize int64
var aggContent []core.Content
for _, c := range content {
Expand Down

0 comments on commit afa8ac1

Please sign in to comment.