Skip to content

Commit

Permalink
symbolize keys in attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed Jun 19, 2023
1 parent 2caba53 commit 2020f92
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/bad_pigeon/models/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,27 @@ def urls
def attrs
user = json['core']['user_results']['result']

fields = legacy.merge({
fields = {
id: id,
source: json['source'],
text: text,
truncated: false,
}).reject { |k, v| ['retweeted_status_result', 'quoted_status_result'].include?(k) }
}

user_fields = user['legacy'].merge({
legacy.each do |k, v|
next if ['retweeted_status_result', 'quoted_status_result'].include?(k)
fields[k.to_sym] = v
end

user_fields = {
id: user['rest_id'].to_i,
id_str: user['rest_id'],
}).reject { |k, v| k =~ /^profile_\w+_extensions/ }
}

user['legacy'].each do |k, v|
next if k =~ /^profile_\w+_extensions/
user_fields[k.to_sym] = v
end

fields[:user] = StrictHash[user_fields]

Expand Down

0 comments on commit 2020f92

Please sign in to comment.