feat: add specific information about transfer counts for seperate directions
This commit is contained in:
parent
867cfc55ee
commit
8364218234
1 changed files with 37 additions and 7 deletions
|
|
@ -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)
|
||||
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 {
|
||||
var identifier string
|
||||
var direction string
|
||||
|
||||
switch v := entry.ServiceInformation.(type) {
|
||||
case models.TSTransferInfo:
|
||||
identifier = v.TransferID
|
||||
direction = v.Direction
|
||||
case *models.TSTransferInfo:
|
||||
identifier = v.TransferID
|
||||
direction = v.Direction
|
||||
case models.TJMTransferInfo:
|
||||
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:
|
||||
continue
|
||||
}
|
||||
|
||||
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{
|
||||
"service": service,
|
||||
"start_time": startTime,
|
||||
"end_time": time.Now(),
|
||||
"unique_transfer_identifiers": len(uniqueTransfers),
|
||||
"entry_count": len(entries),
|
||||
"service": service,
|
||||
"start_time": startTime,
|
||||
"end_time": time.Now(),
|
||||
"transfer_counts": map[string]any{
|
||||
"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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue