Exemple #1
0
    def columns(self):
        cols = [
            self.location_column,
            dynamic_date_aggregation(DatabaseColumn(
                "Incidents of Abuse",
                SumColumn('incidents_total',
                          filters=self.filters +
                          [BETWEEN('date_reported', 'startdate', 'enddate')] +
                          self.filters),
            ),
                                     date_column='date_reported'),
            dynamic_date_aggregation(DatabaseColumn(
                "Outreach activities",
                SumColumn('outreach_total',
                          filters=self.filters +
                          [BETWEEN('date', 'startdate', 'enddate')])),
                                     date_column='date'),
            dynamic_date_aggregation(DatabaseColumn(
                "IGA Reports",
                SumColumn('iga_total',
                          filters=self.filters +
                          [BETWEEN('start_date', 'startdate', 'enddate')])),
                                     date_column='start_date'),
            AggregateColumn("Total", self.sum, [
                AliasColumn('incidents_total'),
                AliasColumn('outreach_total')
            ]),
        ]

        cols[0] = self.date_column
        return cols
Exemple #2
0
 def columns(self):
     return [
         self.location_column,
         DatabaseColumn("Incidents of Abuse", SumColumn('incidents_total')),
         DatabaseColumn("Outreach activities", SumColumn('outreach_total')),
         DatabaseColumn("IGA Reports", SumColumn('iga_total')),
         AggregateColumn(
             "Total", self.sum,
             [AliasColumn('incidents_total'), AliasColumn('outreach_total')]),
     ]
    def columns(self):
        def format_pnc_count(*args):
            return sum([1 if arg == 'yes' else 0 for arg in args])

        return [
            DatabaseColumn("PP 1", SimpleColumn('pp_1_done', alias='pp_1_done')),
            DatabaseColumn("PP 2", SimpleColumn('pp_2_done', alias='pp_2_done')),
            DatabaseColumn("PP 3", SimpleColumn('pp_3_done', alias='pp_3_done')),
            DatabaseColumn("PP 4", SimpleColumn('pp_4_done', alias='pp_4_done')),
            AggregateColumn('PNC Count', format_pnc_count,
                            [AliasColumn('pp_1_done'), AliasColumn('pp_2_done'), AliasColumn('pp_3_done'),
                             AliasColumn('pp_4_done')])]
    def columns(self):
        def percent(x):
            return {'sort_key': x, 'html': '%.2f%%' % (x * 100)}

        return [
            DatabaseColumn('site_id', SimpleColumn('site_id')),
            DatabaseColumn('cas_vus_5', SumColumn('cas_vus_5')),
            DatabaseColumn('cas_suspects_5', SumColumn('cas_suspects_5')),
            DatabaseColumn('tests_realises_5', SumColumn('tests_realises_5')),
            DatabaseColumn('cas_confirmes_5', SumColumn('cas_confirmes_5')),
            AggregateColumn(
                'cas_vus_5_10', add,
                [SumColumn('cas_vus_5_10'),
                 SumColumn('cas_vus_10')]),
            AggregateColumn(
                'cas_suspects_5_10', add,
                [SumColumn('cas_suspects_5_10'),
                 SumColumn('cas_suspects_10')]),
            AggregateColumn('tests_realises_5_10', add, [
                SumColumn('tests_realises_5_10'),
                SumColumn('tests_realises_10')
            ]),
            AggregateColumn('cas_confirmes_5_10', add, [
                SumColumn('cas_confirmes_5_10'),
                SumColumn('cas_confirmes_10')
            ]),
            DatabaseColumn('cas_vus_fe', SumColumn('cas_vus_fe')),
            DatabaseColumn('cas_suspects_fe', SumColumn('cas_suspects_fe')),
            DatabaseColumn('tests_realises_fe',
                           SumColumn('tests_realises_fe')),
            DatabaseColumn('cas_confirmes_fe', SumColumn('cas_confirmes_fe')),
            DatabaseColumn('cas_vu_total', SumColumn('cas_vu_total')),
            DatabaseColumn('cas_suspect_total',
                           SumColumn('cas_suspect_total')),
            DatabaseColumn('tests_realises_total',
                           SumColumn('tests_realises_total')),
            DatabaseColumn('cas_confirmes_total',
                           SumColumn('cas_confirmes_total')),
            AggregateColumn('div_teasts_cas',
                            lambda x, y: (x or 0) / float(y or 1), [
                                AliasColumn('tests_realises_total'),
                                AliasColumn('cas_suspect_total')
                            ],
                            format_fn=percent)
        ]
