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()
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()
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()
def get_signatures(): def handler(json, data): for i in json['facets']['signature']: data.append(i['term']) if not os.path.exists('tests/data/socorro/test_date.json'): date = lmdutils.get_date_ymd('today') dumpjson('tests/data/socorro/test_date.json', date.strftime('%Y-%m-%d')) else: with open('tests/data/socorro/test_date.json', 'r') as In: date = lmdutils.get_date_ymd(json.load(In)) few_days_ago = date - relativedelta(days=3) search_date = _SuperSearch.get_search_date(few_days_ago) params = { 'date': search_date, '_results_number': 0, '_facets': 'signature', '_facets_size': 100, } data = {'Firefox': [], 'FennecAndroid': []} queries = [] for prod, hdata in data.items(): pparams = params.copy() pparams['product'] = prod queries.append( Query( MySuperSearch.URL, params=pparams, handler=handler, handlerdata=hdata, ) ) MySuperSearch(queries=queries).wait() return data
def get_search_date(start, end=None): return _SuperSearch.get_search_date(start, end=end)