Skip to content

Commit

Permalink
fix limit result
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelef committed Oct 8, 2023
1 parent 3a242a3 commit 48a36c0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,30 @@ func main() {
})

app.Get("/limits", func(c *fiber.Ctx) error {
randomIndex := rand.Intn(len(maps.Keys(ghStatClients)))
clientKey := c.Query("client", maps.Keys(ghStatClients)[randomIndex])
client, ok := ghStatClients[clientKey]
client, ok := ghStatClients["PAT"]
if !ok {
return c.Status(404).SendString("Resource not found")
}
result, err := client.GetCurrentLimits(ctx)

if err != nil {
log.Fatalf("Error getting limits %v", err)
}

client, ok = ghStatClients["PAT2"]
if !ok {
return c.Status(404).SendString("Resource not found")
}

tmpResult, err := client.GetCurrentLimits(ctx)

if err != nil {
log.Fatalf("Error getting limits %v", err)
}

result.Remaining += tmpResult.Remaining
result.Limit += tmpResult.Limit

return c.JSON(result)
})

Expand Down

0 comments on commit 48a36c0

Please sign in to comment.