Skip to content

Support for Aggregate Queries #355

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 8 commits into from
Nov 15, 2017
Merged

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Sep 28, 2017

Support for distinct() and aggregate() queries.

Pending: parse-community/parse-server#4207

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

I like it! Just some things here and there, and the tests look good at initial glance. We'll have to wait and see for when this feature is merged in to judge where the tests stand.

public function distinct($key)
{
$sessionToken = null;
if (ParseUser::getCurrentUser()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do something like this to avoid calling ParseUser::getCurrentUser() twice, while still validating there is a current user.

if($user = ParseUser::getCurrentUser()) {
  ...
}

$user would be set in the conditional block then to use.

'aggregate/'.$this->className.'?'.$queryString,
$sessionToken,
null,
true
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't looked over the PR in detail yet over on the server, but does this require the master key to work? If not we should be adding a method parameter to optionally use the master key, same as how the other query methods work.

Copy link
Member Author

Choose a reason for hiding this comment

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

The server requires a masterKey for security purposes

}

/**
* Execute a aggregate query and returns aggregate results.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a little textual typo on a, Execute an aggregrate...

public function aggregate($pipeline)
{
$sessionToken = null;
if (ParseUser::getCurrentUser()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing as above regarding calling this twice.

'aggregate/'.$this->className.'?'.$queryString,
$sessionToken,
null,
true
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here regarding the use of the master key. If it's not required to work it should be a method parameter with a default of false.

@montymxb montymxb added this to the 1.4.0 milestone Nov 13, 2017
@montymxb
Copy link
Contributor

@dplewis you'll need to merge the latest master in to correct those 'Bad Request'/'invalid session token' errors (fixed in #374, bad test cleanup on me). Beyond that I think you will only have a pair of errors before this is good.

@codecov
Copy link

codecov bot commented Nov 15, 2017

Codecov Report

Merging #355 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
+ Coverage      99%   99.01%   +0.01%     
==========================================
  Files          38       38              
  Lines        3522     3559      +37     
==========================================
+ Hits         3487     3524      +37     
  Misses         35       35
Impacted Files Coverage Δ
src/Parse/ParseQuery.php 99.48% <100%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af27c70...36abc00. Read the comment docs.

@dplewis
Copy link
Member Author

dplewis commented Nov 15, 2017

@montymxb I noticed this issue as well parse-community/parse-server#4351
Once thats merged I'll add a test case for it

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

Awesome! The code is good to go, but can I request that you add a small section in the README for this? You may have noticed that I've restructured it to start with a table of contents, everything is pretty easy to find from that. You can add a part in the Queries section. You can add it above or below the Relative Time sub-section, wherever works so long as it's in that group.

As part of the upcoming 1.4.0 release I'll be going over all changes since 1.3.0 and putting up a complete PR for the docs, so we're good on that end.

$this->assertEquals(0, count($results));
}

public function testDisinctOnUsers()
Copy link
Contributor

@montymxb montymxb Nov 15, 2017

Choose a reason for hiding this comment

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

Whoop almost missed this, typo here on testDisinctOnUsers

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

Sweet 👍

@montymxb montymxb merged commit d0808aa into parse-community:master Nov 15, 2017
@dplewis dplewis deleted the aggregate branch November 15, 2017 22:12
@sujitbaniya
Copy link

Great feature to move on

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.

3 participants