mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Canonical API 'skeleton': urls & views
this gives me something to look at and work with, despite being wildly incomplete See #146
This commit is contained in:
16
issues/api_views.py
Normal file
16
issues/api_views.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from rest_framework import viewsets
|
||||
|
||||
from .models import Issue, Grouping
|
||||
from .serializers import IssueSerializer, GroupingSerializer
|
||||
|
||||
|
||||
class IssueViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
queryset = Issue.objects.all().order_by('digest_order') # TBD
|
||||
serializer_class = IssueSerializer
|
||||
|
||||
|
||||
class GroupingViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
queryset = Grouping.objects.all().order_by('grouping_key') # TBD
|
||||
serializer_class = GroupingSerializer
|
||||
|
||||
# TODO: the idea of required filter-fields when listing.
|
||||
45
issues/serializers.py
Normal file
45
issues/serializers.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from .models import Issue, Grouping
|
||||
|
||||
|
||||
class IssueSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Issue
|
||||
|
||||
# TODO better wording:
|
||||
# This is the first attempt at getting the list of fields right. My belief is: this is a nice minimal list.
|
||||
# it _does_ contain `data`, which is typically quite "fat", but I'd say that's the most useful field to have.
|
||||
# and when you're actually in the business of looking at a specific event, you want to see the data.
|
||||
fields = [
|
||||
"id",
|
||||
"project",
|
||||
"is_deleted",
|
||||
"digest_order",
|
||||
"last_seen",
|
||||
"first_seen",
|
||||
"digested_event_count",
|
||||
"stored_event_count",
|
||||
"calculated_type",
|
||||
"calculated_value",
|
||||
"transaction",
|
||||
# "last_frame_filename",
|
||||
# "last_frame_module",
|
||||
# "last_frame_function",
|
||||
"is_resolved",
|
||||
"is_resolved_by_next_release",
|
||||
# "fixed_at", too "raw"? i.e. too implementation-tied?
|
||||
# "events_at", too "raw"? i.e. too implementation-tied?
|
||||
"is_muted",
|
||||
# "unmute_on_volume_based_conditions", too "raw"? i.e. too implementation-tied?
|
||||
]
|
||||
|
||||
|
||||
class GroupingSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Grouping
|
||||
fields = [
|
||||
"project",
|
||||
"grouping_key",
|
||||
"issue",
|
||||
]
|
||||
Reference in New Issue
Block a user