Ejemplo n.º 1
0
    def get_relvals(self):
        """
        Return summary of RelVals by status and submitted RelVals by CMSSW and batch name
        """
        start_time = time.time()
        collection = Database('relvals').collection
        status_query = [{'$match': {'deleted': {'$ne': True}}},
                        {'$group': {'_id': '$status', 'count': {'$sum': 1}}}]
        by_status = collection.aggregate(status_query)

        batch_query = [{'$match': {'deleted': {'$ne': True}}},
                       {'$match': {'status': 'submitted'}},
                       {'$group': {'_id': {'release': '$cmssw_release', 'batch': '$batch_name'},
                                   'counts': {'$sum': 1}}},
                       {'$group': {"_id": "$_id.release",
                                   "batches": {"$push": {"batch_name": "$_id.batch",
                                                         "count": "$counts"}}}}]
        by_batch = collection.aggregate(batch_query)
        by_status = list(by_status)
        by_batch = list(by_batch)
        by_batch = sorted(by_batch, key=lambda x: x['_id'], reverse=True)
        for release in by_batch:
            release['batches'] = sorted(release['batches'],
                                        key=lambda x: (x['count'], x['batch_name'].lower()),
                                        reverse=True)

        statuses = ['new', 'approved', 'submitting', 'submitted', 'done', 'archived']
        by_status = sorted(by_status, key=lambda x: statuses.index(x['_id']))
        end_time = time.time()
        self.logger.debug('Getting objects info - RelVals, time taken %.2fs',
                          end_time - start_time)
        return by_status, by_batch
Ejemplo n.º 2
0
    def get_tickets(self):
        """
        Return summary of tickets by status
        """
        collection = Database('tickets').collection
        by_status = collection.aggregate([{'$match': {'deleted': {'$ne': True}}},
                                          {'$group': {'_id': '$status',
                                                      'count': {'$sum': 1}}}])

        statuses = ['new', 'done']
        by_status = sorted(list(by_status), key=lambda x: statuses.index(x['_id']))
        self.logger.debug('Tickets - by status %s', len(by_status))
        return by_status
Ejemplo n.º 3
0
    def get_requests(self):
        """
        Return summary of requests by status and submitted requests by processing string
        """
        collection = Database('requests').collection
        by_status = collection.aggregate([{'$match': {'deleted': {'$ne': True}}},
                                          {'$group': {'_id': '$status',
                                                      'count': {'$sum': 1}}}])

        by_processing_string = collection.aggregate([{'$match': {'deleted': {'$ne': True}}},
                                                     {'$match': {'status': 'submitted'}},
                                                     {'$group': {'_id': '$processing_string',
                                                                 'count': {'$sum': 1}}},
                                                     {'$sort': {'count': -1}}])
        statuses = ['new', 'approved', 'submitting', 'submitted', 'done']
        by_status = sorted(list(by_status), key=lambda x: statuses.index(x['_id']))
        by_processing_string = sorted(list(by_processing_string),
                                      key=lambda x: (x['count'], x['_id'].lower()),
                                      reverse=True)
        self.logger.debug('Requests - by status %s, by PS %s',
                          len(by_status),
                          len(by_processing_string))
        return by_status, by_processing_string