Skip to content

Commit

Permalink
sort flow level charging record
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchennn committed Dec 15, 2023
1 parent 28b0587 commit 2cb4f1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions backend/WebUI/api_webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,7 @@ func GetChargingRecord(c *gin.Context) {
}

// Flow's Tol, Dl, Ul volume add back to PDU Session Level
// TODO: O(n^2) too slow
for _, du := range ratingGroupDataUsages {
if du.Filter != "" && du.Dnn != "" {
addVolumeToPduLevelDataUsage(ratingGroupDataUsages, du)
Expand All @@ -2076,8 +2077,10 @@ func addVolumeToPduLevelDataUsage(ratingGroupDataUsages map[int64]RatingGroupDat
du.DlVol += flow_du.DlVol
du.UlVol += flow_du.UlVol
ratingGroupDataUsages[rg] = du
break
}
}

if !found {
filter := bson.M{"filter": "", "dnn": "", "snssai": flow_du.Snssai, "ueId": flow_du.Supi}
chargingDataInterface, err := mongoapi.RestfulAPIGetOne(chargingDataColl, filter)
Expand All @@ -2086,8 +2089,7 @@ func addVolumeToPduLevelDataUsage(ratingGroupDataUsages map[int64]RatingGroupDat
}

var chargingData ChargingData
err = json.Unmarshal(mapToByte(chargingDataInterface), &chargingData)
if err != nil {
if json.Unmarshal(mapToByte(chargingDataInterface), &chargingData) != nil {
logger.BillingLog.Error(err)
}

Expand All @@ -2100,6 +2102,7 @@ func addVolumeToPduLevelDataUsage(ratingGroupDataUsages map[int64]RatingGroupDat
if err != nil {
logger.BillingLog.Errorf("Quota convert error, supi: %s, flow: %s", flow_du.Supi, flow_du.Filter)
}

ratingGroupDataUsages[chargingData.RatingGroup] = RatingGroupDataUsage{
Supi: flow_du.Supi,
Filter: "",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/ChargingRecordList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export default function ChargingRecordList() {
/* eslint-disable react/prop-types */
const PerFlowTableView = ({ Supi, Snssai }: Props): React.ReactElement => (
<>
{expand === true ? cr.filter((a) => a!.Filter !== "" && a!.Dnn! !== "" && a!.Supi === Supi && a!.Snssai === Snssai).sort((a,b) => a!.Filter! > b!.Filter! ? 1 : -1).map((row, index) => (
{expand === true ? cr.filter((a) => a!.Filter !== "" && a!.Dnn! !== "" && a!.Supi === Supi && a!.Snssai === Snssai)
.sort((a,b) => a!.Filter! > b!.Filter! ? 1 : -1)
.map((row, index) => (
<TableRow key={index}>
<TableCell>{}</TableCell>
<TableCell>{row.Snssai}</TableCell>
Expand Down

0 comments on commit 2cb4f1c

Please sign in to comment.