#!/usr/bin/env python3

import sys
from itertools import groupby
from berkeley_bowl import database

db = database()

soups_table = db['soups']

# unique by day and location
key = lambda r: (r['location_name'], r['timestamp'])

for grp, items in groupby(sorted(soups_table, key=key), key=key):
    items = list(items)
    print('{} {}'.format(len(items), items[0]))
