Ejemplo n.º 1
0
def db_assign_submission_progressive(session, tid):
    counter = session.query(models.Counter).filter(models.Counter.key == u'submission_sequence', models.Counter.tid == tid).one_or_none()
    if counter is None:
        counter = models.Counter({'key': u'submission_sequence', 'tid': tid})
        session.add(counter)
    else:
        now = datetime_now()
        update = counter.update_date
        if ((now > update) and
            (not((now.year == update.year) and (now.month == update.month) and (now.day == update.day)))):
            counter.counter = 0

        counter.counter += 1
        counter.update_date = now

    return counter.counter
Ejemplo n.º 2
0
def db_assign_submission_progressive(store):
    counter = store.find(models.Counter, models.Counter.key == u'submission_sequence').one()
    if not counter:
        counter = models.Counter({'key': u'submission_sequence'})
        store.add(counter)
    else:
        now = datetime_now()
        update = counter.update_date
        if ((now > counter.update_date) and (not((now.year == update.year) and
                                                     (now.month == update.month) and
                                                     (now.day == update.day)))):
            counter.counter = 1
        else:
            counter.counter += 1

        counter.update_date = now

    return counter.counter