Update aggregate API to use binary megabytes and enhance documentation
Publish telemt-api gateway Docker image / test (push) Successful in 27s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 1m26s

- Changed API responses and internal calculations to use binary megabytes (MiB) instead of octets for traffic metrics.
- Updated relevant endpoints in AGGREGATE.md to reflect the new metric units.
- Modified handler and merge logic to accommodate the new data structure and ensure accurate traffic reporting.
- Enhanced tests to validate the changes in traffic calculations and summary data.
- Deprecated the use of total_octets in favor of total_megabytes for consistency across the API.
This commit is contained in:
Denozordec
2026-03-30 01:04:00 +07:00
parent fb35107b82
commit 4a4f15bd0b
7 changed files with 89 additions and 35 deletions
+6 -2
View File
@@ -164,8 +164,12 @@ func (h *Handler) handleUsers(w http.ResponseWriter, r *http.Request) {
return
}
includeLinks := strings.EqualFold(r.URL.Query().Get("include_links"), "true")
minOct := uint64(0)
if v := r.URL.Query().Get("min_total_octets"); v != "" {
var minOct uint64
if v := r.URL.Query().Get("min_total_megabytes"); v != "" {
if n, err := strconv.ParseFloat(v, 64); err == nil && n > 0 {
minOct = uint64(n * float64(mebibyte))
}
} else if v := r.URL.Query().Get("min_total_octets"); v != "" {
if n, err := strconv.ParseUint(v, 10, 64); err == nil {
minOct = n
}