-
Notifications
You must be signed in to change notification settings - Fork 32
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: refactor requests from freetexts views to other similar views #660
base: main
Are you sure you want to change the base?
Conversation
@jkuester Looking at the implementation of getReportsForContacts, I think we need another REST endpoint and a function in |
😅 Wow, it did not take us long to find new workflows to support here!
Eventually we may decide we want to do this (and the The main problem with that is we do not actually support the second call yet... 🤦 😞 There is no way to get multiple contact docs by UUID at the same time. It should be trivial to add support for this (but we should not do it in the current cht-datasource PR).
This is interesting functionality. I guess you basically end up with the union of all the key matches. This is another workflow that we could eventually support, but it feels like a bit of an edge case in the context of freetext searching. (An intersection would seem to be more useful to me.) In general, I think it is acceptable to say folks need to just make multiple search requests if they want to search with different keys. However, the cht-conf functionality linked here does complicate this since we could end up with a large number of requests.... The more I look at this cht-conf code, though, the more I am wondering if we need the freetext search at all?!? 🤔 Basically this code is abusing the key:value searching to track down reports for a particular contact. Unless I am missing something, this searching could be more efficiently done by using the purpose-built views to get this data. const createdAtKeys = createdAtId ? [
[`patient_id:${createdAtId}`],
[`patient_uuid:${createdAtId}`],
[`place_id:${createdAtId}`],
[`place_uuid:${createdAtId}`]
] : []; To get all the reports associated with the const createdByKeys = createdByIds.map(id => [`contact:${id}`]); Oh woah! This is it! 😆 Mokhtar and I spent a bunch of time trying to figure out why we had this weird custom emission from Regardless, this does not need to be a freetext query. I think we should be able to use @dianabarsan is there any concern with calling |
I think I think indexing reports by submitter is a pretty important functionality in the app, that we might not want to lose. Also I firmly believe we should revise our ddocs and make sure we don't have too much duplicated emissions. Old Couch would never index views that are not used, but new couch will index everything in the background unless expressly specified not skip. To conclude: |
Thanks @dianabarsan!
Ah, yes, this makes sense. I had missed the fact that the descendant's reports would also come back for an ancestor contact.
In this case, I don't think we want to worry about descendant contact's reports. Those are handled elsewhere in the code flow (and then the lineage hierarchy of all the affected contacts/reports gets totally re-written to be correct. For the purposes of this PR, I am fine assuming the current code flow is "correct" and for this query we only care about getting the reports submitted by the actual contact.
10000% agree. This needs to happen, but just not as part of this initial TCO/freetext work! I really want to avoid any other major uplifts creeping in here... 😬 @sugat009, going through this again, I think we are still good using the Then, we can continue doing the |
…client/reports_by_subject
1eae023
to
05f2355
Compare
Okay, so silly question here, but I think maybe you forgot about (or misunderstood) the last half of my comment... 😅
If we have a Additionally, regardless of the |
@jkuester I've left out the checking for specific version of CHT and querying against nouveau for now as the release version is not fixed yet. I've left a |
UPDATE: on today's Hosting TCO squad it was decided that the query to the Nouveau views will be done without the version check at the moment to have the code ready to be shipped. When the release number is decided then the |
Might be convenient to just include an if-check against a placeholder version so you can fully implement both sides of the if-else along with unit tests. Then, once we have a real CHT version, it will be a simple copy-paste to update the version we are using. |
FYI @sugat009 I just pushed a change to the cht-core {
"q":"contact:0790b03c-3a75-415f-8cf3-9d6dae8f16d0 OR contact:8e9f059d-9cd0-4da3-98ac-ef6aaf0b9c1f"
} I think this should be enough to unblock you here, but LMK if you have issues. |
}); | ||
}); | ||
|
||
it('move health_center_1 to district_2 in CHT version 4.99.0', async () => { |
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've put in the version 4.99.0 for now because we are not sure which version the nouveau stuff will be shipped in, and it provides us with a good buffer. We may need to change the version here once Nouveau is released.
@jkuester This is ready for review now. |
Description
Refactored calls to freetexts views in
cht-core
to use other views instead because the freetext views will soon be removed. Check ticket for more info.Partially solves: medic/cht-core#9692
Code review items
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.