示例#1
0
def on_loan_completed_statsdb(loan):
    """Marks the loan as completed in the stats database.
    """
    key = _get_loan_key(loan)
    t_start = datetime.datetime.utcfromtimestamp(loan['loaned_at'])
    t_end = datetime.datetime.utcfromtimestamp(loan['returned_at'])
    d = {
        "book": loan['book'],
        "resource_type": loan['resource_type'],
        "t_start": t_start.isoformat(),
        "t_end": t_end.isoformat(),
        "status": "completed",
    }
    old = statsdb.get_entry(key)
    if old:
        d = dict(old, **d)
    statsdb.update_entry(key, d)
示例#2
0
def on_loan_completed_statsdb(loan):
    """Marks the loan as completed in the stats database.
    """
    key = _get_loan_key(loan)
    t_start = datetime.datetime.utcfromtimestamp(loan['loaned_at'])
    t_end = datetime.datetime.utcfromtimestamp(loan['returned_at'])
    d = {
        "book": loan['book'],
        "resource_type": loan['resource_type'],
        "t_start": t_start.isoformat(),
        "t_end": t_end.isoformat(),
        "status": "completed",
    }
    old = statsdb.get_entry(key)
    if old:
        d = dict(old, **d)
    statsdb.update_entry(key, d)