Skip to content

Commit

Permalink
First timer tag script (publiclab#4878)
Browse files Browse the repository at this point in the history
* First timer tag script

* migration for attaching first-time-poster

* change migration bump version to 5.1

* Update schema.rb.example
  • Loading branch information
cesswairimu authored and icarito committed Apr 9, 2019
1 parent bb5feab commit 8a1e487
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions db/migrate/20190301075323_add_first_tag_poster.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class AddFirstTagPoster < ActiveRecord::Migration[5.1]
def find_and_update
User.joins(:node).where('node.status = ?', 1).each do |user|
if user.nodes.present?
node = user.nodes.first
node.add_tag('first-time-post', user)
end
end
end

def up
find_and_update
end
end
2 changes: 1 addition & 1 deletion db/schema.rb.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_01_04_173959) do
ActiveRecord::Schema.define(version: 2019_03_01_075323) do

create_table "answer_selections", force: true do |t|
t.integer "user_id"
Expand Down

0 comments on commit 8a1e487

Please sign in to comment.