-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
base: master
Are you sure you want to change the base?
feat(9586): implement freetext search in cht datasource #9625
Conversation
eba7aac
to
43efbef
Compare
…text-search-in-cht-datasource
…text-search-in-cht-datasource
@jkuester I did not go with the hook implementation as it would mean checking for filenames to run because this auth setup needs to run only for a few test suites, which would have resulted in a not-so-fruitful hook file with checks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! We are getting very close here.
}; | ||
|
||
/** @internal */ | ||
export const getContactLineage = (medicDb: PouchDB.Database<Doc>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I guess now the getPrimaryContactIds, hydratePrimaryContact, hydrateLineage functions do not need to be exported since they are only getting used in this file.
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
…thub.com:medic/cht-core into 9586-implement-freetext-search-in-cht-datasource
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
…thub.com:medic/cht-core into 9586-implement-freetext-search-in-cht-datasource
There was a problem hiding this 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! 💪
@@ -155,19 +155,45 @@ export const fetchAndFilter = <T extends Doc>( | |||
}; | |||
|
|||
/** @internal */ | |||
export const getPaginatedDocs = async <T>( | |||
getDocsFn: (limit: number, skip: number) => Promise<Nullable<T>[]>, | |||
export const fetchAndFilterUuids = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I am fine going with whatever way you think is most maintainable, but I originally was thinking we could re-use the existing fetchAndFilter
function instead of duplicating most of that logic again here... 😬
export const fetchAndFilterUuids = (
getFunction: (limit: number, skip: number) => Promise<string[]>,
limit: number,
): ReturnType<typeof fetchAndFilter<string>> => {
const uuidSet = new Set<string>();
const filterFn = (uuid: Nullable<string>): boolean => {
if (!uuid) {
return false;
}
const { size } = uuidSet;
uuidSet.add(uuid);
return uuidSet.size !== size;
};
return fetchAndFilter(
getFunction,
filterFn,
limit
);
};
I see you have a + 1
fetch in your fetchAndFilterUuids
which is a bit different behavior (but maybe that should be built into the base fetchAndFilter
? Otherwise, I do not see much performance difference between these right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is no performance difference between these two. I implemented this function separately because when I started working on this I saw a situation, not a bug I guess, where if you query with limit 10. There are 10 objects in the database, the cursor
is also returned as 10
, which means the end-user might re-query again, and then in the next request the user gets cursor
as null
, resulting in 1 extra query. The +1
way is a solution for that.
I did not implement the +1
way directly into the already-existing fetchAndFilter
functionality because it might affect the places where it is used but now that I think about fetchAndFilter
VS fetchAndFilterUuids
, they have a bit of an inconsistent cursor
returns. I think implementing fetchAndFilterUuids
the above way and re-doing fetchAndFilter
with the +1
functionality could be done. However, I think we can move on with the above suggestion and keep the +1
way as a future enhancement as it's not a breaking issue. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move on with the above suggestion and keep the +1 way as a future enhancement as it's not a breaking issue. What do you think?
Sounds good! 👍
YYYYYYYYEEEESSS!!! you two are amazing - so great to see this work come together |
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Co-authored-by: Joshua Kuestersteffen <[email protected]>
Description
Closes: #9586
Code review checklist
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.