def total_by_source(days_back=None):

    q = [
        {"$group": {'_id': "$source", 'totalItems': {"$sum": 1}}},
        {"$sort": {'_id': 1}}
    ]
    if days_back:
        days_back = timelib.strtodatetime(days_back % "%d days ago")
        q.insert(0, {"$match": {'ts': {"$gte": days_back}}})

    totals = conn_coll.aggregate(q)
    if not totals:
        return False

    return totals['result']
dataset/ETHPy150Open fictivekin/openrecipes/scripts/mongo_stats.py/total_by_source/swapped operands of `%`