src/dirbs/reports/base_operator_country.py
def _historic_monthly_stats(self, table_name, as_list=False):
        """Returns a list of historic table results for months previous to this one."""
        rv = []
        with self.conn.cursor() as cursor:
            for month, year in self._previous_reporting_periods():
                cursor.execute(sql.SQL("""SELECT *
                                            FROM {0}
                                           WHERE data_id = (SELECT MAX(data_id)
                                                              FROM report_data_metadata
                                                             WHERE report_month = %s
                                                               AND report_year = %s)
                                             AND operator_id = %s""").format(sql.Identifier(table_name)),
                               [month, year, self.operator_id])
                if not as_list:
                    # If this is None, it means there is no data. Historic monthly stats are expected to be
                    # None is there is no data for this month
                    rv.append(cursor.fetchone())
                else:
                    # For conditions, desired behaviour is the same. If no data exists for a month, we put None in
                    # the array. Otherwise, we put all the results in as a list (there is one result for every
                    # condition)
                    results = cursor.fetchall()
                    if len(results) == 0:
                        rv.append(None)
                    else:
                        rv.append(results)

        return rv
Returns a list of historic table results for months previous to this one.
Returns a list of historic table results for months previous to this one.
Returns a list of historic table results for months previous to this one .
def _historic_monthly_stats(self, table_name, as_list=False):
        rv = []
        with self.conn.cursor() as cursor:
            for month, year in self._previous_reporting_periods():
                cursor.execute(sql.SQL("""SELECT *
                                            FROM {0}
                                           WHERE data_id = (SELECT MAX(data_id)
                                                              FROM report_data_metadata
                                                             WHERE report_month = %s
                                                               AND report_year = %s)
                                             AND operator_id = %s""").format(sql.Identifier(table_name)),
                               [month, year, self.operator_id])
                if not as_list:
                    rv.append(cursor.fetchone())
                else:
                    results = cursor.fetchall()
                    if len(results) == 0:
                        rv.append(None)
                    else:
                        rv.append(results)
        return rv
def _historic_monthly_stats ( self , table_name , as_list = False ) : rv = [ ] with self . conn . cursor ( ) as cursor : for month , year in self . _previous_reporting_periods ( ) : cursor . execute ( sql . SQL ( """SELECT *
                                            FROM {0}
                                           WHERE data_id = (SELECT MAX(data_id)
                                                              FROM report_data_metadata
                                                             WHERE report_month = %s
                                                               AND report_year = %s)
                                             AND operator_id = %s""" ) . format ( sql . Identifier ( table_name ) ) , [ month , year , self . operator_id ] ) if not as_list : rv . append ( cursor . fetchone ( ) ) else : results = cursor . fetchall ( ) if len ( results ) == 0 : rv . append ( None ) else : rv . append ( results ) return rv
Returns a list of historic table results for months previous to this one.
Returns a list of historic table results for months previous to this one .
"""Returns a list of historic table results for months previous to this one.""" # If this is None, it means there is no data. Historic monthly stats are expected to be # None is there is no data for this month # For conditions, desired behaviour is the same. If no data exists for a month, we put None in # the array. Otherwise, we put all the results in as a list (there is one result for every # condition)
self
table_name
as_list