Skip to content

Commit 75da66f

Browse files
committed
fix: much faster query of selectors for web
1 parent b80bd56 commit 75da66f

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

src/DIRAC/WorkloadManagementSystem/DB/JobDB.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __getAttributeNames(self):
107107
def getDistinctJobAttributes(self, attribute, condDict=None, older=None, newer=None, timeStamp="LastUpdateTime"):
108108
"""Get distinct values of the job attribute under specified conditions"""
109109
return self.getDistinctAttributeValues(
110-
"JobsHistorySummary", attribute, condDict=condDict, older=older, newer=newer, timeStamp=timeStamp
110+
"Jobs", attribute, condDict=condDict, older=older, newer=newer, timeStamp=timeStamp
111111
)
112112

113113
#############################################################################

src/DIRAC/WorkloadManagementSystem/Service/JobMonitoringHandler.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ def getJobsAttributes(cls, *args, **kwargs):
5656
types_getApplicationStates = []
5757

5858
@classmethod
59-
def export_getApplicationStates(cls, condDict=None, older=None, newer=None):
59+
def export_getApplicationStates(cls):
6060
"""Return Distinct Values of ApplicationStatus job Attribute in WMS"""
61-
return cls.jobDB.getDistinctJobAttributes("ApplicationStatus", condDict, older, newer)
61+
return cls.jobDB._query("SELECT DISTINCT ApplicationStatus FROM JobsHistorySummary")
6262

6363
##############################################################################
6464
types_getJobTypes = []
6565

6666
@classmethod
67-
def export_getJobTypes(cls, condDict=None, older=None, newer=None):
67+
def export_getJobTypes(cls):
6868
"""Return Distinct Values of JobType job Attribute in WMS"""
69-
return cls.jobDB.getDistinctJobAttributes("JobType", condDict, older, newer)
69+
return cls.jobDB._query("SELECT DISTINCT JobType FROM JobsHistorySummary")
7070

7171
##############################################################################
7272
types_getOwners = []
7373

7474
@classmethod
75-
def export_getOwners(cls, condDict=None, older=None, newer=None):
75+
def export_getOwners(cls):
7676
"""
7777
Return Distinct Values of Owner job Attribute in WMS
7878
"""
79-
return cls.jobDB.getDistinctJobAttributes("Owner", condDict, older, newer)
79+
return cls.jobDB._query("SELECT DISTINCT Owner FROM JobsHistorySummary")
8080

8181
##############################################################################
8282
types_getOwnerGroup = []
@@ -86,47 +86,47 @@ def export_getOwnerGroup(cls):
8686
"""
8787
Return Distinct Values of OwnerGroup from the JobDB
8888
"""
89-
return cls.jobDB.getDistinctJobAttributes("OwnerGroup")
89+
return cls.jobDB._query("SELECT DISTINCT OwnerGroup FROM JobsHistorySummary")
9090

9191
##############################################################################
9292
types_getJobGroups = []
9393

9494
@classmethod
95-
def export_getJobGroups(cls, condDict=None, older=None, cutDate=None):
95+
def export_getJobGroups(cls):
9696
"""
9797
Return Distinct Values of ProductionId job Attribute in WMS
9898
"""
99-
return cls.jobDB.getDistinctJobAttributes("JobGroup", condDict, older, newer=cutDate)
99+
return cls.jobDB._query("SELECT DISTINCT JobGroup FROM JobsHistorySummary")
100100

101101
##############################################################################
102102
types_getSites = []
103103

104104
@classmethod
105-
def export_getSites(cls, condDict=None, older=None, newer=None):
105+
def export_getSites(cls):
106106
"""
107107
Return Distinct Values of Site job Attribute in WMS
108108
"""
109-
return cls.jobDB.getDistinctJobAttributes("Site", condDict, older, newer)
109+
return cls.jobDB._query("SELECT DISTINCT Site FROM JobsHistorySummary")
110110

111111
##############################################################################
112112
types_getStates = []
113113

114114
@classmethod
115-
def export_getStates(cls, condDict=None, older=None, newer=None):
115+
def export_getStates(cls):
116116
"""
117117
Return Distinct Values of Status job Attribute in WMS
118118
"""
119-
return cls.jobDB.getDistinctJobAttributes("Status", condDict, older, newer)
119+
return cls.jobDB._query("SELECT DISTINCT Status FROM JobsHistorySummary")
120120

121121
##############################################################################
122122
types_getMinorStates = []
123123

124124
@classmethod
125-
def export_getMinorStates(cls, condDict=None, older=None, newer=None):
125+
def export_getMinorStates(cls):
126126
"""
127127
Return Distinct Values of Minor Status job Attribute in WMS
128128
"""
129-
return cls.jobDB.getDistinctJobAttributes("MinorStatus", condDict, older, newer)
129+
return cls.jobDB._query("SELECT DISTINCT MinorStatus FROM JobsHistorySummary")
130130

131131
##############################################################################
132132
types_getJobs = []

tests/Integration/WorkloadManagementSystem/Test_Client_WMS.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,16 +422,6 @@ def test_JobStateUpdateAndJobMonitoringMultiple(lfn: str) -> None:
422422
assert res["OK"], res["Message"]
423423
res = jobMonitoringClient.getJobGroups()
424424
assert res["OK"], res["Message"]
425-
resJG_empty = res["Value"]
426-
res = jobMonitoringClient.getJobGroups(None, datetime.datetime.utcnow())
427-
assert res["OK"], res["Message"]
428-
resJG_olderThanNow = res["Value"]
429-
assert resJG_empty == resJG_olderThanNow
430-
res = jobMonitoringClient.getJobGroups(None, datetime.datetime.utcnow() - datetime.timedelta(days=365))
431-
assert res["OK"], res["Message"]
432-
resJG_olderThanOneYear = res["Value"]
433-
assert set(resJG_olderThanOneYear).issubset(set(resJG_olderThanNow))
434-
435425
res = jobMonitoringClient.getStates()
436426
assert res["OK"], res["Message"]
437427
res = jobMonitoringClient.getMinorStates()

0 commit comments

Comments
 (0)