Esempio n. 1
0
 def count(cls,
           name=None,
           last_build_res=None,
           DFG=None,
           release=None,
           squad=None,
           component=None,
           query_str=None):
     """Returns number of jobs based on passed arguments."""
     query = {}
     if name:
         regex = re.compile(name, re.IGNORECASE)
         query['name'] = regex
     if last_build_res:
         query['last_build.status'] = last_build_res
     if DFG:
         query['DFG'] = DFG
     if squad:
         query['squad'] = squad
     if component:
         query['component'] = component
     if release:
         query['release'] = release
     jobs = Database.find(collection='jobs', query=query)
     return jobs.count()
Esempio n. 2
0
 def find(cls,
          name=None,
          exact_match=False,
          last_build_result=None,
          projection=None,
          build_number=None,
          query_str=None,
          **kwargs):
     """Returns find query."""
     query = {}
     if name and not exact_match:
         regex = re.compile(name, re.IGNORECASE)
         query['name'] = regex
     elif name:
         query['name'] = name
     if build_number:
         query['builds.number'] = build_number
     if last_build_result:
         query['last_build.result'] = last_build_result
     for k, v in kwargs.items():
         query[k] = v
     if query_str:
         query = query_str
     jobs = list(
         Database.find(collection="jobs",
                       query=query,
                       projection=projection))
     return jobs
Esempio n. 3
0
 def count(cls, squads=False):
     """Returns the count of DFGs documents."""
     query = {}
     if squads:
         return len(cls.get_all_squads())
     else:
         DFGs = Database.find(collection='DFGs', query=query)
     return DFGs.count()
Esempio n. 4
0
 def get_all_DFGs_based_on_jobs(cls):
     """Returns a list of all DFGs based on job model where it cuts the
     DFG name from the job name and makes sure the set is unique.
     """
     DFGs = []
     regex = re.compile('DFG-', re.IGNORECASE)
     DFG_jobs = Database.find(collection='jobs', query={'name': regex})
     for job in DFG_jobs:
         jname = job['name']
         DFG_name = jname.split('-')[1] if '-' in jname else jname
         if DFG_name not in DFGs:
             DFGs.append(DFG_name)
     return DFGs
Esempio n. 5
0
 def find(cls,
          name=None,
          exact_match=False,
          last_build_result=None,
          projection=None,
          build_number=None,
          query_str=None,
          **kwargs):
     """Returns find query."""
     query = {}
     if build_number:
         query['builds.number'] = build_number
     if last_build_result:
         query['last_build.result'] = last_build_result
     for k, v in kwargs.items():
         query[k] = v
     if name:
         regex = re.compile(name, re.IGNORECASE)
         query['name'] = regex
     if query_str and "last_added" not in query_str:
         if "name" in query_str:
             regex = re.compile(query_str['name'], re.IGNORECASE)
             query_str['name'] = regex
         query = query_str
     if query_str and "last_added" in query_str:
         jobs = list(
             Database.find(collection="jobs",
                           query={
                               'last_build.status': 'None',
                               'release': "15"
                           },
                           projection=projection).limit(10))
     else:
         jobs = list(
             Database.find(collection="jobs",
                           query=query,
                           projection=projection))
     return jobs
Esempio n. 6
0
 def count(cls):
     """Returns the count of builds documents."""
     query = {}
     builds = Database.find(collection='builds', query=query)
     return builds.count()
Esempio n. 7
0
 def find(cls):
     """Returns find query."""
     query = {}
     tests = Database.find(collection=cls.COLLECTION, query=query)
     return tests
Esempio n. 8
0
 def find(cls):
     """Returns find query."""
     query = {}
     DFGs = Database.find(collection="DFGs", query=query)
     return DFGs
Esempio n. 9
0
 def find(cls):
     """Returns find query."""
     query = {}
     builds = Database.find(collection="builds", query=query)
     return builds