feat: add specific information about transfer counts for seperate directions

This commit is contained in:
Patryk Hegenberg 2025-09-25 12:28:01 +02:00
parent 867cfc55ee
commit 8364218234

View file

@ -265,30 +265,60 @@ func (ws *WebServiceV2) handleServiceStats(w http.ResponseWriter, r *http.Reques
http.Error(w, fmt.Sprintf("Query error: %v", err), http.StatusInternalServerError) http.Error(w, fmt.Sprintf("Query error: %v", err), http.StatusInternalServerError)
return return
} }
uniqueTransfersTotal := make(map[string]struct{})
uniqueTransfersIncoming := make(map[string]struct{})
uniqueTransfersOutgoing := make(map[string]struct{})
uniqueTransfersNil := make(map[string]struct{})
uniqueTransfers := make(map[string]struct{})
for _, entry := range entries { for _, entry := range entries {
var identifier string var identifier string
var direction string
switch v := entry.ServiceInformation.(type) { switch v := entry.ServiceInformation.(type) {
case models.TSTransferInfo: case models.TSTransferInfo:
identifier = v.TransferID identifier = v.TransferID
direction = v.Direction
case *models.TSTransferInfo:
identifier = v.TransferID
direction = v.Direction
case models.TJMTransferInfo: case models.TJMTransferInfo:
identifier = v.TransferID identifier = v.TransferID
direction = v.Direction
case *models.TJMTransferInfo:
identifier = v.TransferID
direction = v.Direction
case map[string]any:
identifier, _ = v["transfer_identifier"].(string)
direction, _ = v["direction"].(string)
default: default:
continue continue
} }
if identifier != "" { if identifier != "" {
uniqueTransfers[identifier] = struct{}{} uniqueTransfersTotal[identifier] = struct{}{}
switch strings.ToLower(direction) {
case "incoming":
uniqueTransfersIncoming[identifier] = struct{}{}
case "outgoing":
uniqueTransfersOutgoing[identifier] = struct{}{}
default:
uniqueTransfersNil[identifier] = struct{}{}
}
} }
} }
stats := map[string]any{ stats := map[string]any{
"service": service, "service": service,
"start_time": startTime, "start_time": startTime,
"end_time": time.Now(), "end_time": time.Now(),
"unique_transfer_identifiers": len(uniqueTransfers), "transfer_counts": map[string]any{
"entry_count": len(entries), "total": len(uniqueTransfersTotal),
"incoming": len(uniqueTransfersIncoming),
"outgoing": len(uniqueTransfersOutgoing),
"nil_or_unknown_direction": len(uniqueTransfersNil),
},
"entry_count": len(entries),
} }
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")