def get(self): context = self._build_common_context() context['sites'] = [{ 'server': site[1], 'name': site[2], 'url': site[3], } for site in DATABASE.aggregate_list_sites()] self._render('agg_index.html', context)
def get(self, item_id): item_id = int(item_id) item_properties = DATABASE.items_get_properties(language=self._get_language(), item_id=item_id) if item_properties is None: raise tornado.web.HTTPError(404, reason='"{item_id}" is not a known item'.format( item_id=item_id, )) (item_name, xivdb_id, lodestone_id, hq) = item_properties context = self._build_common_context() quality_counterpart = None quality_counterpart_id = DATABASE.items_get_hq_variant_id(xivdb_id, not hq) if quality_counterpart_id is not None: quality_counterpart = DATABASE.items_get_latest_by_id(quality_counterpart_id) sites = dict((site[0], { 'server': site[1], 'url': site[3], 'colour': site[5], }) for site in DATABASE.aggregate_list_sites()) prices = collections.defaultdict(list) #Data-interpolation happens in the renderer, to avoid wasting memory unnecessarily for (site_id, timestamp, value, quantity) in DATABASE.aggregate_get_prices(xivdb_id, hq): prices[site_id].append((timestamp, value, quantity)) for site_id in prices: prices[site_id] = normalise_price_data( prices[site_id], interval=(CONFIG['aggregation']['graphing']['interval_hours'] * TIME_HOUR), align=True, start_time=(context['rendering']['time_current'] - (CONFIG['aggregation']['graphing']['days'] * TIME_DAY)), end_time=context['rendering']['time_current'], ) context['rendering']['title'] = item_name context.update({ 'language': self._get_language(), 'item_name': item_name, 'item_hq': hq, 'item_id': item_id, 'xivdb_id': xivdb_id, 'lodestone_id': lodestone_id, 'quality_counterpart': quality_counterpart, 'sites': sites, 'prices': prices, }) self._render('agg_item.html', context, html_headers=( #TODO: make this local static content once it's been validated '<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.min.js"></script>', ))
def get(self, item_id): item_id = int(item_id) item_properties = DATABASE.items_get_properties( language=self._get_language(), item_id=item_id) if item_properties is None: raise tornado.web.HTTPError( 404, reason='"{item_id}" is not a known item'.format( item_id=item_id, )) (item_name, xivdb_id, lodestone_id, hq) = item_properties context = self._build_common_context() quality_counterpart = None quality_counterpart_id = DATABASE.items_get_hq_variant_id( xivdb_id, not hq) if quality_counterpart_id is not None: quality_counterpart = DATABASE.items_get_latest_by_id( quality_counterpart_id) sites = dict((site[0], { 'server': site[1], 'url': site[3], 'colour': site[5], }) for site in DATABASE.aggregate_list_sites()) prices = collections.defaultdict(list) #Data-interpolation happens in the renderer, to avoid wasting memory unnecessarily for (site_id, timestamp, value, quantity) in DATABASE.aggregate_get_prices(xivdb_id, hq): prices[site_id].append((timestamp, value, quantity)) for site_id in prices: prices[site_id] = normalise_price_data( prices[site_id], interval=(CONFIG['aggregation']['graphing']['interval_hours'] * TIME_HOUR), align=True, start_time=( context['rendering']['time_current'] - (CONFIG['aggregation']['graphing']['days'] * TIME_DAY)), end_time=context['rendering']['time_current'], ) context['rendering']['title'] = item_name context.update({ 'language': self._get_language(), 'item_name': item_name, 'item_hq': hq, 'item_id': item_id, 'xivdb_id': xivdb_id, 'lodestone_id': lodestone_id, 'quality_counterpart': quality_counterpart, 'sites': sites, 'prices': prices, }) self._render( 'agg_item.html', context, html_headers=( #TODO: make this local static content once it's been validated '<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.min.js"></script>', ))