Skip to content

Commit

Permalink
feat: Support aggregating by date in MySQL.getCounters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Aug 29, 2024
1 parent cfe7863 commit 5844a5f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/DIRAC/Core/Utilities/MySQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _checkFields(inFields, inValues):
return S_OK()


def _quotedList(fieldList=None):
def _quotedList(fieldList=None, allowDate=False):
"""
Quote a list of MySQL Field Names with "`"
Return a comma separated list of quoted Field Names
Expand All @@ -192,7 +192,10 @@ def _quotedList(fieldList=None):
quotedFields = []
try:
for field in fieldList:
quotedFields.append(f"`{field.replace('`', '')}`")
if allowDate and field.startswith("date(") and field.endswith(")"):
quotedFields.append(f"date(`{field.replace('`', '')}`)")
else:
quotedFields.append(f"`{field.replace('`', '')}`")
except Exception:
return None
if not quotedFields:
Expand Down Expand Up @@ -1115,7 +1118,7 @@ def getCounters(
# self.log.debug('getCounters:', error)
return S_ERROR(DErrno.EMYSQL, error)

attrNames = _quotedList(attrList)
attrNames = _quotedList(attrList, allowDate=True)
if attrNames is None:
error = "Invalid updateFields argument"
# self.log.debug('getCounters:', error)
Expand Down

0 comments on commit 5844a5f

Please sign in to comment.