Skip to content

Commit

Permalink
Add rse=ALL_DOCS.
Browse files Browse the repository at this point in the history
Add type check of kwargs[rse].
  • Loading branch information
todor-ivanov committed Mar 7, 2022
1 parent 6a78d41 commit 9b4abed
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/python/WMCore/MicroService/MSUnmerged/MSUnmerged.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,21 +822,37 @@ def getStatsFromMongoDB(self, detail=False, **kwargs):
data = {}
if kwargs.get('rse'):
data["query"] = 'rse=%s&detail=%s' % (kwargs['rse'], detail)
mongoProjection = {"_id": False,
"name": True,
"pfnPrefix": True,
"rucioConMonStatus": True,
"isClean": True,
"timestamps": True,
"counters": True}
if detail:
mongoProjection["dirs"] = True

rseList = kwargs['rse'] if isinstance(kwargs['rse'], list) else [kwargs['rse']]
data["rseData"] = []
for rseName in rseList:
mongoFilter = {'name': rseName}
data["rseData"].append(self.msUnmergedColl.find_one(mongoFilter, projection=mongoProjection))
allDocs = (kwargs['rse'].lower() == "all_docs") if isinstance(kwargs['rse'], str) else False

if allDocs:
mongoProjection = {
"_id": False,
"name": True,
"isClean": True,
"counters": {
"gfalErrors": True,
"dirsToDelete": True,
"dirsDeletedSuccess": True,
"dirsDeletedFail": True}}
mongoFilter = {}
data["rseData"] = list(self.msUnmergedColl.find(mongoFilter, projection=mongoProjection))
else:
mongoProjection = {
"_id": False,
"name": True,
"isClean": True,
"pfnPrefix": True,
"rucioConMonStatus": True,
"timestamps": True,
"counters": True}
if detail:
mongoProjection["dirs"] = True

rseList = kwargs['rse'] if isinstance(kwargs['rse'], list) else [kwargs['rse']]
data["rseData"] = []
for rseName in rseList:
mongoFilter = {'name': rseName}
data["rseData"].append(self.msUnmergedColl.find_one(mongoFilter, projection=mongoProjection))
return data

# @profile
Expand Down

0 comments on commit 9b4abed

Please sign in to comment.