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(9586): implement freetext search in cht datasource #9625

Open
wants to merge 88 commits into
base: master
Choose a base branch
from

Conversation

sugat009
Copy link
Member

@sugat009 sugat009 commented Nov 7, 2024

Description

Closes: #9586

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@sugat009 sugat009 linked an issue Nov 7, 2024 that may be closed by this pull request
@sugat009 sugat009 force-pushed the 9586-implement-freetext-search-in-cht-datasource branch from eba7aac to 43efbef Compare November 18, 2024 08:59
@sugat009 sugat009 requested a review from jkuester February 6, 2025 05:18
Copy link
Contributor

@jkuester jkuester left a comment

Choose a reason for hiding this comment

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

Lets 👏 freaking 👏 go 👏 !!!!! 🚀 🚀

Thanks @sugat009 for hanging in with me on this absolute tour-de-force! 💪

@mrjones-plip
Copy link
Contributor

Lets 👏 freaking 👏 go 👏 !!!!! 🚀 🚀

YYYYYYYYEEEESSS!!! you two are amazing - so great to see this work come together

@sugat009 sugat009 requested a review from dianabarsan February 11, 2025 16:04
const expectedContactIds = [ contact0._id, contact1._id, contact2._id ];
// NOTE: adding a limit of 4 to deliberately fetch 4 contacts with the given search word
// and enforce re-fetching logic
const responsePage = await getUuidsPage(Qualifier.byFreetext(searchWord), null, 4);
Copy link
Member

Choose a reason for hiding this comment

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

Can you please use a limit that is lower than the amount of contacts that we expect to receive?

expect(responseCursor).to.be.equal(null);
});

it('returns a page of people for stringified limit and null cursor passed', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

question: Does person also have a getWithLineage option? If yes, can you please add a test for that as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is already a test for that.

it('returns the person with lineage when the withLineage query parameter is provided', async () => {

However, it's inside the get suite to match the api/controller integration test pattern. I could move it to its own getByLineage suite.

const expectedContactIds = [ report6._id, report7._id, report8._id ];
// NOTE: adding a limit of 4 to deliberately fetch 4 contacts with the given search word
// and enforce re-fetching logic
const responsePage = await getUuidsPage(Qualifier.byFreetext(searchWord), null, 4);
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Can you please use a lower limit than number of results we expect?

@dianabarsan
Copy link
Member

I misclicked and submitted the review without a message 😅

I think this is epic work @sugat009 . All my suggestions are small quality of life things or readability or test coverage things.
Very nice work!

@sugat009 sugat009 requested a review from dianabarsan February 24, 2025 14:48
Copy link
Member

@dianabarsan dianabarsan left a comment

Choose a reason for hiding this comment

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

Great!!! Just one tiny request about adding the test with the lower limit. I think it's really important to add this test, as this can be a majority of requests that make up freetext searches. We should display that pagination works correctly.

const place = await getPlace(Qualifier.byUuid('invalid-uuid'));
expect(place).to.be.null;
});
it(
Copy link
Member

Choose a reason for hiding this comment

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

What about a place that has no parent and no primary contact?

// and enforce re-fetching logic
const queryParams = {
freetext: searchWord,
limit: 4
Copy link
Member

Choose a reason for hiding this comment

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

I think I saw a test that added this and that it was later removed?

// and enforce re-fetching logic
const queryParams = {
freetext: searchWord,
limit: 4
Copy link
Member

Choose a reason for hiding this comment

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

I think we should still add the test, and check that the results are a subset of the list of possible results.

@sugat009
Copy link
Member Author

Great!!! Just one tiny request about adding the test with the lower limit. I think it's really important to add this test, as this can be a majority of requests that make up freetext searches. We should display that pagination works correctly.

Sure, will do.

I think I saw a test that added this and that it was later removed?

Yeah. I've already written the test. I was planning on waiting on the approval before I pushed it mistakenly 😅.

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.

Implement freetext search in cht-datasource
4 participants