(user, since=None, until=None)
return query.count()
Number of distinct episodes the user has played in the interval
Number of distinct episodes the user has played in the interval
Number of distinct episodes the user has played in the interval
def num_played_episodes(user, since=None, until=None):
    """Number of distinct episodes the user has played in the interval"""
    query = (
        EpisodeHistoryEntry.objects.filter(user=user, action=EpisodeHistoryEntry.PLAY)
        .order_by("episode__id")
        .distinct("episode__id")
    )

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

    if until is not None:
        query = query.filter(timestamp__lte=until)

    return query.count()
def num_played_episodes ( user , since = None , until = None ) : query = ( EpisodeHistoryEntry . objects . filter ( user = user , action = EpisodeHistoryEntry . PLAY ) . order_by ( "episode__id" ) . distinct ( "episode__id" ) ) if since is not None : query = query . filter ( timestamp__gt = since ) if until is not None : query = query . filter ( timestamp__lte = until ) return query . count ( )