Closed netsensei closed 12 months ago
@netsensei why would that make it simpler? In that case you would have to guess/know what the method will be doing. Plus you would not be able use the method if you would just have a string value at your disposal.
@nicolasfranck
[]string{}
Additionally, storing all id's as an array of key/value objects makes it far harder to do lookups. Way easier is a hashmap of arrays. With each array being identified by its type:
{
"historic_ugent_id": [ 111, 222, 333 ],
"uzgent_id": [ 444, 555, 666]
}
If we store the id's like this, we can just fetch the corresponding array and use functions like sort.Search or the newer slices.BinarySearch to do lookups; instead of iterating over a range.
This issue might become deprecated / stale due to #40. Review #40 first before working on this one.
@netsensei I see indeed in my code that historic ugent id is required when fetching data from GISMO, because any linking would be impossible otherwise. See https://github.com/ugent-library/people-service/blob/main/subscribers/gismo_person.go#L72 where it returns an error for that incoming message
Story
The current code loops over the
OtherId
property, and then tries to query the database via therepo.GetPersonByOtherId
method. At the same time, it also performs a check whether or not the id is ahistoric_ugent_id
.It's a lot of ceremony which could be simplified. Moreover, there's room to make the
repo.GetPersonByOtherId
do more of the heavy lifting.Success criteria
historic_ugent_id
Screenshots
n/a
Implementation suggestion
np.OtherID
is a slice ofIdRef
structs. Looping across it and fetching the id could / should become part of therepo.GetPersonByOtherId
method. This would simplify the code while importing students to this:Note how the entire slice of id's is passed to the function, instead of a single
historic_ugent_id
id.Automatic testing scenario
n/a
Additional information
This issue might be deprecated by #40
Related issues
31