(
    episode, start_date=datetime(2010, 1, 1), leap=timedelta(days=1)
)
Returns data for the episode listener timeseries

    An iterator with data for each day (starting from the first event
    is returned, where each day is represented by a ListenerData tuple
Returns data for the episode listener timeseries
Returns data for the episode listener timeseries
def episode_listener_data(
    episode, start_date=datetime(2010, 1, 1), leap=timedelta(days=1)
):
    """Returns data for the episode listener timeseries

    An iterator with data for each day (starting from the first event
    is returned, where each day is represented by a ListenerData tuple"""
    history = EpisodeHistoryEntry.objects.filter(
        episode=episode, timestamp__gte=start_date
    )
    # contains play-counts, indexed by date {date: play-count}
    play_counts = playcounts_timerange(history)

    # we start either at the episode-release or the first listen-event
    events = (
        list(play_counts.keys()) + [episode.released.date()] if episode.released else []
    )

    if not events:
        return

    # we always start at the first listen-event
    start = min(events)
    for date in daterange(start, leap=leap):
        playcount = play_counts.get(date, 0)
        e = episode if (episode.released.date() == date) else None
        yield ListenerData(date, playcount, e)
def episode_listener_data ( episode , start_date = datetime ( 2010 , 1 , 1 ) , leap = timedelta ( days = 1 ) ) : history = EpisodeHistoryEntry . objects . filter ( episode = episode , timestamp__gte = start_date ) # contains play-counts, indexed by date {date: play-count} play_counts = playcounts_timerange ( history ) # we start either at the episode-release or the first listen-event events = ( list ( play_counts . keys ( ) ) + [ episode . released . date ( ) ] if episode . released else [ ] ) if not events : return # we always start at the first listen-event start = min ( events ) for date in daterange ( start , leap = leap ) : playcount = play_counts . get ( date , 0 ) e = episode if ( episode . released . date ( ) == date ) else None yield ListenerData ( date , playcount , e )