-
Notifications
You must be signed in to change notification settings - Fork 6
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
[#2931] Update company data on login #1524
Conversation
5b7cd3a
to
c38c7b2
Compare
c38c7b2
to
2a5012b
Compare
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.
Discussed off-line, we'll do this PR first before the selection screen skipper.
39d3cc6
to
557a8f2
Compare
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.
A few issues to do with vestiging/kvk pairs, but maybe we can tackle that later, let's discuss on monday.
fields = { | ||
"company_name": vestiging.get("naam"), | ||
"city": binnenlandsadres.get("plaats"), | ||
"postcode": binnenlandsadres.get("postcode"), | ||
"street": binnenlandsadres.get("straatnaam"), | ||
"housenumber": binnenlandsadres.get("huisnummer"), | ||
} | ||
|
||
for field, new_value in fields.items(): | ||
current_value = getattr(user, field, None) | ||
if new_value and new_value != current_value: | ||
setattr(user, field, new_value) |
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 am not sure these checks have added value: the kvk is the source of truth here I think, we can just overwrite all the fields no (assuming there's a binnenlandsAdres
)?
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 wouldn't be enough to check for the presence of binnenlandAdres
, because each field in binnenlandAdres
is potentially null and would have to be checked as well. Some of the fields may actually be required (an address without at least city name would be strange), but I don't know which ones (the spec doesn't say). I find it simpler therefore to get
the values from the dict
and check if they are different from what's stored on the user.
src/open_inwoner/kvk/client.py
Outdated
@@ -122,6 +125,24 @@ def get_all_company_branches(self, kvk: str, **kwargs) -> list[dict | None]: | |||
|
|||
return branches | |||
|
|||
@cache("vestigingsnummer") |
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.
@cache("vestigingsnummer") | |
@cache("vestiging:{vestigingsnummer}") |
I am a bit concerned by the **kwargs
though, I don't think you can currently add that as a parameter in the cache key, but that means you'll always get a cached result even if kwargs
changes. Is there any way to actually name the kwargs
?
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.
That's not a use case because the only kwarg
passed on is the vestigingsnummer
. The code is misleading though; kwargs.update
suggests that there is other stuff in there. I changed the function signature + body to make clear that we're only passing on the vestigingsnummer
.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1524 +/- ##
===========================================
+ Coverage 94.25% 94.27% +0.01%
===========================================
Files 1068 1071 +3
Lines 40466 40597 +131
===========================================
+ Hits 38141 38271 +130
- Misses 2325 2326 +1 ☔ View full report in Codecov by Sentry. |
557a8f2
to
c083269
Compare
At the time of opening this PR we are not able to support separate updates for users with the same |
Taiga: https://taiga.maykinmedia.nl/project/open-inwoner/task/2931