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

feat: Add trigger beforeUnsubscribe for LiveQuery #7419

Open
wants to merge 8 commits into
base: alpha
Choose a base branch
from

Conversation

sadortun
Copy link
Contributor

@sadortun sadortun commented Jun 6, 2021

New Pull Request Checklist

Issue Description

There is a very useful Before Subscribe Trigger, this PR add its counterpart beforeUnsubscribe

Related issue: #7420

Approach

TODOs before merging

  • Add test cases
  • Add entry to changelog

@mtrezza
Copy link
Member

mtrezza commented Jun 6, 2021

Thanks for opening this PR.

Please make sure to also open an issue related to this PR.

@sadortun
Copy link
Contributor Author

sadortun commented Jun 6, 2021

@mtrezza done.

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved too quickly...

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just needs a lint-fix it seems.
And can you add a test for this new trigger?

@codecov
Copy link

codecov bot commented Jun 6, 2021

Codecov Report

Patch coverage: 88.88% and project coverage change: -0.01% ⚠️

Comparison is base (3d6d50e) 94.31% compared to head (5d07966) 94.31%.
Report is 1 commits behind head on alpha.

❗ Current head 5d07966 differs from pull request most recent head 1d1660a. Consider uploading reports for the commit 1d1660a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #7419      +/-   ##
==========================================
- Coverage   94.31%   94.31%   -0.01%     
==========================================
  Files         186      186              
  Lines       14770    14786      +16     
