예제 #1
0
    def get_stats(self, signatures, date):
        def handler(json, data):
            if json["errors"]:
                raise SocorroError()
            del json["hits"]
            for facet in json["facets"].get("signature", {}):
                data.remove(facet["term"])

        date = lmdutils.get_date_ymd(date) - relativedelta(weeks=self.nweeks)
        search_date = SuperSearch.get_search_date(date)
        chunks, size = self.chunkify(signatures)
        base = {
            "date": search_date,
            "signature": "",
            "_result_number": 0,
            "_facets": "signature",
            "_facets_size": size,
        }

        searches = []
        for chunk in chunks:
            params = base.copy()
            params["signature"] = ["=" + x for x in chunk]
            searches.append(
                SuperSearch(
                    params=params,
                    handler=handler,
                    handlerdata=signatures,
                    raise_error=True,
                ))

        for s in searches:
            s.wait()
예제 #2
0
    def get_stats(self, signatures, date):
        def handler(json, data):
            if json['errors']:
                raise SocorroError()
            del json['hits']
            for facet in json['facets'].get('signature', {}):
                data.remove(facet['term'])

        date = lmdutils.get_date_ymd(date) - relativedelta(weeks=self.nweeks)
        search_date = SuperSearch.get_search_date(date)
        chunks, size = self.chunkify(signatures)
        base = {
            'date': search_date,
            'signature': '',
            '_result_number': 0,
            '_facets': 'signature',
            '_facets_size': size,
        }

        searches = []
        for chunk in chunks:
            params = base.copy()
            params['signature'] = ['=' + x for x in chunk]
            searches.append(
                SuperSearch(
                    params=params,
                    handler=handler,
                    handlerdata=signatures,
                    raise_error=True,
                ))

        for s in searches:
            s.wait()