Ejemplo n.º 1
0
def get_quotas(playlist):
    quotas = {
        "heavy_rotation_played": 0,
        "heavy_rotation_target": TRACKS_HEAVY_ROTATION_TARGET,
        "light_rotation_played": 0,
        "light_rotation_target": TRACKS_LIGHT_ROTATION_TARGET,
        "local_current_played": 0,
        "local_current_target": TRACKS_LOCAL_CURRENT_TARGET,
        "local_classic_played": 0,
        "local_classic_target": TRACKS_LOCAL_CLASSIC_TARGET,
    }
    pl = PlaylistEvent.all().filter("playlist =", playlist)
    now = chicago_now()
    now.replace(second=0, microsecond=0)
    pl.filter("established >=", now - timedelta(seconds=60 * now.minute))
    pl.filter("established <", now + timedelta(seconds=60 * (60 - now.minute)))
    for event in iter_playlist_events_for_view(pl):
        if not event.is_break:
            if "heavy_rotation" in event.categories:
                quotas["heavy_rotation_played"] += 1
            if "light_rotation" in event.categories:
                quotas["light_rotation_played"] += 1
            if "local_current" in event.categories:
                quotas["local_current_played"] += 1
            if "local_classic" in event.categories:
                quotas["local_classic_played"] += 1

    return quotas
Ejemplo n.º 2
0
def get_quotas(playlist):
    quotas = {'heavy_rotation_played': 0,
              'heavy_rotation_target': TRACKS_HEAVY_ROTATION_TARGET,
              'light_rotation_played': 0,
              'light_rotation_target': TRACKS_LIGHT_ROTATION_TARGET,
              'local_current_played': 0,
              'local_current_target': TRACKS_LOCAL_CURRENT_TARGET,
              'local_classic_played': 0,
              'local_classic_target': TRACKS_LOCAL_CLASSIC_TARGET}
    pl = PlaylistEvent.all().filter('playlist =', playlist)
    now = chicago_now()
    now.replace(second=0, microsecond=0)
    pl.filter('established >=', now - timedelta(seconds=60 * now.minute))
    pl.filter('established <', now + timedelta(seconds=60 * (60 - now.minute)))
    for event in iter_playlist_events_for_view(pl):
        if not event.is_break:
            if 'heavy_rotation' in event.categories:
                quotas['heavy_rotation_played'] += 1
            if 'light_rotation' in event.categories:
                quotas['light_rotation_played'] += 1
            if 'local_current' in event.categories:
                quotas['local_current_played'] += 1
            if 'local_classic' in event.categories:
                quotas['local_classic_played'] += 1

    return quotas
Ejemplo n.º 3
0
def get_quotas(playlist):
    quotas = {
        'heavy_rotation_played': 0,
        'heavy_rotation_target': TRACKS_HEAVY_ROTATION_TARGET,
        'light_rotation_played': 0,
        'light_rotation_target': TRACKS_LIGHT_ROTATION_TARGET,
        'local_current_played': 0,
        'local_current_target': TRACKS_LOCAL_CURRENT_TARGET,
        'local_classic_played': 0,
        'local_classic_target': TRACKS_LOCAL_CLASSIC_TARGET
    }
    pl = PlaylistEvent.all().filter('playlist =', playlist)
    now = chicago_now()
    now.replace(second=0, microsecond=0)
    pl.filter('established >=', now - timedelta(seconds=60 * now.minute))
    pl.filter('established <', now + timedelta(seconds=60 * (60 - now.minute)))
    for event in iter_playlist_events_for_view(pl):
        if not event.is_break:
            if 'heavy_rotation' in event.categories:
                quotas['heavy_rotation_played'] += 1
            if 'light_rotation' in event.categories:
                quotas['light_rotation_played'] += 1
            if 'local_current' in event.categories:
                quotas['local_current_played'] += 1
            if 'local_classic' in event.categories:
                quotas['local_classic_played'] += 1

    return quotas
Ejemplo n.º 4
0
def filter_playlist_events_by_date_range(from_date, to_date):
    fd = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0)
    td = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
    playlist = chirp_playlist_key()
    pl = PlaylistEvent.all().filter('playlist =', playlist)
    pl = pl.filter('established >=', fd)
    pl = pl.filter('established <=', td)
    pl = pl.order('-established')
    return pl
Ejemplo n.º 5
0
def filter_playlist_events_by_date_range(from_date, to_date):
    fd = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0)
    td = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
    playlist = chirp_playlist_key()
    pl = PlaylistEvent.all().filter('playlist =', playlist)
    pl = pl.filter('established >=', fd)
    pl = pl.filter('established <=', td)
    pl = pl.order('-established')
    return pl
Ejemplo n.º 6
0
def get_playlist_history(playlist):
    pl = PlaylistEvent.all().filter("playlist =", playlist)
    pl = pl.filter("established >=", datetime.now() - timedelta(hours=3))
    pl = pl.order("-established")
    return list(iter_playlist_events_for_view(pl))
Ejemplo n.º 7
0
def get_playlist_history(playlist):
    pl = PlaylistEvent.all().filter('playlist =', playlist)
    pl = pl.filter('established >=', datetime.now() - timedelta(hours=3))
    pl = pl.order('-established')
    return list(iter_playlist_events_for_view(pl))