array hash 的使用
对抓取的数据进行去重,取最新的数据,hash array的使用
def get_result_hash_for_lueluelue_result_sets
#对数据进行确认,无论怎么进行修改用户的列的id是不会变化的,只会随着修改时间进行增加数据,后者取代前者
temp_hash = {
"DOT" => '70476024645083539914866120258902002044389822943217047784978736702069848167247',
"ETH" => '77201932000687051421874801696342701541816747065578039511607412978553675800564',
"BTC" => '105640063387051144792550451261497903460441457163918809975891088748950929433065',
"IPFS" => '109444936916467285377972213791356162468265265799777646334604004948560489512394',
"EMAIL" => '50101170924916254227885891120695131387383646459470231890507002477095918146885',
"NOTICE" => '31727182724036554852371956750201584211517824919105130426252222689897810866214',
"TWITTER_COM" => '11710898932869919534375710263824782355793106641910621555855312720536896315685',
"GITHUB" => '102576668688838416847107385580607409742813859881781246507337882384803237069874',
"TWITTER_URL" => '23368862207911262087635895660209245090921614897479706708279561601163163997039',
"AVATAR" => '98593787308120460448886304499976840768878166060614499815391824681489593998420',
"C_NAME" => '69611991539268867131500085835156593536513732089793432642972060827780580969128'
}
result_hash = {}
#定义一个空的hash,进行结果的提取,获取需要的数据
temp_hash.map { |key, value|
#抓取用户修改的所有数据
dot_value = []
#定义一个空的数组,把id相同的数据进行提取,取最后一个(也就是最新的数据)
result_sets.each { |e|
if e['keyHash'] == value
dot_value << e
puts dot_value
puts key
puts value
puts e['keyHash']
#数据打印后,后续不需要的话,可以删除打印的数据,不打印数据
end
if dot_value.last == nil
hash = result_hash.store(key, '')
else
hash = result_hash.store(key, dot_value.last)
end
}
}
puts "=== temp_hash : #{temp_hash}"
puts "=== result_hash: #{result_hash}"
return result_hash
end
后台打印的数据

最终的结果:
