fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 58s
Deploy Dev / Push (pull_request) Successful in 36s
Deploy Dev / Deploy dev (pull_request) Successful in 15s

This commit is contained in:
Egor Matveev
2025-06-15 22:24:06 +03:00
parent fad93012a1
commit f2ab91cbce
3 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package storage
import (
"context"
"time"
)
type IncrementMetric struct {
Timestamp time.Time `json:"timestamp"`
Service string `json:"service"`
Environment string `json:"environment"`
Name string `json:"name"`
Count int `json:"count"`
}
func AddIncrementMetric(metric IncrementMetric) error {
batch, err := connection().PrepareBatch(context.Background(), "INSERT INTO increments")
if err != nil {
return err
}
err = batch.Append(
metric.Timestamp,
metric.Service,
metric.Environment,
metric.Name,
metric.Count,
)
if err != nil {
return err
}
return batch.Send()
}