Replace UUID with locator#237
Conversation
|
would take a look at it again and start working on a new fix |
2f84a27 to
1652ac6
Compare
|
added the necessary changes |
mariocynicys
left a comment
There was a problem hiding this comment.
Other than the lint issue, LGTM!
You should squash the 3 commits into one and sign it. And another commit if you decide to modify get_appointments in the PR.
sr-gi
left a comment
There was a problem hiding this comment.
Oh wow, I have had a review for this pending for months and I never submitted it 🤦
Disregard the old comments.
a6d7a59 to
50e1fc9
Compare
sr-gi
left a comment
There was a problem hiding this comment.
Quick check, the concept is OK but the approach is not, check comments inline
50e1fc9 to
143b826
Compare
sr-gi
left a comment
There was a problem hiding this comment.
Better, but I think the approach can still be improved
143b826 to
d3819c0
Compare
mariocynicys
left a comment
There was a problem hiding this comment.
Getting better. Need to filter trackers and some polishing.
sr-gi
left a comment
There was a problem hiding this comment.
Some additional comments on top of @mariocynicys's, looking better overall
d3819c0 to
332f3c4
Compare
mariocynicys
left a comment
There was a problem hiding this comment.
Awesome! Looking very good!
Needs some bigger/more generic tests though.
332f3c4 to
152020f
Compare
sr-gi
left a comment
There was a problem hiding this comment.
Looks pretty good. I left mostly rustlang improvements and some comments/nits.
The main things missing are more tests for get_appointment, this should be close to mergeable at this point
modified test to reflect change modified Todo to reflect recent change Signed-off-by: aruokhai <joshuaaruokhaitech@gmail.com>
Signed-off-by: aruokhai <joshuaaruokhaitech@gmail.com> removed todo Signed-off-by: aruokhai <joshuaaruokhaitech@gmail.com> added broader unit test
4ce7c8e to
4f2d7a8
Compare
mariocynicys
left a comment
There was a problem hiding this comment.
Thanks! I think this is @ final stages.
Left some suggestions/refactors inline.
| if locator_and_userid.is_some() { | ||
| sql.push_str(" AND a.locator=(?1)"); | ||
| } | ||
|
|
||
| // If a user_id is passed, filter even more. | ||
| if locator_and_userid.is_some_and(|inner| inner.1.is_some()) { | ||
| sql.push_str(" AND a.user_id=(?2)"); | ||
| } |
There was a problem hiding this comment.
| if locator_and_userid.is_some() { | |
| sql.push_str(" AND a.locator=(?1)"); | |
| } | |
| // If a user_id is passed, filter even more. | |
| if locator_and_userid.is_some_and(|inner| inner.1.is_some()) { | |
| sql.push_str(" AND a.user_id=(?2)"); | |
| } | |
| if let Some((locator, optional_userid)) = locator_and_userid { | |
| sql.push_str(" AND a.locator=(?1)"); | |
| query_args.push(locator.to_vec()); | |
| if let Some(user_id) = optional_userid { | |
| sql.push_str(" AND a.user_id=(?2)"); | |
| query_args.push(user_id.to_vec()); | |
| } | |
| } |
There was a problem hiding this comment.
I think this statement let mut stmt = self.connection.prepare(&sql).unwrap(); would prevent the addition of query_args.push(locator.to_vec()); . I believe only after the initialisation of the stmt variable can be query args be added , which also takes arrays as its parameters. Also the intial changes was made this way, in which i mean joined
if let Some((_, user_id)) = locator_and_userid {
sql.push_str(" AND a.locator=(?1)");
if user_id.is_some() {
sql.push_str(" AND a.user_id=(?2)");
}
};
in which Sergio recommended i split to make it cleaner.
There was a problem hiding this comment.
Yup, this actually wouldn't work since stmt.query(...) won't accept a rust vector. I found this extension which allows preparing a statement with vector as args, but it's not worth the hustle. I only suggested this to not use the match below but it's not bad anyway.
Regarding nested checks, splitting the checks up in different lines makes sense when the method's args are Option<Locator> and Option<UserId>, because then we would add the appropriate filters without thinking about the dependency between them (we shouldn't nest the checks in this case).
But we went with the Option<(Locator, Option<UserId>)> route, in which there is a dependency between the locator and the user id (locator has to exist for user id to exist), so it makes more sense have the check for user id nested inside.
4f2d7a8 to
122deaf
Compare
122deaf to
e7cbc32
Compare
mariocynicys
left a comment
There was a problem hiding this comment.
Thanks!
Only one request from my side.
Looks good otherwise.
| let user_id = get_random_user_id().to_vec(); | ||
| let locator = get_random_locator().to_vec(); | ||
| let response = internal_api | ||
| .get_appointments(Request::new(msgs::GetAppointmentsRequest { | ||
| locator, | ||
| user_id: Some(user_id), | ||
| })) |
| let random_number = 4 * i + 7; | ||
| let appointments_to_create = random_number; |
There was a problem hiding this comment.
That's indeed way more readable, thanks!
1f152b1 to
be0b6f2
Compare
be0b6f2 to
ca497ee
Compare
|
Looks like this may be mergeable (?). Planing to give it a last look and merge if so. Needs rebase now that everything is green again |
Objective
Ensure locators are returned instead of uuid's under appointments section when user details are fetched through the cli using the getuser command.
Problem
locatoris an appropriate identifier for appointments in the Bolt13 specification draft, which is also being used in thegetappointmentscli command , but in thegetusercli command uuid is being used which can be confusing . The solution is ensuregetusercli command makes use oflocatorand notuuid.Changes
get_user_infofunction to make use of locator and not uuid when returning user appointments info.get_usertest to reflect the change from uuid to locator.Scope Of Change
This is a non critical change, as it only affects the CLI.
closes #229