Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/webview/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from api.webview import views

urlpatterns = [
url(r'^documents/$', views.DocumentList.as_view()),
url(r'^(documents/){1}(from=((?P<from>(\d{4}-\d{2}-\d{2}){0,1}))&until=((?P<until>\d{4}-\d{2}-\d{2}){0,1})){0,1}/{0,1}$', views.DocumentList.as_view()),
url(r'^get-api-key/$', views.DocumentList.as_view(), name='get-api-key'),
url(r'^documents/status', views.status, name='status'),
url(r'^documents/(?P<source>\w+)/$', views.DocumentsFromSource.as_view(), name='source'),
Expand Down
12 changes: 9 additions & 3 deletions api/webview/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rest_framework.response import Response
from rest_framework.decorators import api_view
from django.views.decorators.clickjacking import xframe_options_exempt

from dateutil.parser import parse
from elasticsearch import Elasticsearch

from scrapi import settings
Expand All @@ -28,7 +28,13 @@ def perform_create(self, serializer):
def get_queryset(self):
""" Return all documents
"""
return Document.objects.all()
filters={}
if self.kwargs.get('from',None):
filters['providerUpdatedDateTime__gte'] = parse(self.kwargs['from'])
if self.kwargs.get('until',None):
filters['providerUpdatedDateTime__lte'] = parse(self.kwargs['until'])

return Document.objects.filter(**filters)


class DocumentsFromSource(generics.ListAPIView):
Expand All @@ -44,7 +50,7 @@ def perform_create(self, serializer):
def get_queryset(self):
""" Return queryset based on source
"""
return Document.objects.filter(source=self.kwargs['source'])
return Document.objects.filter(source=self.kwargs['source']).exclude(normalized=None)


@api_view(['GET'])
Expand Down