Skip to content

Commit 32b4483

Browse files
committed
fix: faster queries for DISTINCT values
1 parent d263910 commit 32b4483

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/JobCleaningAgent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def initialize(self):
8787

8888
def _getAllowedJobTypes(self):
8989
"""Get valid jobTypes"""
90-
result = self.jobDB.getDistinctJobAttributes("JobType")
90+
result = self.jobDB._query("SELECT DISTINCT JobType FROM JobsHistorySummary")
9191
if not result["OK"]:
9292
return result
9393
cleanJobTypes = []

src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_JobCleaningAgent.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def jca(mocker):
2626
create=True,
2727
)
2828
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.AgentModule.am_getOption", return_value=mockAM)
29-
mocker.patch(
30-
"DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.getDistinctJobAttributes", side_effect=mockReply
31-
)
29+
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB._query", side_effect=mockReply)
3230
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.selectJobs", side_effect=mockReply)
3331
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.JobDB.__init__", side_effect=mockNone)
3432
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobCleaningAgent.ReqClient", return_value=mockNone)

src/DIRAC/WorkloadManagementSystem/DB/JobDB.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ def getSiteSummary(self):
11971197
waitingList = ['"Submitted"', '"Assigned"', '"Waiting"', '"Matched"']
11981198
waitingString = ",".join(waitingList)
11991199

1200-
result = self.getDistinctJobAttributes("Site")
1200+
result = self._query("SELECT DISTINCT Site FROM JobsHistorySummary")
12011201
if not result["OK"]:
12021202
return result
12031203

0 commit comments

Comments
 (0)