-
Notifications
You must be signed in to change notification settings - Fork 0
Find the RfidTag if there is a mismatch #22
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
base: master
Are you sure you want to change the base?
Conversation
|
This commit should solve errors like https://appsignal.com/evopark-gmbh/sites/5769516e01925b18d51d8bf9/incidents/847/samples/5ad85a7acbf15e0319aa1138. |
Sometimes requests come that have a different `MediaKey` for a certain tag then we have stored in the `CardAccountMapping`. This commit adds the functionality to find the tag by searching its UID.
5500208 to
430f331
Compare
| @@ -0,0 +1,58 @@ | |||
| # frozen_string_literal: true | |||
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.
This file should either be moved into ruby-utils (so that it's available in all repositories) or reside in spec/dummy. Otherwise we have a very unfortunate code duplication here.
| def rfid_tag_information | ||
| rfid_tag_id = garage_system.card_account_mappings.find_by(card_key: params[:Media][:MediaKey]).rfid_tag_id | ||
| rfid_tag_id = garage_system.card_account_mappings.find_by(card_key: params[:Media][:MediaKey])&.rfid_tag_id || | ||
| RfidTag.find_by(uid: RfidTid.new(params[:DriveIn][:Media][:MediaId]).to_s).id |
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.
The problem with this approach is that the specification doesn't guarantee that this will be present or that the media ID will be an RFID TID. Ideally, when running the sync, the card and customer account mappings are only soft-deleted (via acts_as_paranoid) and when finding them here, we then use the with_deleted scope. That way we don't need to make any assumptions about the request.
| # frozen_string_literal: true | ||
| require 'rfid_tid' | ||
|
|
||
| RSpec.describe RfidTid do |
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.
same as above: the spec shouldn't be duplicated either.
Sometimes requests come that have a different
MediaKeyfor a certain tag then we have storedin the
CardAccountMapping.This commit adds the functionality to find the tag
by searching its UID.