Revision | 19993864e78e6e41dfdfc6c81fccfda3d972d6b1 (tree) |
---|---|
Zeit | 2020-08-31 05:04:59 |
Autor | HMML <hmml3939@gmai...> |
Commiter | HMML |
Fix feed id as digest.
@@ -17,7 +17,7 @@ class JmaFeed < ApplicationRecord | ||
17 | 17 | Rails.logger.info "Fetching success." |
18 | 18 | doc = Nokogiri::XML(b) |
19 | 19 | doc.remove_namespaces! |
20 | - fid = doc.xpath("/feed/id").text | |
20 | + fid = Digest::SHA2.hexdigest b | |
21 | 21 | obj = find_by(feed_id: fid) |
22 | 22 | if obj |
23 | 23 | Rails.logger.info "Jma feed id=#{fid} found. Skip creation and return existing entry." |
@@ -29,7 +29,7 @@ class JmaFeed < ApplicationRecord | ||
29 | 29 | def body=(xml) |
30 | 30 | self[:body] = xml |
31 | 31 | self.feed_time = Time.parse(xml_doc.xpath("/feed/updated").text) |
32 | - self.feed_id = xml_doc.xpath("/feed/id").text | |
32 | + self.feed_id = Digest::SHA2.hexdigest(xml) | |
33 | 33 | self.last_process_id = nil |
34 | 34 | end |
35 | 35 |