def update_counter(page, db=None):
    db = db or database
    collection = db['pagecounters']

    date = datetime.utcnow()
    date = date.strftime('%Y/%m/%d')

    page = clean_page(page)

    d = {'$inc': {}}

    visited_by_date = session.data.get('visited_by_date')
    if not visited_by_date:
        visited_by_date = {'date': date, 'pages': []}

    if date == visited_by_date['date']:
        if page not in visited_by_date['pages']:
            d['$inc']['date.%s.unique' % date] = 1
            visited_by_date['pages'].append(page)
            session.data['visited_by_date'] = visited_by_date
    else:
        visited_by_date['date'] = date
        visited_by_date['pages'] = []
        d['$inc']['date.%s.unique' % date] = 1
        visited_by_date['pages'].append(page)
        session.data['visited_by_date'] = visited_by_date

    d['$inc']['date.%s.total' % date] = 1

    visited = session.data.get('visited')  # '/project/x/, project/y/'
    if not visited:
        visited = []
    if page not in visited:
        d['$inc']['unique'] = 1
        visited.append(page)
        session.data['visited'] = visited
    d['$inc']['total'] = 1
    collection.update({'_id': page}, d, True, False)
Publish an application.
dataset/ETHPy150Open CenterForOpenScience/osf.io/framework/analytics/__init__.py/update_counter--crossover with--dataset/ETHPy150Open ravello/testmill/lib/testmill/ravello.py/RavelloClient.publish_application