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

Add the new fullTextSearch method with the associated tests. #470

Closed
wants to merge 2 commits into from

Conversation

SebC99
Copy link
Contributor

@SebC99 SebC99 commented Aug 2, 2017

To be used with parse-server version > 2.5.0

@codecov
Copy link

codecov bot commented Aug 2, 2017

Codecov Report

Merging #470 into master will increase coverage by 1.39%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #470      +/-   ##
==========================================
+ Coverage   84.03%   85.42%   +1.39%     
==========================================
  Files          47       46       -1     
  Lines        3801     3747      -54     
  Branches      869      859      -10     
==========================================
+ Hits         3194     3201       +7     
+ Misses        607      546      -61
Impacted Files Coverage Δ
src/ParseQuery.js 94.27% <88.23%> (+0.19%) ⬆️
src/Parse.js 81.53% <0%> (-0.28%) ⬇️
src/encode.js 100% <0%> (ø) ⬆️
src/ParsePolygon.js
src/StorageController.react-native.js 85.71% <0%> (+2.38%) ⬆️
src/decode.js 100% <0%> (+3.33%) ⬆️

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 f713a2c...1012bb0. Read the comment docs.

@dplewis dplewis mentioned this pull request Sep 27, 2017
Copy link

@russell-dot-js russell-dot-js left a comment

Choose a reason for hiding this comment

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

Overall it looks good, but there is some logic in fullTextSearch that either is buggy (if statement that always evaluates to true) or is hard to reason about and warrants test coverage

fullTextSearch(key: string, search: string, language: string, caseSensitive: boolean, diacriticSensitive: boolean): ParseQuery {
if (typeof key === 'undefined' || !key) {
throw new Error('A key is required.');
}

Choose a reason for hiding this comment

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

redundant, could be simplified to if(!key)

throw new Error('You have to add one string to search.');
}
var options = { '$term': search };
if (typeof language !== "undefined" || language !== null) {

Choose a reason for hiding this comment

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

inconsistent usage of single/double quoted strings

Copy link

@russell-dot-js russell-dot-js Oct 8, 2017

Choose a reason for hiding this comment

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

when is this statement false?

var a = null;
typeof a !== 'undefined' // true

var a = undefined;
a !== null // true

if (typeof caseSensitive !== "undefined" || caseSensitive !== null) {
options['$caseSensitive'] = caseSensitive;
}
if (typeof diacriticSensitive !== "undefined" || diacriticSensitive !== null) {

Choose a reason for hiding this comment

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

I'm struggling to see when this would ever be falsy

Copy link
Contributor Author

@SebC99 SebC99 Nov 3, 2017

Choose a reason for hiding this comment

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

You're right, it was supposed to be a &&.
To be more precise we could go with something like:

if (typeof diacriticSensitive === "boolean") {
    options['$diacriticSensitive'] = diacriticSensitive;
}

I prefer it to just test if (diacritic) to let user specifies a false value if he wants to for any reason.

@montymxb
Copy link
Contributor

montymxb commented Nov 3, 2017

@SebC99 just wanted to check in and see if you're still working on this. For some of the notes above you can simplify them down just !param (like for requiring search and key). As for the rest, since they should be booleans, if(param) would do just fine.

@SebC99
Copy link
Contributor Author

SebC99 commented Nov 3, 2017

@montymxb sorry I didn't see @russell-dot-js's comments! I'll check that asap

@SebC99 SebC99 force-pushed the feature/fulltextsearch branch from c29f31e to 1012bb0 Compare November 3, 2017 10:04
if (typeof language === 'string') {
options['$language'] = language;
}
if (typeof caseSensitive === "boolean") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should wrap "boolean" with single quotes like the ones above.

if (typeof caseSensitive === "boolean") {
options['$caseSensitive'] = caseSensitive;
}
if (typeof diacriticSensitive === "boolean") {
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 as above

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.

Just some nits with the choice of single/double quotes.

Also can you add integration tests for this? They would go in here. Ideally we'll need a test case demonstrating functional use of each parameter and anti-cases if possible. Just paired cases where one indicates you can find something with fullText and given parameters, and another case where you do not expect to get an object.

As far as the current failure I'll look at this, but it seems unrelated to what you're presenting here.

Other than nice job on putting this together 👍 . Looking forward to checking out the changes!

@montymxb
Copy link
Contributor

montymxb commented Dec 8, 2017

@SebC99 bump?

@SebC99
Copy link
Contributor Author

SebC99 commented Dec 8, 2017

Sorry haven't got the time yet (and not very good at writing tests)!

@montymxb
Copy link
Contributor

montymxb commented Dec 9, 2017

Gotcha. Well if you need an idea of what tests would look like you can checkout one of the test files for parse queries. Additionally that example file is probably where you would put your tests as well. Adding some new its would be what we're looking for. If you have any questions as to how to go about this let me know and I'll see if you I can dig up some links to get you in the right direction.

@srameshr
Copy link

srameshr commented Jan 8, 2018

Shit! This did not make it into the JS sdk?
Waiting for this! The current test search on Parse Server is barely useful.
@montymxb

@SebC99
Copy link
Contributor Author

SebC99 commented Jan 9, 2018

@srameshr sorry I really don't have the time to add the integration tests for now :(

@srameshr
Copy link

srameshr commented Jan 9, 2018

@montymxb Any chance that you would make the changes and merge it in? I will update the docs.

@dplewis
Copy link
Member

dplewis commented Jan 9, 2018

@srameshr I wanted to give @SebC99 a chance to get this in. I have some time later to add Full Text Search to this SDK. That reminds me to add it to the Android SDK as well.

Also the JS Docs will be auto generated

@srameshr
Copy link

srameshr commented Jan 9, 2018

@dplewis It would be great if you could do that. As of now I am manually copying and pasting that chuck of code.

@montymxb
Copy link
Contributor

montymxb commented Jan 9, 2018 via email

@srameshr
Copy link

@montymxb @dplewis
Waiting for this to be merged!

@dplewis
Copy link
Member

dplewis commented Jan 11, 2018

@srameshr I opened #541. It may take some time for approval and a new sdk release. You can always fork the repo, pull down the changes and use your own branch until the release.

@montymxb
Copy link
Contributor

Closed in favor of #541 , still wanted to say thanks for taking the time to work on this @SebC99 .

@montymxb montymxb closed this Jan 15, 2018
@SebC99
Copy link
Contributor Author

SebC99 commented Jan 16, 2018

Thanks a lot guys, and sorry for not having had the time to finish it!
💪

@dplewis
Copy link
Member

dplewis commented Jan 16, 2018

@SebC99 No problem, thanks for getting started on this requested feature. 👍

@SebC99 SebC99 deleted the feature/fulltextsearch branch August 27, 2022 21:06
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.

6 participants