Skip to content

Resolve "Improve LocalBaserow services: implement LocalBaserowServiceFilter and LocalBaserowServiceSort"

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

  1. Create a table with fields Name (text), Surname (text) and Age (number).
    • Row1: Alan, Turing, 50
    • Row2: Alan, Perkins, 60
    • Row3: Jeff, Perkins, 70
  2. Create a view filter for Name - equal - Alan.
  3. Create a view sort on Age - DESC.
  4. Take note of the table and view IDs.
  5. Switch to AB, create a new ListRows / LocalBaserow data source in a new, or existing builder application.
  6. Create three paragraphs:
    1. concat(get("data_source.{DATA_SOURCE_ID}.0.Name"), ', age ', get("data_source.{DATA_SOURCE_ID}.0.Age"))
    2. concat(get("data_source.{DATA_SOURCE_ID}.1.Name"), ', age ', get("data_source.{DATA_SOURCE_ID}.1.Age"))
    3. concat(get("data_source.{DATA_SOURCE_ID}.2.Name"), ', age ', get("data_source.{DATA_SOURCE_ID}.2.Age"))
  7. You should only see two valid paragraphs (row1 & row2) as we applied a ViewFilter on Name=Alan.
  8. 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. The ViewFilter is being applied, and the new ServiceFilter 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

Merge request reports