Resolve "Improve LocalBaserow services: implement LocalBaserowServiceFilter and LocalBaserowServiceSort"
requested to merge 1966-improve-localbaserow-services-implement-localbaserowservicefilter-and-localbaserowservicesort into develop
What is in this MR
This MR introduces the first pass at ServiceFilter
and ServiceSort
.
When implemented in our first integration, these are named LocalBaserowTableServiceFilter
and LocalBaserowTableServiceSort
, as they only apply to services which implement LocalBaserowTableService
(GetRow
and ListRows
).
How to test this MR
@jrmi and I discussed how best to test this since it's a backend-only MR, and we agreed that providing Django shell ORM queries would make it easier for the Reviewer.
Setup
- Create a table with fields
Name
(text),Surname
(text) andAge
(number).- Row1:
Alan
,Turing
,50
- Row2:
Alan
,Perkins
,60
- Row3:
Jeff
,Perkins
,70
- Row1:
- Create a view filter for
Name
-equal
-Alan
. - Create a view sort on
Age
-DESC
. - Take note of the table and view IDs.
- Switch to AB, create a new
ListRows
/LocalBaserow
data source in a new, or existing builder application. - Create three paragraphs:
concat(get("data_source.{DATA_SOURCE_ID}.0.Name"), ', age ', get("data_source.{DATA_SOURCE_ID}.0.Age"))
concat(get("data_source.{DATA_SOURCE_ID}.1.Name"), ', age ', get("data_source.{DATA_SOURCE_ID}.1.Age"))
concat(get("data_source.{DATA_SOURCE_ID}.2.Name"), ', age ', get("data_source.{DATA_SOURCE_ID}.2.Age"))
- You should only see two valid paragraphs (row1 & row2) as we applied a
ViewFilter
onName=Alan
. - You should see them sorted
Age
DESC.
Filter tests
- Create a new
LocalBaserowTableServiceFilter
:
service = LocalBaserowListRows.objects.get(id=YOUR_SERVICE_ID)
service_filter = LocalBaserowTableServiceFilter.objects.create(
type='equal',
value='Turing',
service=service
field=service.table.field_set.get(name='Surname')
)
- When you next dispatch, you should only see
Row1
,Alan Turing
. TheViewFilter
is being applied, and the newServiceFilter
is being applied on top of it.
Sort tests
- Drop your service filter.
- You should now see two Alan paragraphs again.
- Create a
LocalBaserowTableServiceSort
:
service_filter.delete()
LocalBaserowTableServiceSort.objects.create(
order='ASC',
service=service,
field=service.table.field_set.get(name='Age')
)
- You should now see the two Alans sorted by age ASC, Alan (50) followed by Alan (60). The original age DESC view sort is ignored.
Merge Request Checklist
-
changelog.md has been updated if required. -
New/updated Premium/Enterprise features are separated correctly in the premium or enterprise folder -
The latest Chrome and Firefox have been used to test any new frontend features -
Documentation has been updated -
Quality Standards are met -
Performance: tables are still fast with 100k+ rows, 100+ field tables -
The redoc API pages have been updated for any REST API changes -
Our custom API docs are updated for changes to endpoints accessed via api tokens -
The UI/UX has been updated following UI Style Guide
Closes #1966 (closed)
Edited by Peter Evans