Skip to content

Commit

Permalink
Extract buildtime marshalling to its own method
Browse files Browse the repository at this point in the history
Lazy marshalling buildtime just when its needed
  • Loading branch information
vpereira committed Jan 4, 2022
1 parent 02cbd0c commit 45e598f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/api/app/models/binary_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,23 @@ def to_axml(_opts = {})
end

def identical_to?(binary_hash)
# handle nil/NULL case
buildtime = binary_hash['buildtime'].blank? ? nil : Time.strptime(binary_hash['buildtime'].to_s, '%s')

# We ignore not set binary_id in db because it got introduced later
# we must not touch the modification time in that case
binary_disturl == binary_hash['disturl'] &&
binary_supportstatus == binary_hash['supportstatus'] &&
(binary_id.nil? || binary_id == binary_hash['binaryid']) &&
binary_buildtime == buildtime
binary_buildtime == binary_hash_build_time(binary_hash)
end

private

def binary_hash_build_time(binary_hash)
# handle nil/NULL case
return if binary_hash['buildtime'].blank?

Time.strptime(binary_hash['buildtime'].to_s, '%s')
end

def product_medium
repository.product_medium.find_by(name: medium)
end
Expand Down

0 comments on commit 45e598f

Please sign in to comment.