-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "new" institution-user metrics view
- Loading branch information
Showing
5 changed files
with
170 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
import abc | ||
import typing | ||
|
||
from rest_framework import generics | ||
|
||
from api.base.views import JSONAPIBaseView | ||
|
||
if typing.TYPE_CHECKING: | ||
from elasticsearch_dsl import Search | ||
|
||
|
||
class ElasticsearchMetricsListView(JSONAPIBaseView, generics.ListAPIView, abc.ABC): | ||
'''use `elasticsearch_dsl.Search` as a queryset-analogue | ||
''' | ||
@abc.abstractmethod | ||
def get_search(self) -> Search: | ||
... | ||
|
||
### | ||
# beware! rest_framework shenanigans below | ||
|
||
# note: because elasticsearch_dsl.Search supports slicing and gives results when iterated on, | ||
# it should work fine with default pagination! | ||
|
||
# override rest_framework.generics.GenericAPIView | ||
def get_queryset(self): | ||
return self.get_search() | ||
|
||
# override rest_framework.generics.GenericAPIView | ||
def filter_queryset(self, queryset): | ||
return queryset # TODO: FilterMixin, i guess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters