scout/adapter/mongo/event.py
def events(self, institute, case=None, variant_id=None, level=None,
               comments=False, panel=None):
        """Fetch events from the database.

          Args:
            institute (dict): A institute
            case (dict): A case
            variant_id (str, optional): global variant id
            level (str, optional): restrict comments to 'specific' or 'global'
            comments (bool, optional): restrict events to include only comments
            panel (str): A panel name

          Returns:
              pymongo.Cursor: Query result
        """

        query = {}

        if variant_id:
            if comments:
                # If it's comment-related event collect global and variant-specific comment events
                LOG.debug("Fetching all comments for institute {0} case {1} variant {2}".format(
                          institute['_id'], case['_id'], variant_id))
                query = {
                    '$or': [
                        {
                            'category' : 'variant',
                            'variant_id' : variant_id,
                            'verb' : 'comment',
                            'level' : 'global'
                        },
                        {
                            'category' : 'variant',
                            'variant_id' : variant_id,
                            'institute' : institute['_id'],
                            'case' : case['_id'],
                            'verb' : 'comment',
                            'level' : 'specific'
                        }
                    ]
                }
            else: # Collect other variant-specific events which are not comments
                query['institute'] = institute['_id']
                query['category'] = 'variant'
                query['variant_id'] = variant_id
                query['case'] = case['_id']
        else:
            query['institute'] = institute['_id']
            if panel:
                query['panel'] = panel
            # If no variant_id or panel we know that it is a case level comment
            else:
                query['category'] = 'case'

                if case:
                    query['case'] = case['_id']

                if comments:
                    query['verb'] = 'comment'


        return self.event_collection.find(query).sort('created_at', pymongo.DESCENDING)
def events(self, institute, case=None, variant_id=None, level=None,
               comments=False, panel=None):
        query = {}

        if variant_id:
            if comments:
                # If it's comment-related event collect global and variant-specific comment events
                LOG.debug("Fetching all comments for institute {0} case {1} variant {2}".format(
                          institute['_id'], case['_id'], variant_id))
                query = {
                    '$or': [
                        {
                            'category' : 'variant',
                            'variant_id' : variant_id,
                            'verb' : 'comment',
                            'level' : 'global'
                        },
                        {
                            'category' : 'variant',
                            'variant_id' : variant_id,
                            'institute' : institute['_id'],
                            'case' : case['_id'],
                            'verb' : 'comment',
                            'level' : 'specific'
                        }
                    ]
                }
            else: # Collect other variant-specific events which are not comments
                query['institute'] = institute['_id']
                query['category'] = 'variant'
                query['variant_id'] = variant_id
                query['case'] = case['_id']
        else:
            query['institute'] = institute['_id']
            if panel:
                query['panel'] = panel
            # If no variant_id or panel we know that it is a case level comment
            else:
                query['category'] = 'case'

                if case:
                    query['case'] = case['_id']

                if comments:
                    query['verb'] = 'comment'


        return self.event_collection.find(query).sort('created_at', pymongo.DESCENDING)
def events ( self , institute , case = None , variant_id = None , level = None , comments = False , panel = None ) : query = { } if variant_id : if comments : # If it's comment-related event collect global and variant-specific comment events LOG . debug ( "Fetching all comments for institute {0} case {1} variant {2}" . format ( institute [ '_id' ] , case [ '_id' ] , variant_id ) ) query = { '$or' : [ { 'category' : 'variant' , 'variant_id' : variant_id , 'verb' : 'comment' , 'level' : 'global' } , { 'category' : 'variant' , 'variant_id' : variant_id , 'institute' : institute [ '_id' ] , 'case' : case [ '_id' ] , 'verb' : 'comment' , 'level' : 'specific' } ] } else : # Collect other variant-specific events which are not comments query [ 'institute' ] = institute [ '_id' ] query [ 'category' ] = 'variant' query [ 'variant_id' ] = variant_id query [ 'case' ] = case [ '_id' ] else : query [ 'institute' ] = institute [ '_id' ] if panel : query [ 'panel' ] = panel # If no variant_id or panel we know that it is a case level comment else : query [ 'category' ] = 'case' if case : query [ 'case' ] = case [ '_id' ] if comments : query [ 'verb' ] = 'comment' return self . event_collection . find ( query ) . sort ( 'created_at' , pymongo . DESCENDING )
Fetch events from the database.

          Args:
            institute (dict): A institute
            case (dict): A case
            variant_id (str, optional): global variant id
            level (str, optional): restrict comments to 'specific' or 'global'
            comments (bool, optional): restrict events to include only comments
            panel (str): A panel name

          Returns:
              pymongo.Cursor: Query result
Fetch events from the database .