Exemple #5
0
 def columns(self):
     return [
         self.location_column,
         DatabaseColumn(
             "Incidents of Abuse",
             SumColumn('incidents_total',
                       filters=self.filters +
                       [BETWEEN('date_reported', 'startdate', 'enddate')])),
         DatabaseColumn(
             "Outreach activities",
             SumColumn('outreach_total',
                       filters=self.filters +
                       [BETWEEN('date', 'startdate', 'enddate')])),
         DatabaseColumn(
             "IGA Reports",
             SumColumn('iga_total',
                       filters=self.filters +
                       [BETWEEN('start_date', 'startdate', 'enddate')])),
         AggregateColumn("Total", self.sum, [
             AliasColumn('incidents_total'),
             AliasColumn('outreach_total')
         ]),
     ]
    def columns(self):
        def percent(num, x, y, z, w):
            denom = (x or 0) + (y or 0) + (z or 0) + (w or 0)
            if not denom:
                return {'sort_key': 'NA', 'html': 0}
            div = (num or 0) / float(denom)
            return {'sort_key': div, 'html': '%.2f%%' % (div * 100)}

        return [
            DatabaseColumn('site_id', SimpleColumn('site_id')),
            DatabaseColumn('cas_vus_5', SumColumn('cas_vus_5')),
            DatabaseColumn('cas_suspects_5', SumColumn('cas_suspects_5')),
            DatabaseColumn('cas_confirmes_5', SumColumn('cas_confirmes_5')),
            DatabaseColumn('cas_vus_5_10', SumColumn('cas_vus_5_10')),
            DatabaseColumn('cas_suspects_5_10',
                           SumColumn('cas_suspects_5_10')),
            DatabaseColumn('cas_confirmes_5_10',
                           SumColumn('cas_confirmes_5_10')),
            DatabaseColumn('cas_vus_10', SumColumn('cas_vus_10')),
            DatabaseColumn('cas_suspects_10', SumColumn('cas_suspects_10')),
            DatabaseColumn('cas_confirmes_10', SumColumn('cas_confirmes_10')),
            DatabaseColumn('cas_vus_fe', SumColumn('cas_vus_fe')),
            DatabaseColumn('cas_suspects_fe', SumColumn('cas_suspects_fe')),
            DatabaseColumn('cas_confirmes_fe', SumColumn('cas_confirmes_fe')),
            AggregateColumn('total_cas',
                            lambda x, y, z, w: (x or 0) + (y or 0) + (z or 0) +
                            (w or 0), [
                                AliasColumn('cas_confirmes_5'),
                                AliasColumn('cas_confirmes_5_10'),
                                AliasColumn('cas_confirmes_10'),
                                AliasColumn('cas_confirmes_fe'),
                            ],
                            slug='total_cas'),
            AggregateColumn('per_cas_5',
                            percent, [
                                AliasColumn('cas_confirmes_5'),
                                AliasColumn('cas_confirmes_5'),
                                AliasColumn('cas_confirmes_5_10'),
                                AliasColumn('cas_confirmes_10'),
                                AliasColumn('cas_confirmes_fe')
                            ],
                            format_fn=lambda x: x),
            AggregateColumn('per_cas_5_10',
                            percent, [
                                AliasColumn('cas_confirmes_5_10'),
                                AliasColumn('cas_confirmes_5'),
                                AliasColumn('cas_confirmes_5_10'),
                                AliasColumn('cas_confirmes_10'),
                                AliasColumn('cas_confirmes_fe')
                            ],
                            format_fn=lambda x: x),
            AggregateColumn('per_cas_10',
                            percent, [
                                AliasColumn('cas_confirmes_10'),
                                AliasColumn('cas_confirmes_5'),
                                AliasColumn('cas_confirmes_5_10'),
                                AliasColumn('cas_confirmes_10'),
                                AliasColumn('cas_confirmes_fe')
                            ],
                            format_fn=lambda x: x),
            AggregateColumn('per_cas_fa',
                            percent, [
                                AliasColumn('cas_confirmes_fe'),
                                AliasColumn('cas_confirmes_5'),
                                AliasColumn('cas_confirmes_5_10'),
                                AliasColumn('cas_confirmes_10'),
                                AliasColumn('cas_confirmes_fe')
                            ],
                            format_fn=lambda x: x)
        ]