Esempio n. 1
0
    def items(self):
        source = self.context.__parent__.__name__
        source = Eq('stiam.ro.source', source)

        tags = [self.context.__name__]
        tags = AnyOf('stiam.ro.tags', tags)

        query = SearchQuery(source).And(tags)
        brains = query.searchResults(sort_index='stiam.ro.effective',
                                     reverse=True, limit=30)

        duplicate = ""
        index = 0
        for brain in brains:
            if index >= 15:
                raise StopIteration

            title = getattr(brain, "title", "")
            s = SequenceMatcher(lambda x: x == "", title, duplicate)
            if s.ratio() > 0.6:
                continue

            duplicate = title
            index += 1
            yield brain
Esempio n. 2
0
    def __call__(self, **kwargs):
        """ Evolve
        """
        start = datetime.now(bucharest)
        logger.info('Reindex stiam.ro.source started: %s',
                    start.strftime('%Y-%m-%d %H:%M:%S'))

        end = datetime.now(bucharest) + timedelta(3)
        leQuery = Le('stiam.ro.effective', end)
        query = SearchQuery(leQuery)
        brains = query.searchResults()
        logger.info('Reindex %s newsitems', len(brains))

        intids = getUtility(IIntIds)
        sourceIndex = getUtility(interfaces.IIndex, 'stiam.ro.source')

        for index, brain in enumerate(brains):
            server = brain.__parent__.__parent__.__name__
            oid = intids.getId(brain)
            sourceIndex.doIndex(oid, server)

            if index % 500 == 0:
                logger.info('Indexed %s items', index)

        logger.info('Reindex stiam.ro.source done: %s',
                    datetime.now(bucharest) - start)
Esempio n. 3
0
    def items(self):
        tags = self.context.tags
        max_items = self.context.max_items

        anyOfQuery = AnyOf("jokes.tags", tags)
        query = SearchQuery(anyOfQuery)
        brains = query.searchResults(sort_index="jokes.effective", reverse=True, limit=max_items)
        for brain in brains:
            yield brain
def findWorkItemsForItemAndProcessId(item, process_id):
    """ Returns workitems for 'item' 'process_id'."""
    intids = zope.component.getUtility(IIntIds, context=getSite())
    iid = intids.queryId(item, None)
    if not iid: return []  # maybe but we are not able to know
    oidsQuery = AnyOf('workflow-relevant-oids', [iid])
    pidQuery = Eq('workitem-processid', process_id)
    query = SearchQuery(oidsQuery).And(pidQuery)
    return query.searchResults()
Esempio n. 5
0
    def items(self):
        tags = self.context.tags or [self.context.__name__]
        now = datetime.now(bucharest)
        max_items = 500

        logger.info('Query %s start %s', tags, now.strftime('%H:%M:%S'))

        anyOfQuery = AnyOf('stiam.ro.tags', tags)
        query = SearchQuery(anyOfQuery)
        brains = query.searchResults(sort_index='stiam.ro.effective',
                                     reverse=True, limit=max_items)

        logger.info('Query %s end %s', tags, datetime.now(bucharest).strftime('%H:%M:%S'))

        for brain in brains:
            yield brain
Esempio n. 6
0
    def items(self):
        tags = self.context.tags or [self.context.__name__]
        max_items = self.context.max_items * 2

        anyOfQuery = AnyOf('stiam.ro.tags', tags)
        query = SearchQuery(anyOfQuery)
        brains = query.searchResults(sort_index='stiam.ro.effective',
                                     reverse=True, limit=max_items)

        index = 0
        duplicate = ""
        for brain in brains:
            if index >= max_items / 2:
                raise StopIteration

            title = getattr(brain, "title", "")
            s = SequenceMatcher(lambda x: x == "", title, duplicate)
            if s.ratio() > 0.6:
                continue

            duplicate = title
            index += 1
            yield brain
 def values(self):
     principal_id = self.request.principal.id
     contributorQuery = AnyOf('workitem-contributors', (principal_id, ))
     worklistQuery = Eq('worklist-value', 'contributor')
     query = SearchQuery(contributorQuery).And(worklistQuery)
     return query.searchResults()