运维现在需要测定数据库的更新频率,数据使用爬虫爬取。
返回两个 JSON 文件,代表着一个月前的数据和现在的数据。
例子:
// a month ago
{"id": "111","name": "kirisame", "age": 16, "info": "I like Mushroom"}
{"id": "222","name": "reimu", "age": 16, "info": "I like Sleep"}
{"id": "333","name": "Scarlet", "age": 300, "info": "I don't like sunshine"}
{"id": "111","name": "kirisame", "age": 16, "info": "I like Mushroom and fireworks"}
{"id": "222","name": "reimu", "age": 16, "info": "I like Sleep and money"}
{"id": "333","name": "Scarlet", "age": 300, "info": "I don't like sunshine"}
目前需要统计有多少个条目是和之前不同的,以此确定更新频率
分别读入两个文件,并用数组存储
def conver_array_hash(input_array)
hash = {}
input_array.each do |element|
hash[element[:id].to_sym] = element.except(:id)
end
hash
end
如果有更好的解决方法,欢迎大家一起讨论。