@@ -31,8 +31,8 @@ class StatesAccountingAgent(AgentModule):
31
31
__summaryKeyFieldsMapping = [
32
32
"Status" ,
33
33
"Site" ,
34
- "User " ,
35
- "UserGroup " ,
34
+ "Owner " ,
35
+ "OwnerGroup " ,
36
36
"JobGroup" ,
37
37
"VO" ,
38
38
"JobType" ,
@@ -41,7 +41,7 @@ class StatesAccountingAgent(AgentModule):
41
41
]
42
42
__summaryDefinedFields = [("ApplicationStatus" , "unset" ), ("MinorStatus" , "unset" )]
43
43
__summaryValueFieldsMapping = ["Jobs" , "Reschedules" ]
44
- __renameFieldsMapping = {"JobType" : "JobSplitType" }
44
+ __renameFieldsMapping = {"Owner" : "User" , "OwnerGroup" : "UserGroup" , " JobType" : "JobSplitType" }
45
45
46
46
# PilotsHistory fields
47
47
__pilotsMapping = ["GridSite" , "ComputingElement" , "GridType" , "Status" , "VO" , "NumOfPilots" ]
@@ -95,7 +95,7 @@ def execute(self):
95
95
f"{ result ['Message' ]} : won't commit PilotsHistory at this cycle" ,
96
96
)
97
97
98
- values = result ["Value" ][ 1 ]
98
+ values = result ["Value" ]
99
99
for record in values :
100
100
rD = {}
101
101
for iP , _ in enumerate (self .__pilotsMapping ):
@@ -111,21 +111,21 @@ def execute(self):
111
111
112
112
# WMSHistory to Monitoring or Accounting
113
113
self .log .info (f"Committing WMSHistory to { 'and ' .join (self .jobMonitoringOption )} backend" )
114
- result = JobDB ()._query ("SELECT * FROM JobsHistorySummary" )
114
+ result = JobDB ()._query (
115
+ f"SELECT { self .__summaryKeyFieldsMapping } FROM JobsHistorySummary ORDER BY { ',' .join (self .__summaryKeyFieldsMapping )} "
116
+ )
115
117
if not result ["OK" ]:
116
118
self .log .error ("Can't get the JobDB summary" , f"{ result ['Message' ]} : won't commit WMSHistory at this cycle" )
117
119
return S_ERROR ()
118
120
119
- values = result ["Value" ][1 ]
120
-
121
+ values = result ["Value" ]
121
122
now = datetime .datetime .utcnow ()
122
123
self .log .info ("Start sending WMSHistory records" )
123
124
for record in values :
124
125
rD = {}
125
126
for fV in self .__summaryDefinedFields :
126
127
rD [fV [0 ]] = fV [1 ]
127
- for iP , _ in enumerate (self .__summaryKeyFieldsMapping ):
128
- fieldName = self .__summaryKeyFieldsMapping [iP ]
128
+ for iP , fieldName in enumerate (self .__summaryKeyFieldsMapping ):
129
129
rD [self .__renameFieldsMapping .get (fieldName , fieldName )] = record [iP ]
130
130
record = record [len (self .__summaryKeyFieldsMapping ) :]
131
131
for iP , _ in enumerate (self .__summaryValueFieldsMapping ):
0 commit comments