<commit_before>from django.conf.urls.defaults import url

from tastypie.resources import ModelResource
from jmbo.api import ModelBaseResource

from music.models import Track


class TrackResource(ModelBaseResource):

    class Meta:
        queryset = Track.permitted.all()
        resource_name = 'track'
        ordering = ['last_played']

    def override_urls(self):
        return [
            url(r"^(?P<resource_name>%s)/(?P<slug>[\w-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
        ]
<commit_msg>Allow filtering and ordering on API<commit_after>from django.conf.urls.defaults import url

from tastypie.resources import ModelResource
from tastypie.constants import ALL
from jmbo.api import ModelBaseResource

from music.models import Track


class TrackResource(ModelBaseResource):

    class Meta:
        queryset = Track.permitted.all()
        resource_name = 'track'
        filtering = {
            'last_played': ALL
        }
        ordering = ['last_played']

    def override_urls(self):
        return [
            url(r"^(?P<resource_name>%s)/(?P<slug>[\w-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
        ]

{'fraction_non_alphanumeric': 0.11637239165329052, 'fraction_numerical': 0.0, 'mean_word_length': 3.375438596491228, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5578481', 'n_tokens_mistral': 376, 'n_tokens_neox': 370, 'n_words': 78}