Пример #1
0
 def generate_chart_data(self):
     ds = Datastore()
     test_ids = list(ds.get_test_ids(
         bundle=self.name, date=self.bundle.get('date')))
     if test_ids:
         test_ids.reverse()
     provider_names = self.get_provider_names(test_ids)
     datasets = self._create_initial_datasets(provider_names)
     title = None
     units = None
     direction = None
     for test_id in test_ids:
         tests = ds.get({'test_id': test_id['_id']})
         title, units, direction = self._generate_datasets(
             datasets, tests, provider_names)
     if not title:
         return None
     self.calculate_avg_benchmark(datasets)
     title = "{} Benchmark Chart  (Units: {}  Direction: {})".format(
         title.title(), units, direction)
     chart_data = {
         'labels': [x['_id'][-5:] for x in test_ids],
         'datasets': datasets,
         'title': title,
     }
     return json.dumps(chart_data)
Пример #2
0
 def test_get_test_ids_by_bundle(self):
     doc = make_doc()
     doc['bundle_name'] = 'foo'
     update_data(self.ds, doc)
     doc = make_doc(2)
     doc['bundle_name'] = 'foo'
     update_data(self.ds, doc)
     doc = make_doc(3, test_id="44")
     update_data(self.ds, doc)
     ds = Datastore()
     distinct = ds.get_test_ids(bundle='foo')
     distinct = list(distinct)
     expected = [{'date': '1', '_id': '33'}]
     self.assertEqual(distinct, expected)
Пример #3
0
    def test_get_test_ids_by_date(self):
        doc = make_doc()
        doc['bundle_name'] = 'foo'
        doc['date'] = "1"
        update_data(self.ds, doc)

        doc = make_doc(2)
        doc['bundle_name'] = 'foo'
        doc['date'] = "2"
        update_data(self.ds, doc)

        doc = make_doc(3, test_id="44")
        doc['bundle_name'] = 'foo'
        doc['date'] = "3"
        update_data(self.ds, doc)

        ds = Datastore()
        test_ids = ds.get_test_ids(bundle='foo', date="2")
        test_ids = list(test_ids)
        expected = [{'date': '1', '_id': '33'}]
        self.assertEqual(test_ids, expected)
Пример #4
0
def get_recent_test_result(page, limit, bundle=None):
    ds = Datastore()
    skip = limit * (abs(page) - 1)
    test_ids = ds.get_test_ids(bundle=bundle, limit=limit, skip=skip)
    cwr_results = get_results_by_test_ids(test_ids)
    return cwr_results