(self)
return sourceReport
Return access report by client source (imap, roundcube, ...)
Return access report by client source (imap, roundcube, ...)
Return access report by client source ( imap roundcube ... )
def reportBySource(self):
        """Return access report by client source (imap, roundcube, ...)"""
        condition = "unixtime > '{}%' and source != '-'".format(self.periodFilter)
        timeColumns = "count(ip) as count," + self.dateColumns
        group = "group by source"
        order = "order by count desc"
        query = "select source,{} from connections where {} {} {}".format(
            timeColumns, condition, group, order)
        cursor = self.conn.execute(query)

        sourceReport = []

        for row in cursor:
            line = {}
            line['source'] = row[0]
            line['nbConnections'] = row[1]
            line['from-date'] = row[2]
            line['till-date'] = row[3]
            sourceReport.append(line)

        return sourceReport
def reportBySource ( self ) : condition = "unixtime > '{}%' and source != '-'" . format ( self . periodFilter ) timeColumns = "count(ip) as count," + self . dateColumns group = "group by source" order = "order by count desc" query = "select source,{} from connections where {} {} {}" . format ( timeColumns , condition , group , order ) cursor = self . conn . execute ( query ) sourceReport = [ ] for row in cursor : line = { } line [ 'source' ] = row [ 0 ] line [ 'nbConnections' ] = row [ 1 ] line [ 'from-date' ] = row [ 2 ] line [ 'till-date' ] = row [ 3 ] sourceReport . append ( line ) return sourceReport