Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/status board #708

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Cherry pick
  • Loading branch information
Oludare96 authored and cardene committed Aug 8, 2017
commit bf052545055e6b2ccfa509093fb908fd9c2eb808
8 changes: 6 additions & 2 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
from rest_framework_json_api import serializers

from share import models
from share.models import ProviderRegistration, SiteBanner, CeleryTaskResult, HarvestLogs

from api import fields
from share.models import ProviderRegistration, SiteBanner, CeleryTaskResult, HarvestLog


from share.models import ProviderRegistration, SiteBanner, CeleryTaskResult, logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all the from share.models imports, just use from share import models (and update existing things to match)


from api import fields

class BaseShareSerializer(serializers.ModelSerializer):

Expand Down Expand Up @@ -147,6 +150,7 @@ class Meta:
model = models.SourceConfig
fields = '__all__'


class SiteBannerSerializer(ShareModelSerializer):
color = serializers.SerializerMethodField()

Expand Down
2 changes: 1 addition & 1 deletion api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from .registration import * # noqa
from .schema import * # noqa
from .banner import * # noqa
from .harvestlogs import * # noqa
from .harvestlog import * # noqa
from .sourceConfig import * # noqa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename these files:
harvestlogs.py => harvest_logs.py
sourceConfig.py => source_config.py

31 changes: 27 additions & 4 deletions api/views/sourceConfig.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
from rest_framework import viewsets
# trying to fix shit
from api.views import ShareObjectViewSet
from rest_framework import filters
from api.serializers import SourceConfigSerializer
from share.models import SourceConfig
from api.pagination import FuzzyPageNumberPagination
from django.db.models import Count
from django.db.models import Aggregate
from share.models import HarvestLog
from django.db.models import OuterRef, Subquery
from django.db.models import IntegerField

class SourceConfigViewSet(viewsets.ReadOnlyModelViewSet):
class SourceConfigViewSet(ShareObjectViewSet):
serializer_class = SourceConfigSerializer
pagination_class = FuzzyPageNumberPagination
queryset = SourceConfig.objects.all()

def get_queryset(self):
return SourceConfig.objects.all()
# def get_queryset(self):
# recent_harvests = HarvestLog.objects.filter(
# source_config_id = OuterRef(OuterRef('id')),
# status__in = [HarvestLog.STATUS.failed, HarvestLog.STATUS.succeeded]
# ).order_by('-date_started')[:10]
# recent_fails = HarvestLog.objects.filter(
# status = HarvestLog.STATUS.failed,
# id__in = Subquery(recent_harvests.values('id')),
# # output_field = models.IntegerField())
# )
# queryset = SourceConfig.objects.all().annotate(
# fails=Count(Subquery(recent_fails.values('id')),
# # output_field = models.IntegerField()))
# )
# queryset = queryset.order_by('fails')
# return queryset
2 changes: 2 additions & 0 deletions api/views/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SourceViewSet(viewsets.ReadOnlyModelViewSet):
def get_queryset(self):
return Source.objects.exclude(icon='').exclude(is_deleted=True)


def create(self, request, *args, **kwargs):
try:
long_title = request.data['long_title']
Expand Down Expand Up @@ -129,6 +130,7 @@ def create(self, request, *args, **kwargs):
)



class NormalizedDataViewSet(viewsets.ModelViewSet):
"""View showing all normalized data in the SHARE Dataset.

Expand Down