Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Refresh records status column when a response is created/updated/upserted/deleted #5069

Closed
Tracked by #5000
jfcalvo opened this issue Jun 20, 2024 · 0 comments
Assignees

Comments

@jfcalvo
Copy link
Member

jfcalvo commented Jun 20, 2024

The new status column created at records table should be refreshed every time an associated response is created/updated/upserted/deleted.

There are several approaches that we can explore to solve this issue:

  1. Use a function that refresh the status column when some function inside our context modules execute a change over a response.
  2. Use database triggers to refresh the status column.
  3. Use SQLAchemy event callbacks to listen to changes in responses and refresh the status column.

We need to take into account that when records are created responses can be assigned too, in these cases we need to refresh the status column as well.

@jfcalvo jfcalvo self-assigned this Jun 20, 2024
jfcalvo added a commit that referenced this issue Jul 1, 2024
…se model (#5118)

# Description

This PR include the following changes:
* Added `count_submitted_responses` as a property of `Record` database
model.
  * This property requires record responses to be pre-loaded. 
  * This value is get from the database using a subquery.
* Added `count_submitted_responses` to search engine mapping.
* Record `status` is exposed by API schemas and is calculated based in
`count_submitted_responses` column property from `Record` database
model.
* This `status` is defined as a property inside `Record` database model
and it's using the `dataset` distribution strategy to calculate the
value.

## Missing changes in this PR
- [ ] Make test suite to pass after changes.
- [ ] Add support to `status` value in search endpoints so we can filter
by `status=pending&response_status=pending`.
- [ ] Check that we are refreshing the record
`count_submitted_responses` values before indexing the record and add a
partial update into the search engine when some associated entity (like
responses) are create/updated/deleted for a record. (We probably should
add a partial update of the index for this record attribute).
- [ ] Change dataset progress metrics.
- [ ] Change user metrics.

Refs #5069

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (change restructuring the codebase without changing
functionality)
- [ ] Improvement (change adding some improvement to an existing
functionality)
- [ ] Documentation update

**How Has This Been Tested**

(Please describe the tests that you ran to verify your changes. And
ideally, reference `tests`)

- [ ] Test A
- [ ] Test B

**Checklist**

- [ ] I added relevant documentation
- [ ] follows the style guidelines of this project
- [ ] I did a self-review of my code
- [ ] I made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK)
(see text above)
- [ ] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)

---------

Co-authored-by: Paco Aranda <[email protected]>
@jfcalvo jfcalvo closed this as completed Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant