Skip to content

Add db_query signal and signal_query method #4981

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

Merged
merged 2 commits into from
Jul 20, 2022

Conversation

OmeGak
Copy link
Member

@OmeGak OmeGak commented Jun 30, 2021

Add a db_query signal that allows a handler modify the query object. The signal_query method is expected to be used for sending the signal in order to guarantee that only one handler modifies the query.

An example of usage is the following:

query = (Registration.query.with_parent(self.event)
         .filter(Registration.is_state_publishable, ~RegistrationForm.is_deleted)
         .join(Registration.registration_form)
         .options(subqueryload('data').joinedload('field_data'),
                  contains_eager('registration_form'))
         .signal_query('publishable-registrations-in-participant-list'))

On the signal handler side, the query can be intercepted like this:

@signals.core.db_query.connect_via('publishable-registrations-in-participant-list')
def _intercept_publishable_registrations_in_participant_list(sender, query, **kwargs):
    return query.filter(...)

@OmeGak OmeGak force-pushed the wip/signal-query branch 2 times, most recently from d07b957 to 1771827 Compare June 30, 2021 15:29
@OmeGak OmeGak force-pushed the wip/signal-query branch from 1771827 to 5f056fb Compare July 18, 2022 16:51
@OmeGak OmeGak marked this pull request as ready for review July 18, 2022 16:51
@OmeGak OmeGak force-pushed the wip/signal-query branch from 5f056fb to 51ab7ce Compare July 19, 2022 12:35
@OmeGak OmeGak changed the title Add db_query lowlevel signal and signal_query util Add db_query signal and signal_query method Jul 19, 2022
@OmeGak OmeGak force-pushed the wip/signal-query branch 2 times, most recently from b0d3a7c to e64141e Compare July 19, 2022 12:52
@OmeGak OmeGak force-pushed the wip/signal-query branch from e64141e to 6b340e6 Compare July 19, 2022 12:58
@ThiefMaster ThiefMaster enabled auto-merge (squash) July 20, 2022 09:20
@ThiefMaster ThiefMaster merged commit 48558cb into indico:master Jul 20, 2022
@ThiefMaster ThiefMaster deleted the wip/signal-query branch July 20, 2022 09:24
SegiNyn pushed a commit to UNOG-Indico/indico-core that referenced this pull request Jul 20, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
SegiNyn pushed a commit to UNOG-Indico/indico-core that referenced this pull request Jul 20, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
OmeGak added a commit to UNOG-Indico/indico-core that referenced this pull request Jul 20, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
SegiNyn pushed a commit to UNOG-Indico/indico-core that referenced this pull request Jul 26, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
OmeGak added a commit to UNOG-Indico/indico-core that referenced this pull request Jul 27, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
OmeGak added a commit to UNOG-Indico/indico-core that referenced this pull request Dec 6, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
OmeGak added a commit to UNOG-Indico/indico-core that referenced this pull request Dec 8, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
OmeGak added a commit to UNOG-Indico/indico-core that referenced this pull request Dec 8, 2022
* Add db_query signal and signal_query method
* Add unit test for signal_query

Co-authored-by: Adrian Moennich <adrian.moennich@cern.ch>
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

Successfully merging this pull request may close these issues.

2 participants