def cached_data_list(entity, periods, indicator): return [ get_cached_data('section2-arrivals', entity=entity, period=period, indicator=indicator) for period in periods ]
def dashboard(request, entity_uuid=None, indicator_slug=None, period_str=None, *args, **kwargs): context = {'page': 'dashboard'} # entity context.update(process_entity_filter(request, entity_uuid)) root = context['entity'] if context['entity'] else Entity.get_root() context.update(process_period_filter(request, period_str, 'period')) if context['period'] is None: context['period'] = MonthPeriod.current().previous() all_indicators = Indicator.get_all_sorted() # Indicator.get_all_routine() indicator = Indicator.get_or_none(indicator_slug) context.update({ 'root': root, 'completeness': OrderedDict([ (child, get_cached_data('completeness', dps=child, period=context['period'], indicator=indicator)) for child in root.get_children() ]), 'indicators': all_indicators, 'indicator': indicator, 'lineage': [Entity.PROVINCE] }) # totals context.update({ 'mean_completeness': numpy.mean( [e['completeness'] for e in context['completeness'].values()]), 'mean_promptness': numpy.mean( [e['promptness'] for e in context['completeness'].values()]), }) # evolution of pw_anc_receiving_sp3 pwsp3 = get_timed_records(Indicator.get_by_number(59), root, context['all_periods']) perioda = context['all_periods'][0] periodb = context['all_periods'][-1] context.update({ 'sp3_title': "{num} : {name} entre {pa} et {pb}" .format(num=pwsp3['indicator'].number, name=pwsp3['indicator'].name, pa=perioda.strid, pb=periodb.strid), 'sp3_fname': "palu-evol-sp3-_{pa}_{pb}" .format(pa=perioda.strid, pb=periodb.strid), 'sp3_categories': [p[1].name for p in pwsp3['periods']], 'sp3_series': [{'name': pwsp3['indicator'].name, 'data': pwsp3['points']} ], }) return render(request, kwargs.get('template_name', 'dashboard.html'), context)
def cached_data_list(entity, periods, indicator): return [get_cached_data('section2-arrivals', entity=entity, period=period, indicator=indicator) for period in periods]
def view(request, entity_uuid=None, perioda_str=None, periodb_str=None, indicator_slug=None, **kwargs): context = {'page': 'analysis_section2'} # handling entity context.update(process_entity_filter(request, entity_uuid)) # handling periods # context.update(process_period_filter(request, period_str, 'period')) context.update(process_period_filter(request, perioda_str, 'perioda')) context.update(process_period_filter(request, periodb_str, 'periodb')) if context['perioda'] > context['periodb']: context['perioda'], context['periodb'] = \ context['periodb'], context['perioda'] periods = MonthPeriod.all_from(context['perioda'], context['periodb']) context.update({'selected_periods': periods}) def cached_data_list(entity, periods, indicator): return [get_cached_data('section2-arrivals', entity=entity, period=period, indicator=indicator) for period in periods] context.update({ 'section': text_type(SECTION_ID), 'section_name': SECTION_NAME, 'arrivals': OrderedDict( [(indicator, cached_data_list(context['entity'], periods, indicator)) for indicator in Indicator.get_all_routine()]) }) # evolution graph cp = { 'periods': [period.to_tuple() for period in periods], 'points': [get_cached_data('section2-points', entity=context['entity'], period=period) for period in periods] } perioda = periods[0] periodb = periods[-1] context.update({ 'cp_title': "Évolution de la complétude à {name} entre {pa} et {pb}" .format(name=context['entity'].short_name, pa=perioda.strid, pb=periodb.strid), 'cp_fname': "completeness-_{pa}_{pb}" .format(pa=perioda.strid, pb=periodb.strid), 'cp_categories': [p[1].name for p in cp['periods']], 'cp_series': [{'name': "Complétude", 'data': cp['points']}] }) # absolute URI for links context.update({ 'baseurl': request.build_absolute_uri(), 'lineage': [Entity.PROVINCE]}) return render(request, kwargs.get('template_name', 'analysis_section2.html'), context)
def view(request, entity_uuid=None, perioda_str=None, periodb_str=None, indicator_slug=None, **kwargs): context = {'page': 'analysis_section2'} # handling entity context.update(process_entity_filter(request, entity_uuid)) # handling periods # context.update(process_period_filter(request, period_str, 'period')) context.update(process_period_filter(request, perioda_str, 'perioda')) context.update(process_period_filter(request, periodb_str, 'periodb')) if context['perioda'] > context['periodb']: context['perioda'], context['periodb'] = \ context['periodb'], context['perioda'] periods = MonthPeriod.all_from(context['perioda'], context['periodb']) context.update({'selected_periods': periods}) def cached_data_list(entity, periods, indicator): return [ get_cached_data('section2-arrivals', entity=entity, period=period, indicator=indicator) for period in periods ] context.update({ 'section': text_type(SECTION_ID), 'section_name': SECTION_NAME, 'arrivals': OrderedDict([(indicator, cached_data_list(context['entity'], periods, indicator)) for indicator in Indicator.get_all_routine()]) }) # evolution graph cp = { 'periods': [period.to_tuple() for period in periods], 'points': [ get_cached_data('section2-points', entity=context['entity'], period=period) for period in periods ] } perioda = periods[0] periodb = periods[-1] context.update({ 'cp_title': "Évolution de la complétude à {name} entre {pa} et {pb}".format( name=context['entity'].short_name, pa=perioda.strid, pb=periodb.strid), 'cp_fname': "completeness-_{pa}_{pb}".format(pa=perioda.strid, pb=periodb.strid), 'cp_categories': [p[1].name for p in cp['periods']], 'cp_series': [{ 'name': "Complétude", 'data': cp['points'] }] }) # absolute URI for links context.update({ 'baseurl': request.build_absolute_uri(), 'lineage': [Entity.PROVINCE] }) return render(request, kwargs.get('template_name', 'analysis_section2.html'), context)
def dashboard(request, entity_uuid=None, indicator_slug=None, period_str=None, *args, **kwargs): context = {'page': 'dashboard'} # entity context.update(process_entity_filter(request, entity_uuid)) root = context['entity'] if context['entity'] else Entity.get_root() context.update(process_period_filter(request, period_str, 'period')) if context['period'] is None: context['period'] = MonthPeriod.current().previous() all_indicators = Indicator.get_all_sorted() # Indicator.get_all_routine() indicator = Indicator.get_or_none(indicator_slug) context.update({ 'root': root, 'completeness': OrderedDict([(child, get_cached_data('completeness', dps=child, period=context['period'], indicator=indicator)) for child in root.get_children()]), 'indicators': all_indicators, 'indicator': indicator, 'lineage': [Entity.PROVINCE] }) # totals context.update({ 'mean_completeness': numpy.mean( [e['completeness'] for e in context['completeness'].values()]), 'mean_promptness': numpy.mean([e['promptness'] for e in context['completeness'].values()]), }) # evolution of pw_anc_receiving_sp3 pwsp3 = get_timed_records(Indicator.get_by_number(59), root, context['all_periods']) perioda = context['all_periods'][0] periodb = context['all_periods'][-1] context.update({ 'sp3_title': "{num} : {name} entre {pa} et {pb}".format( num=pwsp3['indicator'].number, name=pwsp3['indicator'].name, pa=perioda.strid, pb=periodb.strid), 'sp3_fname': "palu-evol-sp3-_{pa}_{pb}".format(pa=perioda.strid, pb=periodb.strid), 'sp3_categories': [p[1].name for p in pwsp3['periods']], 'sp3_series': [{ 'name': pwsp3['indicator'].name, 'data': pwsp3['points'] }], }) return render(request, kwargs.get('template_name', 'dashboard.html'), context)