Skip to content

Update CommunityLibraryViewset to support notifications filtering #5456

@AlexVelezLl

Description

@AlexVelezLl

This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Once the editor channel submission workflow is in place, the editor has everything they need to submit a channel. However, they do not have a way to get any updates about their submission. For this, we will build a Notifications page where editors can view the status updates of their submissions or submissions of the channels they are editors for. This issue will focus on implementing the backend filters necessary to support this new page.

Technical requirements

  • For now, we won't be building a new notifications architecture in Studio, as we don't yet have enough use cases. So, we will focus just on getting updates on the Community Library Submissions, i.e., in this notifications page, for now, we will just query the CommunityLibrarySubmissionViewset endpoint.
  • The main problem of using this viewset is that we will use the CommunityLibrarySubmission model, which stores both "events": the creation and the resolution of the submission. Each with their own date
    • To support the filter by date, we will be taking some tradeoffs to optimize the query, but leaving some use cases unsupported. For this, we will always filter by a date_updated field, which will be the same as the date_created if the submission is just created, and hasn't had any other updates, and will replace the date_resolved field when the submission is approved or rejected.
    • So, we will update the date_resolved field to be date_updated in the CommunityLibrarySubmission model, which will be set to the timestamp of each update made on the submission. Look for all references to date_resolved and update them accordingly. Add an index to this field.
    • Add new date filters: date_updated__lte and date_updated__gte. (For this, we will need to create a new filterset class, which would include the channel field too).
  • Add a SearchFilter backend, and set the search fields to use the channel name. So users will be able to search by channel name.
  • Add a status__in multi choice filter to filter by multiple submission statuses.
    • Also, add an index in the status field on the Django model.
  • Since now the editor will be able to see the admin name, move the resolved_by* fields logic to the CommunityLibrarySubmissionViewSetMixin class, so that it is shared between the admins and editors.
  • Update the pagination ordering field and the queryset ordering field to be -date_updated instead.

Acceptance criteria

  • New date_updated field is created, replacing the date_resolved and the default ordering fields.
  • Frontend is now able to filter by date_updated date range, status__in, search filters.
  • Db indexes have been added to the date_updated and status fields.
  • Tests are added/updated according to the new specs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions