correct linting

This commit is contained in:
Sam 2018-06-29 16:04:38 +10:00
parent 8f43872bff
commit f4f95ce956
1 changed files with 19 additions and 20 deletions

View File

@ -101,7 +101,6 @@ EOM
break if users.empty? break if users.empty?
last_user_id = users[-1]["id"] last_user_id = users[-1]["id"]
before = users.size
users.reject! { |u| @lookup.user_already_imported?(u["id"].to_i) } users.reject! { |u| @lookup.user_already_imported?(u["id"].to_i) }
create_users(users, total: user_count, offset: offset) do |user| create_users(users, total: user_count, offset: offset) do |user|
@ -233,8 +232,8 @@ EOM
end end
remaining = max_length remaining = max_length
if word_lengths.inject(0) {|sum, (k,v)| sum + v } > remaining if word_lengths.inject(0) { |sum, (_, v)| sum + v } > remaining
word_lengths = Hash[word_lengths.sort {|x,y| y[1] <=> x[1]}] word_lengths = Hash[word_lengths.sort { |x, y| y[1] <=> x[1] }]
word_lengths.each do |idx, word_length| word_lengths.each do |idx, word_length|
if remaining > 0 if remaining > 0
remaining -= word_length remaining -= word_length
@ -277,7 +276,7 @@ EOM
create_posts(posts, total: post_count, offset: offset) do |post| create_posts(posts, total: post_count, offset: offset) do |post|
begin begin
raw = preprocess_post_raw(post["content"]) raw = preprocess_post_raw(post["content"])
rescue => e rescue => e
puts e.message puts e.message
end end
@ -305,16 +304,16 @@ EOM
SELECT postid, userid SELECT postid, userid
FROM #{TABLE_PREFIX}uservotes u FROM #{TABLE_PREFIX}uservotes u
WHERE u.vote=1 WHERE u.vote=1
SQL SQL
).to_a ).to_a
likes.each do |like| likes.each do |like|
post = Post.find_by(id: post_id_from_imported_post_id("thread-#{like['postid']}")) post = Post.find_by(id: post_id_from_imported_post_id("thread-#{like['postid']}"))
user = User.find_by(id: user_id_from_imported_user_id(like["userid"])) user = User.find_by(id: user_id_from_imported_user_id(like["userid"]))
begin begin
PostAction.act(user, post, 2) if user && post PostAction.act(user, post, 2) if user && post
rescue => e rescue => e
debugger puts "error acting on post #{e}"
end end
end end
end end
@ -402,22 +401,22 @@ EOM
end end
# [FONT=blah] and [COLOR=blah] # [FONT=blah] and [COLOR=blah]
raw.gsub! /\[FONT=.*?\](.*?)\[\/FONT\]/im, '\1' raw.gsub!(/\[FONT=.*?\](.*?)\[\/FONT\]/im, '\1')
raw.gsub! /\[COLOR=.*?\](.*?)\[\/COLOR\]/im, '\1' raw.gsub!(/\[COLOR=.*?\](.*?)\[\/COLOR\]/im, '\1')
raw.gsub! /\[COLOR=#.*?\](.*?)\[\/COLOR\]/im, '\1' raw.gsub!(/\[COLOR=#.*?\](.*?)\[\/COLOR\]/im, '\1')
raw.gsub! /\[SIZE=.*?\](.*?)\[\/SIZE\]/im, '\1' raw.gsub!(/\[SIZE=.*?\](.*?)\[\/SIZE\]/im, '\1')
raw.gsub! /\[h=.*?\](.*?)\[\/h\]/im, '\1' raw.gsub!(/\[h=.*?\](.*?)\[\/h\]/im, '\1')
# [CENTER]...[/CENTER] # [CENTER]...[/CENTER]
raw.gsub! /\[CENTER\](.*?)\[\/CENTER\]/im, '\1' raw.gsub!(/\[CENTER\](.*?)\[\/CENTER\]/im, '\1')
# [INDENT]...[/INDENT] # [INDENT]...[/INDENT]
raw.gsub! /\[INDENT\](.*?)\[\/INDENT\]/im, '\1' raw.gsub!(/\[INDENT\](.*?)\[\/INDENT\]/im, '\1')
raw.gsub! /\[TABLE\](.*?)\[\/TABLE\]/im, '\1' raw.gsub!(/\[TABLE\](.*?)\[\/TABLE\]/im, '\1')
raw.gsub! /\[TR\](.*?)\[\/TR\]/im, '\1' raw.gsub!(/\[TR\](.*?)\[\/TR\]/im, '\1')
raw.gsub! /\[TD\](.*?)\[\/TD\]/im, '\1' raw.gsub!(/\[TD\](.*?)\[\/TD\]/im, '\1')
raw.gsub! /\[TD="?.*?"?\](.*?)\[\/TD\]/im, '\1' raw.gsub!(/\[TD="?.*?"?\](.*?)\[\/TD\]/im, '\1')
# [QUOTE]...[/QUOTE] # [QUOTE]...[/QUOTE]
raw.gsub!(/\[quote\](.+?)\[\/quote\]/im) { |quote| raw.gsub!(/\[quote\](.+?)\[\/quote\]/im) { |quote|