(user, since=None)
return sum([0] + list(seconds))
The seconds played by the user since the given timestamp
The seconds played by the user since the given timestamp
The seconds played by the user since the given timestamp
def seconds_played(user, since=None):
    """The seconds played by the user since the given timestamp"""
    query = EpisodeHistoryEntry.objects.filter(
        user=user, action=EpisodeHistoryEntry.PLAY, stopped__isnull=False
    ).extra(select={"seconds": "stopped-COALESCE(started, 0)"})

    if since is not None:
        query = query.filter(timestamp__gt=since)

    seconds = query.values_list("seconds", flat=True)
    return sum([0] + list(seconds))
def seconds_played ( user , since = None ) : query = EpisodeHistoryEntry . objects . filter ( user = user , action = EpisodeHistoryEntry . PLAY , stopped__isnull = False ) . extra ( select = { "seconds" : "stopped-COALESCE(started, 0)" } ) if since is not None : query = query . filter ( timestamp__gt = since ) seconds = query . values_list ( "seconds" , flat = True ) return sum ( [ 0 ] + list ( seconds ) )