Remove UserFirst for mention since it can be retrieved elsewhere

This commit is contained in:
Robin Ward 2016-04-06 14:01:11 -04:00
parent b1d04412db
commit 5866f0df18
5 changed files with 21 additions and 18 deletions

View file

@ -1,7 +1,9 @@
class UserFirst < ActiveRecord::Base
def self.types
@types ||= Enum.new(used_emoji: 1, mentioned_user: 2)
@types ||= Enum.new(used_emoji: 1,
mentioned_user: 2 #unused now
)
end
def self.create_for(user_id, type, post_id=nil)

View file

@ -365,10 +365,10 @@ Badge.seed do |b|
b.multiple_grant = false
b.target_posts = true
b.show_posts = true
b.query = BadgeQueries.has_user_first(:mentioned_user)
b.query = BadgeQueries::FirstMention
b.badge_grouping_id = BadgeGrouping::GettingStarted
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
b.trigger = Badge::Trigger::PostProcessed
b.trigger = Badge::Trigger::PostRevision
b.system = true
end

View file

@ -134,6 +134,22 @@ SQL
HAVING COUNT(p.id) > 0
SQL
FirstMention = <<-SQL
SELECT acting_user_id AS user_id, min(target_post_id) AS post_id, min(p.created_at) AS granted_at
FROM user_actions
JOIN posts p ON p.id = target_post_id
JOIN topics t ON t.id = topic_id
JOIN categories c on c.id = category_id
WHERE action_type = 7
AND NOT read_restricted
AND p.deleted_at IS NULL
AND t.deleted_at IS NULL
AND t.visible
AND t.archetype <> 'private_message'
AND (:backfill OR p.id IN (:post_ids))
GROUP BY acting_user_id
SQL
def self.invite_badge(count,trust_level)
"
SELECT u.id user_id, current_timestamp granted_at

View file

@ -45,10 +45,6 @@ class CookedPostProcessor
created |= UserFirst.create_for(@post.user_id, :used_emoji, @post.id)
end
if @doc.css("span.mention, a.mention").size > 0
created |= UserFirst.create_for(@post.user_id, :mentioned_user, @post.id)
end
if created
BadgeGranter.queue_badge_grant(Badge::Trigger::PostProcessed, user: @post.user)
end

View file

@ -31,17 +31,6 @@ describe UserFirst do
end
context 'mentioning' do
let(:codinghorror) { Fabricate(:codinghorror) }
it "creates one the first time a user mentions another" do
post = PostCreator.create(user, title: "gonna mention another user", raw: "what is up @codinghorror?")
uf = UserFirst.where(user_id: user.id, first_type: UserFirst.types[:mentioned_user]).first
expect(uf).to be_present
expect(uf.post_id).to eq(post.id)
end
end
context "privacy" do
let(:codinghorror) { Fabricate(:codinghorror) }