==========================================
+ Hits        13931    13946      +15     
- Misses        839      840       +1     
Files Changed Coverage Δ
src/triggers.js 95.35% <ø> (ø)
src/LiveQuery/ParseLiveQueryServer.js 95.72% <85.71%> (-0.32%) ⬇️
src/cloud-code/Parse.Cloud.js 99.31% <100.00%> (+0.01%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sadortun
Copy link
Contributor Author

sadortun commented Jun 6, 2021

@mtrezza I had to commit with --no-verify, the prettier doesn't seems to work, it does with en error saying there Is no files in /src**/

I'll try to have a look later

@mtrezza
Copy link
Member

mtrezza commented Jun 7, 2021

If you run npm run prettier it should work. But if that causes a lot of changes in files that are unrelated to this PR, please only run it for the files you edited.
Then run npm run lint-fix.

@sadortun
Copy link
Contributor Author

sadortun commented Jun 7, 2021

@mtrezza Sadly prettier wont work with the npm run (im using windows)

This fixes the issue. Do you want a PR ? Should i commit this in this PR ?

- prettier --write '{src,spec}/{**/*,*}.js'
+ prettier --write {src,spec}/{**/*,*}.js

@sadortun
Copy link
Contributor Author

sadortun commented Jun 7, 2021

@mtrezza Docs added parse-community/docs#833

src/cloud-code/Parse.Cloud.js Outdated Show resolved Hide resolved
@mtrezza
Copy link
Member

mtrezza commented Jun 7, 2021

This fixes the issue. Do you want a PR ? Should i commit this in this PR ?

I assume that it still works on unix then, yes please go ahead, I'll test it.

dplewis
dplewis previously approved these changes Jun 8, 2021
Copy link
Member

@dplewis dplewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! @mtrezza anything you want to add?

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can you please update the ToDo list and check if we have things like changelog entry.

@mtrezza
Copy link
Member

mtrezza commented Jun 21, 2021

To clarify the TODO list, I think we can delete these, because they are irrelevant in this PR:

  • Add security check
  • Add new Parse Error codes to Parse JS SDK
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • ...

This PR just needs this I think, then we can do a final review:

  • Add entry to changelog

@sadortun
Copy link
Contributor Author

@mtrezza Changelog entry added

@mtrezza
Copy link
Member

mtrezza commented Jun 22, 2021

@sadortun I removed the n/a TODOs from the post. To clarify, TODOs that do not apply to a PR are removed, not checked, otherwise a reviewer may think you actually made these changes.

@sadortun sadortun requested a review from mtrezza June 25, 2021 12:19
@mtrezza
Copy link
Member

mtrezza commented Jun 26, 2021

Can you take a look at the coverage for src/LiveQuery/ParseLiveQueryServer.js#L848? https://github.com/parse-community/parse-server/pull/7419/checks?check_run_id=2881789028

@mtrezza
Copy link
Member

mtrezza commented Jul 25, 2021

@sadortun Would you mind rebasing this on master and make sure the coverage is fine? I think this will be good to merge then.

@sadortun
Copy link
Contributor Author

Ofc, sorry about the delayS, on this and others PRs !!

@mtrezza
Copy link
Member

mtrezza commented Jul 25, 2021

No worries, thanks for looking into this.

@mtrezza mtrezza removed their request for review July 29, 2021 13:25
@mtrezza
Copy link
Member

mtrezza commented Jul 29, 2021

I have removed myself from review for now. Please feel free to request again when the merge conflicts are resolved.

@sadortun
Copy link
Contributor Author

@mtrezza
✅ Rebased
✅ Fixed coverage

@mtrezza
Copy link
Member

mtrezza commented Sep 3, 2021

⚠️ Important change for merging PRs from Parse Server 5.0 onwards!

We are planning to release the first beta version of Parse Server 5.0 in October 2021.

If a PR contains a breaking change and is not merged before the beta release of Parse Server 5.0, it cannot be merged until the end of 2022. Instead it has to follow the Deprecation Policy and phase-in breaking changes to be merged during the course of 2022.

One of the most voiced community feedbacks was the demand for predictability in breaking changes to make it easy to upgrade Parse Server. We have made a first step towards this by introducing the Deprecation Policy in February 2021 that assists to phase-in breaking changes, giving developers time to adapt. We will follow-up with the introduction of Release Automation and a branch model that will allow breaking changes only with a new major release, scheduled for the beginning of each calendar year.

We understand that some PRs are a long time in the making and we very much appreciate your contribution. We want to make it easy for PRs that contain a breaking change and were created before the introduction of the Deprecation Policy. These PRs can be merged with a breaking change without being phased-in before the beta release of Parse Server 5.0. We are making this exception because we appreciate that this is a time of transition that requires additional effort from contributors to adapt. We encourage everyone to prepare their PRs until the end of September and account for review time and possible adaptions.

If a PR contains a breaking change and should be merged before the beta release, please mention @parse-community/server-maintenance and we will coordinate with you to merge the PR.

Thanks for your contribution and support during this transition to Parse Server release automation!

@sadortun
Copy link
Contributor Author

sadortun commented Sep 3, 2021

@mtrezza @dblythy

✅ Fixed last discussions
✅ Rebased on master

mtrezza
mtrezza previously approved these changes Sep 3, 2021
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing to me!

Let's see what @dblythy says, nothing escapes his eyes usually.

Copy link
Member

@dblythy dblythy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good! Only a minor nit

src/LiveQuery/ParseLiveQueryServer.js Outdated Show resolved Hide resolved
Copy link
Member

@dblythy dblythy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job @sadortun! Sorry I didn't realise that there were other hard coded errors in the file and you were just copying the formatting. We should fix that in a different PR

Actually, a few other things:

const className = subscription.className;
const trigger = getTrigger(className, 'beforeUnsubscribe', Parse.applicationId);
if (trigger) {
const auth = await this.getAuthFromClient(client, request.requestId, request.sessionToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the other uses, getAuthFromClient is wrapped in the try / catch block. I don't think it throws, but could you add it to the try / catch, or add a test case for beforeUnsubscribe without the user.signUp?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sadortun Could you address this comment, then I believe this should be good to merge.

src/cloud-code/Parse.Cloud.js Show resolved Hide resolved
@mtrezza
Copy link
Member

mtrezza commented Feb 12, 2022

@sadortun Do you think we could get this ready for merge?

@sadortun
Copy link
Contributor Author

sadortun commented Feb 12, 2022

Ah, sorry, i was sure it was already merged !

I'll have a look later today.

Edit: sorry about the delay(s) I haven't forgotten you!

@mtrezza mtrezza changed the title [Feature] Add a Trigger for BeforeUnsubscribe on live queries Add a Trigger for BeforeUnsubscribe on live queries Feb 12, 2022
@parse-github-assistant
Copy link

parse-github-assistant bot commented Feb 12, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@mtrezza mtrezza changed the title Add a Trigger for BeforeUnsubscribe on live queries feat: add trigger beforeUnsubscribe for LiveQuery Feb 12, 2022
@mtrezza mtrezza dismissed stale reviews from dplewis and themself via ab796c2 April 3, 2022 23:40
@mtrezza
Copy link
Member

mtrezza commented May 7, 2022

@sadortun came across this PR; it looks almost ready to merge; would you want to take another look at the open comments, so we can merge this?

@parse-github-assistant
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: add trigger beforeUnsubscribe for LiveQuery feat: Add trigger beforeUnsubscribe for LiveQuery Aug 13, 2023
@mtrezza mtrezza requested a review from a team September 26, 2023 19:31
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.

4 participants