<commit_before>import itertools
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.contrib import messages
from django.http.response import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response
from django.template.context import RequestContext
from django.template.defaultfilters import slugify
from django.utils import timezone
from django.views.generic import DetailView

from core.models import QSICPic
from core.utils import CalendarWeek
from core.utils import EST
from events.models import Event
from events.models import Performance
from events.utils import build_reoccuring_events



def tonight(request):

    return render_to_response(
        'events/tonight.html',
        locals(),
        context_instance=RequestContext(request)
    )


def up_next(request):
    # Starting with today, get the next event or 6 performances.
    now = timezone.now()
    today_date = now.date()
    today = timezone.datetime(today_date.year, today_date.month, today_date.day, tzinfo=EST)

    build_reoccuring_events(now)

    # get all events for cal_week
    events = [e for e in Event.objects.all().order_by('_start_dt') if e.start_dt >= today]

    # get all performances not in events
    performances = Performance.objects.filter(
        start_dt__gte=today,
    ).exclude(
        event__in=events
    ).order_by(
        'start_dt'
    )

    events_and_perofrmances = list(itertools.chain(events, performances))

    events_and_perofrmances.sort(key=lambda i: i.start_dt)

    if events_and_perofrmances and isinstance(events_and_perofrmances[0], Event):
        # just show the one event
        up_next_type = 'event'<commit_msg>Fix issue where placeholder events are shown on homepage.<commit_after>import itertools
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.contrib import messages
from django.http.response import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response
from django.template.context import RequestContext
from django.template.defaultfilters import slugify
from django.utils import timezone
from django.views.generic import DetailView

from core.models import QSICPic
from core.utils import CalendarWeek
from core.utils import EST
from events.models import Event
from events.models import Performance
from events.utils import build_reoccuring_events



def tonight(request):

    return render_to_response(
        'events/tonight.html',
        locals(),
        context_instance=RequestContext(request)
    )


def up_next(request):
    # Starting with today, get the next event or 6 performances.
    now = timezone.now()
    today_date = now.date()
    today = timezone.datetime(today_date.year, today_date.month, today_date.day, tzinfo=EST)

    build_reoccuring_events(now)

    # get all events for cal_week
    events = [e for e in Event.objects.exclude(is_placeholder=True).order_by('_start_dt')
              if e.start_dt >= today]

    # get all performances not in events
    performances = Performance.objects.filter(
        start_dt__gte=today,
    ).exclude(
        event__in=events
    ).order_by(
        'start_dt'
    )

    events_and_perofrmances = list(itertools.chain(events, performances))

    events_and_perofrmances.sort(key=lambda i: i.start_dt)

    if events_and_perofrmances and isinstance(events_and_perofrmances[0], Event):
        # just show the one event
        up_next_type = 'event'
{'fraction_non_alphanumeric': 0.0691594039921282, 'fraction_numerical': 0.0028113578858588698, 'mean_word_length': 4.068376068376068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5675090', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1010, 'n_words': 287}