Skip to content

Commit

Permalink
fix: make use of updatemany
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Nov 18, 2024
1 parent 093fc5a commit a765366
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/DIRAC/Core/Utilities/MySQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ def _updatemany(self, cmd, data, *, conn=None, debug=True):

return retDict


def _transaction(self, cmdList, conn=None):
"""dummy transaction support
Expand Down
24 changes: 9 additions & 15 deletions src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,35 +96,29 @@ def _get_date(date):
if isinstance(minorStatus, str):
minorStatus = [minorStatus] * len(jobID)
if isinstance(applicationStatus, str):
applicationStatus = [applicationStatus] * len(jobID)
applicationStatus = [applicationStatus[:255]] * len(jobID)
if isinstance(_date, datetime.datetime):
_date = [_date] * len(jobID)

for jid, stat, mstat, appstat, dt in zip(jobID, status, minorStatus, applicationStatus, _date):
epocs = []
for dt in _date:
epoc = dt.replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER
cmd += "(%d,'%s','%s','%s','%s',%f,'%s')," % (
int(jid),
stat,
mstat,
appstat[:255],
str(dt),
epoc,
source[:32],
)
cmd = cmd[:-1]
epocs.append(epoc)
cmd = cmd + "(%s, %s, %s, %s, %s, %s, %s)"
data = list(zip(jobID, status, minorStatus, applicationStatus, _date, epocs, [source[:32]] * len(jobID)))
return self._updatemany(cmd, data)
else: # else make a single insert
epoc = _date.replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER
cmd = cmd + "(%d,'%s','%s','%s','%s',%f,'%s')" % (
int(jobID),
status,
minorStatus,
applicationStatus[:255],
applicationStatus,
str(_date),
epoc,
source[:32],
)

return self._update(cmd)
return self._update(cmd)

#############################################################################
def getJobLoggingInfo(self, jobID):
Expand Down

0 comments on commit a765366

Please sign in to comment.