<commit_before>from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
from submissions.models.artist import Artist
from submissions.models.album import Album
from submissions.models.link import Link
from submissions.models.track import Track
from tagging.models import Tag
from tracking.models import TrackedArtist, TrackedAlbum, TrackedLink
from django.contrib.auth.models import User
from django.db.models import Count
from haystack.forms import SearchForm
from django.views.decorators.cache import cache_page
import datetime
from updates.models import Update


def index(request):
    tracked = TrackedArtist.objects.order_by('-hits')[:20]
    t_artists= [artist for artist in tracked if artist.object.is_public][:10]

    now = datetime.datetime.now()
    for update in Update.objects.filter(expired=False):
        if update.expires < now:
            update.expired = True
            update.save()

    context = RequestContext(request, {
        'updates': Update.objects.filter(expired=False),
        'artist_count': Artist.objects.count(),
        'album_count' : Album.objects.count(),
        'link_count' : Link.objects.count(),
        'tag_count' : Tag.objects.count(),
        'user_count' : User.objects.count(),
        'track_count': Track.objects.count(),
        'latest_artists' : Artist.objects.filter(is_valid=True, is_deleted=False).order_by('-created')[:10],
        'latest_albums' : Album.objects.filter(is_valid=True, is_deleted=False).order_by('-created')[:10],
        'latest_links' : Link.objects.order_by('-created').filter(is_deleted=False)[:10],
        'popular_artists' : t_artists,
        'popular_albums' : TrackedAlbum.objects.order_by('-hits')[:10],
        'popular_links' : TrackedLink.objects.order_by('-hits')[:10],
        'top_contrib_artists': User.objects.annotate(Count('artist')).order_by('-artist__count')[1:11], #get rid of tehorng
        'top_contrib_albums': User.objects.annotate(Count('album')).order_by('-album__count')[1:11], #get rid of tehorng
        'top_contrib_links': User.objects.annotate(Count('link')).order_by('-link__count')[:10],
        'form' : SearchForm(initial={'q': "artist, album, or song"}),
    })
    return render_to_response('tehorng/index.html', context)<commit_msg>Get rid of legacy Tracking code.<commit_after>from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
from submissions.models.artist import Artist
from submissions.models.album import Album
from submissions.models.link import Link
from submissions.models.track import Track
from tagging.models import Tag
from tracking.models import TrackedArtist, TrackedAlbum, TrackedLink
from django.contrib.auth.models import User
from django.db.models import Count
from haystack.forms import SearchForm
from django.views.decorators.cache import cache_page
import datetime
from updates.models import Update
from submissions.views.utils import get_popular
from django.contrib.contenttypes.models import ContentType

def index(request, template="tehorng/index.html"):
    now = datetime.datetime.now()
    for update in Update.objects.filter(expired=False):
        if update.expires < now:
            update.expired = True
            update.save()

    context = RequestContext(request, {
        'updates': Update.objects.filter(expired=False),
        'artist_count': Artist.objects.count(),
        'album_count' : Album.objects.count(),
        'link_count' : Link.objects.count(),
        'tag_count' : Tag.objects.count(),
        'user_count' : User.objects.count(),
        'track_count': Track.objects.count(),
        'latest_artists' : Artist.objects.filter(is_valid=True, is_deleted=False).order_by('-created')[:10],
        'latest_albums' : Album.objects.filter(is_valid=True, is_deleted=False).order_by('-created')[:10],
        'latest_links' : Link.objects.order_by('-created').filter(is_deleted=False)[:10],
        'top_contrib_artists': User.objects.annotate(Count('artist')).order_by('-artist__count')[1:11], #get rid of tehorng
        'top_contrib_albums': User.objects.annotate(Count('album')).order_by('-album__count')[1:11], #get rid of tehorng
        'top_contrib_links': User.objects.annotate(Count('link')).order_by('-link__count')[:10],
        'form' : SearchForm(initial={'q': "artist, album, or song"}),
    })
    return render_to_response(template, context)
{'fraction_non_alphanumeric': 0.12875250166777852, 'fraction_numerical': 0.008005336891260841, 'mean_word_length': 4.432367149758454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4238931', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1336, 'n_words': 271}