lib/ayadn/nicerank.rb in ayadn-3.0 vs lib/ayadn/nicerank.rb in ayadn-4.0

- old
+ new

@@ -21,12 +21,12 @@ # if absent, decode + save to dic + cache in store # if present, save to dic from store (and count hits for debug) def get_ranks stream begin user_ids, niceranks = [], {} - stream['data'].each do |post| - id = post['user']['id'] + stream.posts.each do |post| + id = post.user.id user_ids << id if @store[id].nil? end user_ids.uniq! got = CNX.get "#{@url}#{user_ids.join(',')}" unless user_ids.empty? if got.nil? || got == "" @@ -45,11 +45,11 @@ end parsed['data'].each do |obj| res = @store[obj['user_id']] if res.nil? - obj['is_human'] == true ? is_human = 1 : is_human = 0 + obj['is_human'] ? is_human = 1 : is_human = 0 content = { rank: obj['rank'], is_human: is_human } @store[obj['user_id']] = content @@ -59,25 +59,25 @@ niceranks[obj['user_id']] = res end end - @posts += stream['data'].size + @posts += stream.posts.size @ids += user_ids.size - if Settings.options[:timeline][:debug] == true + if Settings.options.timeline.debug deb = "\n" deb << "+ NICERANK\n" deb << "* t#{Time.now.to_i}\n" - deb << "Posts:\t\t#{stream['data'].size}\n" + deb << "Posts:\t\t#{stream.posts.size}\n" deb << "Requested NR:\t#{user_ids.size}\n" deb << "* TOTALS\n" deb << "Posts:\t\t#{@posts}\n" deb << "Fetched ranks:\t#{@ids}\n" deb << "DB hits:\t#{@hits}\n" deb << "Uniques:\t#{@store.count}\n" deb << "\n" - puts deb.color(Settings.options[:colors][:debug]) + puts deb.color(Settings.options.colors.debug) Logs.rec.debug "NICERANK/POSTS: #{@posts}" Logs.rec.debug "NICERANK/NR CALLS: #{@ids}" Logs.rec.debug "NICERANK/CACHE HITS: #{@hits}" Logs.rec.debug "NICERANK/CACHED IDS: #{@store.count}" end