aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorrhenium <re4k@re4k.info>2013-05-20 23:56:26 +0900
committerrhenium <re4k@re4k.info>2013-05-20 23:56:26 +0900
commit43b82c0d5deb0587365d98be599ab03a50c79fa4 (patch)
tree9579d89477584834e428e51436e603464bb07054 /app
parent0830b385775b17479100021e956fa14df8dcb4f9 (diff)
downloadaclog-43b82c0d5deb0587365d98be599ab03a50c79fa4.tar.gz
remove stolen_tweet model
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/_tweets.css.sass5
-rw-r--r--app/controllers/report_controller.rb51
-rw-r--r--app/models/stolen_tweet.rb14
-rw-r--r--app/models/tweet.rb3
-rw-r--r--app/views/report/index.html.haml34
-rw-r--r--app/views/report/tweet.html.haml2
-rw-r--r--app/views/tweets/_tweet.html.haml5
-rw-r--r--app/views/tweets/_tweets.html.haml2
8 files changed, 19 insertions, 97 deletions
diff --git a/app/assets/stylesheets/_tweets.css.sass b/app/assets/stylesheets/_tweets.css.sass
index d86c427..af90be0 100644
--- a/app/assets/stylesheets/_tweets.css.sass
+++ b/app/assets/stylesheets/_tweets.css.sass
@@ -64,11 +64,6 @@
.created_at
:display block
:float left
- .copied
- :float left
- :margin-left 10px
- a
- :color #ff6666
.source
:display block
:float right
diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb
index 8483050..2b1f071 100644
--- a/app/controllers/report_controller.rb
+++ b/app/controllers/report_controller.rb
@@ -5,43 +5,6 @@ class ReportController < ApplicationController
# いんでっくす
end
- def tweet
- original_id, tweet_id = [get_tweet_id(params[:tweet_id_0]), get_tweet_id(params[:tweet_id_1])].sort
-
- raise ActionController::BadRequest unless original_id && tweet_id
-
- tweet = Tweet.find(tweet_id)
- if tweet
- original = Tweet.find(original_id)
- unless original
- add_issue_stolen(false, tweet_id, original_id)
- return
- # 記録されてなかった
- # どうしよう。どのアカウントのAPIを使うか?
- end
-
- if original_id < tweet_id
- if iscopy?(original, tweet)
- # 両方記録されており、パクリツイート
- logger.debug("pakuri!!!")
- StolenTweet.register(original, tweet)
- add_issue_stolen(true, tweet_id, original_id)
- else
- # パクリツイートではない(違う)
- logger.debug("not pakuri!")
- add_issue_stolen(false, tweet_id, original_id)
- end
- else
- # パクリツイートではない(新しい)
- logger.debug("not old, new")
- end
- else
- # 記録されてないけど?
- # 403
- logger.debug("not recorded?")
- end
- end
-
private
def get_tweet_id(str)
case str
@@ -49,18 +12,4 @@ class ReportController < ApplicationController
$1.to_i
end
end
-
- def iscopy?(original, tweet)
- textr = -> str do
- str.gsub(/([  \t\n\r\f]|[\x20\x00-\x20\x0f])/, "")
- end
-
- textr.call(original.text) == textr.call(tweet.text)
- end
-
- def add_issue_stolen(resolved, tweet_id, original_id)
- Issue.register(Aclog::Constants::IssueType::TWEET_STOLEN,
- resolved ? Aclog::Constants::IssueStatus::RESOLVED : Aclog::Constants::IssueStatus::PENDING,
- {tweet_id: tweet_id, original_id: original_id})
- end
end
diff --git a/app/models/stolen_tweet.rb b/app/models/stolen_tweet.rb
deleted file mode 100644
index aa2d01d..0000000
--- a/app/models/stolen_tweet.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class StolenTweet < ActiveRecord::Base
- belongs_to :tweet
- belongs_to :original, class_name: :Tweet
-
- def self.register(original_tweet, the_tweet)
- begin
- create!(tweet_id: the_tweet.id, original_id: original_tweet.id)
- rescue ActiveRecord::RecordNotUnique
- logger.error("Duplicate Stolen Info")
- rescue
- logger.error("Unknown error while inserting stolen info: #{$!}/#{$@}")
- end
- end
-end
diff --git a/app/models/tweet.rb b/app/models/tweet.rb
index 5978d26..e8fe41b 100644
--- a/app/models/tweet.rb
+++ b/app/models/tweet.rb
@@ -2,15 +2,12 @@ class Tweet < ActiveRecord::Base
belongs_to :user
has_many :favorites, -> { order("favorites.id") }, dependent: :delete_all
has_many :retweets, -> { order("retweets.id") }, dependent: :delete_all
- has_one :stolen_tweet, ->{ includes(:original) }, dependent: :delete
has_many :favoriters, -> {order("favorites.id") }, through: :favorites, source: :user
has_many :retweeters, -> { order("retweets.id") }, through: :retweets, source: :user
- has_one :original, through: :stolen_tweet, source: :original
scope :recent, -> { where("tweets.tweeted_at > ?", Time.zone.now - 3.days) }
scope :reacted, -> {where("tweets.favorites_count > 0 OR tweets.retweets_count > 0") }
- scope :original, -> { includes(:stolen_tweet).where(stolen_tweets: {tweet_id: nil}) }
scope :not_protected, -> { includes(:user).where(users: {protected: false}) }
scope :max_id, -> id { where("tweets.id <= ?", id.to_i) if id }
scope :since_id, -> id { where("tweets.id > ?", id.to_i) if id }
diff --git a/app/views/report/index.html.haml b/app/views/report/index.html.haml
index 2e213e7..1ed4ca3 100644
--- a/app/views/report/index.html.haml
+++ b/app/views/report/index.html.haml
@@ -1,17 +1,17 @@
-%h1 パクリツイートの報告
-%p
- まだ準備中です。全く同一のツイートのみしか対応しておりません。
-%hr
-= form_tag({:controller => "report", :action => "tweet"}, {:method => :post, :class => "form-horizontal"}) do
- .control-group
- = label_tag "tweet_id_0", "ツイート1", :class => "control-label"
- .controls
- = text_field_tag "tweet_id_0", params[:tweet_id_0], :style => "width: 100%"
- .control-group
- = label_tag "tweet_id_1", "ツイート2", :class => "control-label"
- .controls
- = text_field_tag "tweet_id_1", params[:tweet_id_1], :style => "width: 100%"
- .control-group
- .controls
- = submit_tag "送信", :name => nil, :class => "btn"
-
+/%h1 パクリツイートの報告
+/%p
+/ まだ準備中です。全く同一のツイートのみしか対応しておりません。
+/%hr
+/= form_tag({:controller => "report", :action => "tweet"}, {:method => :post, :class => "form-horizontal"}) do
+/ .control-group
+/ = label_tag "tweet_id_0", "ツイート1", :class => "control-label"
+/ .controls
+/ = text_field_tag "tweet_id_0", params[:tweet_id_0], :style => "width: 100%"
+/ .control-group
+/ = label_tag "tweet_id_1", "ツイート2", :class => "control-label"
+/ .controls
+/ = text_field_tag "tweet_id_1", params[:tweet_id_1], :style => "width: 100%"
+/ .control-group
+/ .controls
+/ = submit_tag "送信", :name => nil, :class => "btn"
+/
diff --git a/app/views/report/tweet.html.haml b/app/views/report/tweet.html.haml
deleted file mode 100644
index 4bd3987..0000000
--- a/app/views/report/tweet.html.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-%h1 パクリツイートの報告
-%p 報告ありがとうございました。
diff --git a/app/views/tweets/_tweet.html.haml b/app/views/tweets/_tweet.html.haml
index 44d6d88..8f6f4e8 100644
--- a/app/views/tweets/_tweet.html.haml
+++ b/app/views/tweets/_tweet.html.haml
@@ -14,7 +14,7 @@
.user
%span.nam= link_to tweet.user.name, user_best_path(tweet.user.screen_name)
%span.screen_name= link_to tweet.user.screen_name, user_best_path(tweet.user.screen_name)
- .text{class: tweet.stolen_tweet ? "quiet" : nil}
+ .text
- if authorized_to_show?(tweet.user)
= simple_format(format_tweet_text(tweet.text))
- else
@@ -28,9 +28,6 @@
- if params[:action] == "show" && user_truncated?(tweet)
%span.full
= link_to "full", params.merge(full: true)
- - if tweet.stolen_tweet
- %span.copied
- = link_to "original", tweet_path(tweet.original.id)
%span.source
= raw format_source_text(tweet.source)
.stats
diff --git a/app/views/tweets/_tweets.html.haml b/app/views/tweets/_tweets.html.haml
index 2ff4baa..9e9bc0e 100644
--- a/app/views/tweets/_tweets.html.haml
+++ b/app/views/tweets/_tweets.html.haml
@@ -1,7 +1,7 @@
- if params[:action] == "search"
= render partial: "search/search"
.tweets
- = render partial: "tweets/tweet", collection: @tweets.includes(:user).includes(:stolen_tweet), as: :tweet
+ = render partial: "tweets/tweet", collection: @tweets.includes(:user), as: :tweet
.loading
= image_tag "loading.gif", alt: "loading...", title: nil
.pagination