Skip to content

Commit

Permalink
changed stats metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirari04 committed Jan 15, 2024
1 parent 9c5784d commit b48c48a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 8 additions & 6 deletions controllers/GetSystemStatsController.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ func GetSystemStats(c *fiber.Ctx) error {
DiskW float64
DiskR float64
}
amount := 240
duration := time.Minute
var response []StatItem
for i := 0; i < 24; i++ {
for i := 0; i < amount; i++ {
var resources StatItem
addFromHours := time.Hour * time.Duration(24-(i)) * -1
from := time.Now().Add(addFromHours)
addUntilHours := time.Hour * time.Duration(24-(i+1)) * -1
until := time.Now().Add(addUntilHours)
addFrom := duration * time.Duration(amount-(i)) * -1
from := time.Now().Add(addFrom)
addUntil := duration * time.Duration(amount-(i+1)) * -1
until := time.Now().Add(addUntil)
if res := inits.DB.
Model(&models.SystemResource{}).
Select(
Expand All @@ -45,7 +47,7 @@ func GetSystemStats(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusInternalServerError)
}
response = append(response, StatItem{
CreatedAt: time.Now().Add(time.Hour * time.Duration(24-(i+1)) * -1),
CreatedAt: time.Now().Add(duration * time.Duration(amount-(i+1)) * -1),
Cpu: resources.Cpu,
Mem: resources.Mem,
NetOut: resources.NetOut,
Expand Down
7 changes: 2 additions & 5 deletions middlewares/JwtStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ func JwtStream(c *fiber.Ctx) error {
if uuid == "" {
return c.Status(fiber.StatusBadRequest).SendString("Missing UUID parameter")
}
tknStr := c.Cookies(uuid, "")
tknStr := c.Query("jwt", "")
if tknStr == "" {
tknStr = c.Query("jwt", "")
if tknStr == "" {
return c.Status(fiber.StatusBadRequest).SendString("UUID parameter match issue")
}
return c.Status(fiber.StatusBadRequest).SendString("UUID parameter match issue")
}
token, claims, err := auth.VerifyJWTStream(tknStr)
if err != nil {
Expand Down

0 comments on commit b48c48a

Please sign in to comment.