-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add important API filters that enable the following: 1. Ability to list extract metadata applicable only to a given data source and/or data source version. 2. Ability to list upload metadata from a given facility and/or on a given date.
- Loading branch information
1 parent
230fece
commit 1f67b13
Showing
3 changed files
with
94 additions
and
9 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,18 @@ | ||
from django_filters.rest_framework import FilterSet | ||
|
||
|
||
class BaseFilterSet(FilterSet): | ||
""" | ||
The base `FilterSet` from which all other filter sets are derived from. | ||
""" | ||
|
||
... | ||
|
||
|
||
class AuditBaseFilterSet(BaseFilterSet): | ||
""" | ||
The base `FilterSet` from which all other `AuditBase` model filter sets are | ||
derived from. | ||
""" | ||
|
||
... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from apps.core.filters import AuditBaseFilterSet | ||
|
||
from .models import ( | ||
DataSourceVersion, | ||
SQLDatabaseSource, | ||
SQLExtractMetadata, | ||
SQLUploadChunk, | ||
SQLUploadMetadata, | ||
) | ||
|
||
|
||
class DataSourceVersionFilter(AuditBaseFilterSet): | ||
"""Filter for the `DataSourceVersion` model.""" | ||
|
||
class Meta: | ||
model = DataSourceVersion | ||
fields = ("id", "data_source", "data_source_version") | ||
|
||
|
||
class SQLDatabaseSourceFilter(AuditBaseFilterSet): | ||
"""Filter for the `SQLDatabaseSource` model.""" | ||
|
||
class Meta: | ||
model = SQLDatabaseSource | ||
fields = ("id", "name", "database_name", "database_vendor") | ||
|
||
|
||
class SQLExtractMetadataFilter(AuditBaseFilterSet): | ||
"""Filter for the `SQLExtractMetadata` model.""" | ||
|
||
class Meta: | ||
model = SQLExtractMetadata | ||
fields = ( | ||
"id", | ||
"name", | ||
"data_source", | ||
"applicable_source_versions", | ||
"version", | ||
"preferred_uploads_name", | ||
) | ||
|
||
|
||
class SQLUploadChunkFilter(AuditBaseFilterSet): | ||
"""Filter for the `SQLUploadChunk` model.""" | ||
|
||
class Meta: | ||
model = SQLUploadChunk | ||
fields = ("id", "upload_metadata") | ||
|
||
|
||
class SQLUploadMetadataFilter(AuditBaseFilterSet): | ||
"""Filter for the `SQLUploadMetadata` model.""" | ||
|
||
class Meta: | ||
model = SQLUploadMetadata | ||
fields = { | ||
"id": ["exact"], | ||
"extract_metadata": ["exact"], | ||
"org_unit_code": ["exact"], | ||
"org_unit_name": ["exact", "icontains"], | ||
"start_time": ["exact", "lt", "gt"], | ||
"finish_time": ["exact", "lt", "gt"], | ||
"is_consumed": ["exact"], | ||
} |