fix: upf kpi for tenant

This commit is contained in:
2024-06-25 15:35:39 +08:00
parent 671f76f52e
commit 0faeb1e0ca
2 changed files with 12 additions and 4 deletions

View File

@@ -76,7 +76,8 @@ type KpiData struct {
Granularity int8 `json:"granularity" xorm:"granularity"`
KPIValues []KPIVal `json:"kpiValues" xorm:"json 'kpi_values'"`
//CreatedAt int64 `json:"createdAt" xorm:"created 'created_at'"`
CreatedAt int64 `json:"createdAt" xorm:"'created_at'"`
CreatedAt int64 `json:"createdAt" xorm:"'created_at'"`
TenantName string `json:"tenantName" xorm:"tenant_name"`
}
type KPIVal struct {
KPIID string `json:"kpi_id" xorm:"kpi_id"`
@@ -257,6 +258,9 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
kpiData.KPIValues = append(kpiData.KPIValues, *kpiVal)
}
// set tenant_name if exist
where := fmt.Sprintf("status='1' and tenant_id=(select parent_id from sys_tenant where status='1' and tenancy_type='UPF' and tenancy_key='%s')", kpiData.RmUid)
kpiData.TenantName, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_name", where)
// insert kpi_report table, no session
tableName := "kpi_report_" + strings.ToLower(kpiReport.Task.NE.NeType)
affected, err := xEngine.Table(tableName).Insert(kpiData)