lib/ayadn/workers.rb in ayadn-2.0.12 vs lib/ayadn/workers.rb in ayadn-2.1

- old
+ new

@@ -109,48 +109,26 @@ def build_users_list(list, table, options = {}) users = at(list.map {|obj| obj[:username]}) ids = list.map {|obj| obj[:id].to_i} ranks = NiceRank.new.from_ids(ids) - indexed_ranks = {} - ranks.each do |r| - if r.empty? - indexed_ranks = false - break - else - indexed_ranks[r['user_id']] = r - end - end - table << ['USERNAME'.color(:red), 'NAME'.color(:red), 'POSTS'.color(:red), 'POSTS/DAY'.color(:red)] + table << ['USERNAME'.color(:red), 'NAME'.color(:red), 'POSTS'.color(:red)] table << :separator arr = [] if options[:username] list.sort_by! { |obj| obj[:username] } elsif options[:name] - list.sort_by! { |obj| obj[:name].downcase } + list.sort_by! { |obj| obj[:name].nil? ? "(no name)" : obj[:name].downcase } elsif options[:posts] list.sort_by! { |obj| [obj[:posts], obj[:username]] } end list.each do |obj| obj[:name] = "" if obj[:name].nil? - unless indexed_ranks == false - details = indexed_ranks[obj[:id].to_i] - if details['user']['posts_day'] == -1 - posts_day = 'ignored' - else - posts_day = details['user']['posts_day'].round(2).to_s - end - else - posts_day = 'unknown' - end obj[:username].length > 23 ? username = "#{obj[:username][0..20]}..." : username = obj[:username] obj[:name].length > 23 ? name = "#{obj[:name][0..20]}..." : name = obj[:name] - arr << [ "@#{username} ".color(Settings.options[:colors][:username]), "#{name.to_s.force_encoding('UTF-8')}", obj[:posts], posts_day ] + arr << [ "@#{username} ".color(Settings.options[:colors][:username]), "#{name.to_s.force_encoding('UTF-8')}", obj[:posts] ] end - if options[:posts_day] - arr.sort_by! { |obj| obj[3].to_f } - end if options[:reverse] arr.reverse! end if Settings.options[:formats][:list][:reverse] == true arr.reverse! @@ -170,12 +148,12 @@ posts = {} data.each.with_index(1) do |post, index| unless Settings.global[:force] == true if Settings.options[:blacklist][:active] == true if Databases.is_in_blacklist?('client', post['source']['name'].downcase) - Debug.skipped({source: post['source']['name']}) - next + Debug.skipped({source: post['source']['name']}) + next end end end unless Settings.global[:force] == true if Settings.options[:blacklist][:active] == true @@ -229,15 +207,13 @@ # create custom objects from ADN response if niceranks[post['user']['id'].to_i] rank = niceranks[post['user']['id'].to_i][:rank] is_human = niceranks[post['user']['id'].to_i][:is_human] - real_person = niceranks[post['user']['id'].to_i][:real_person] else rank = false is_human = 'unknown' - real_person = 'unknown' end if post['user'].has_key?('name') name = post['user']['name'].to_s.force_encoding("UTF-8") else @@ -253,10 +229,9 @@ thread_id: post['thread_id'], username: post['user']['username'], user_id: post['user']['id'].to_i, nicerank: rank, is_human: is_human, - real_person: real_person, handle: "@#{post['user']['username']}", type: post['user']['type'], date: parsed_time(post['created_at']), date_short: parsed_time_short(post['created_at']), you_starred: post['you_starred'],