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.
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.
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.
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.