(self, db, date_part, params, base)
return self._date_aggregate
Datetime aggregation for a link id.
        :param db:
        :param date_part:
        :param params:
        :param base:
        :return:
Datetime aggregation for a link id.
        :param db:
        :param date_part:
        :param params:
        :param base:
        :return:
Datetime aggregation for a link id . : param db : : param date_part : : param params : : param base : : return :
def date_aggregate(self, db, date_part, params, base):
        """Datetime aggregation for a link id.
        :param db:
        :param date_part:
        :param params:
        :param base:
        :return:
        """
        if self._date_aggregate is None:
            qry = text("""
                SELECT {} AS click_on, COUNT(*)
                FROM clickmeta
                WHERE link_id=:link_id AND created_at >= :created_at
                GROUP BY click_on
                ORDER BY click_on DESC
                """.format(date_part))
            data = db.execute(qry, params).fetchall()
            if base == 'month':
                self._date_aggregate = dict(
                    (datetime.datetime.strptime(
                        k, '%Y-%m-%d').strftime('%d %b, %Y'), val)
                    for k, val in data)
            if base == 'day':
                self._date_aggregate = dict(
                    (datetime.datetime.strptime(
                        k, '%m-%d').strftime('%d %b'), val)
                    for k, val in data)
            else:
                self._date_aggregate = dict(data)
        return self._date_aggregate
def date_aggregate ( self , db , date_part , params , base ) : if self . _date_aggregate is None : qry = text ( """
                SELECT {} AS click_on, COUNT(*)
                FROM clickmeta
                WHERE link_id=:link_id AND created_at >= :created_at
                GROUP BY click_on
                ORDER BY click_on DESC
                """ . format ( date_part ) ) data = db . execute ( qry , params ) . fetchall ( ) if base == 'month' : self . _date_aggregate = dict ( ( datetime . datetime . strptime ( k , '%Y-%m-%d' ) . strftime ( '%d %b, %Y' ) , val ) for k , val in data ) if base == 'day' : self . _date_aggregate = dict ( ( datetime . datetime . strptime ( k , '%m-%d' ) . strftime ( '%d %b' ) , val ) for k , val in data ) else : self . _date_aggregate = dict ( data ) return self . _date_aggregate