Skip to content

Commit

Permalink
Install Merit, Fix broken paths
Browse files Browse the repository at this point in the history
  • Loading branch information
scaffeinate committed Jun 14, 2017
1 parent 7bca363 commit 565382e
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ GEM
after_commit_action (1.0.1)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
ambry (1.0.0)
arel (7.1.4)
auto_html (1.6.4)
redcarpet (~> 3.1)
Expand Down Expand Up @@ -276,6 +277,8 @@ GEM
lumberjack (1.0.11)
mail (2.6.5)
mime-types (>= 1.16, < 4)
merit (2.4.0)
ambry (~> 1.0.0)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
Expand Down Expand Up @@ -433,6 +436,7 @@ DEPENDENCIES
jquery-atwho-rails
jquery-rails
letter_opener
merit
pg
populator
public_activity
Expand Down
1 change: 0 additions & 1 deletion app/models/Merit

This file was deleted.

7 changes: 3 additions & 4 deletions app/models/badge_rules.rb → app/models/merit/badge_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class BadgeRules
include Merit::BadgeRulesMethods

def initialize

grant_on 'comments#create', badge: 'Jr.Critics', temporary: true, to: :user do |comment|
comment.user.comments.count >= 2
end
comment.user.comments.count >= 2
end
end

# If it creates user, grant badge
# Should be "current_user" after registration for badge to be granted.
Expand All @@ -49,6 +49,5 @@ def initialize
#
# user.name.length > 4
# end
end
end
end
12 changes: 5 additions & 7 deletions app/models/point_rules.rb → app/models/merit/point_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ class PointRules
include Merit::PointRulesMethods

def initialize
score 2, on: 'comments#create', to: [:user]
score 1, on: 'posts#upvote', to: [:user]
score 4, on: 'posts#create', to: [:user]

score 1, on: 'comments#create', to: [:user]


score 5, on: 'post#upvote', to: [:user]


score 3, on: 'post#create', to: [:user]
score 3, on: 'events#create', to: [:user]
score 1, on: 'events#upvote', to: [:user]
# score 10, :on => 'users#create' do |user|
# user.bio.present?
# end
Expand Down
31 changes: 31 additions & 0 deletions app/models/merit/rank_rules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Be sure to restart your server when you modify this file.
#
# 5 stars is a common ranking use case. They are not given at specified
# actions like badges, you should define a cron job to test if ranks are to be
# granted.
#
# +set_rank+ accepts:
# * :+level+ ranking level (greater is better)
# * :+to+ model or scope to check if new rankings apply
# * :+level_name+ attribute name (default is empty and results in 'level'
# attribute, if set it's appended like 'level_#{level_name}')

module Merit
class RankRules
include Merit::RankRulesMethods

def initialize
# set_rank :level => 1, :to => Commiter.active do |commiter|
# commiter.repositories.count > 1 && commiter.followers >= 10
# end
#
# set_rank :level => 2, :to => Commiter.active do |commiter|
# commiter.branches.count > 1 && commiter.followers >= 10
# end
#
# set_rank :level => 3, :to => Commiter.active do |commiter|
# commiter.branches.count > 2 && commiter.followers >= 20
# end
end
end
end
6 changes: 6 additions & 0 deletions db/migrate/20170613183107_add_merit_fields_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddMeritFieldsToUsers < ActiveRecord::Migration
def change
add_column :users, :sash_id, :integer
add_column :users, :level, :integer, :default => 0
end
end
15 changes: 15 additions & 0 deletions db/migrate/20170613183243_create_merit_actions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CreateMeritActions < ActiveRecord::Migration
def change
create_table :merit_actions do |t|
t.integer :user_id
t.string :action_method
t.integer :action_value
t.boolean :had_errors, default: false
t.string :target_model
t.integer :target_id
t.text :target_data
t.boolean :processed, default: false
t.timestamps
end
end
end
11 changes: 11 additions & 0 deletions db/migrate/20170613183244_create_merit_activity_logs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateMeritActivityLogs < ActiveRecord::Migration
def change
create_table :merit_activity_logs do |t|
t.integer :action_id
t.string :related_change_type
t.integer :related_change_id
t.string :description
t.datetime :created_at
end
end
end
7 changes: 7 additions & 0 deletions db/migrate/20170613183245_create_sashes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateSashes < ActiveRecord::Migration
def change
create_table :sashes do |t|
t.timestamps
end
end
end
16 changes: 16 additions & 0 deletions db/migrate/20170613183246_create_badges_sashes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CreateBadgesSashes < ActiveRecord::Migration
def self.up
create_table :badges_sashes do |t|
t.integer :badge_id, :sash_id
t.boolean :notified_user, default: false
t.datetime :created_at
end
add_index :badges_sashes, [:badge_id, :sash_id]
add_index :badges_sashes, :badge_id
add_index :badges_sashes, :sash_id
end

def self.down
drop_table :badges_sashes
end
end
15 changes: 15 additions & 0 deletions db/migrate/20170613183247_create_scores_and_points.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CreateScoresAndPoints < ActiveRecord::Migration
def change
create_table :merit_scores do |t|
t.references :sash
t.string :category, default: 'default'
end

create_table :merit_score_points do |t|
t.references :score
t.integer :num_points, default: 0
t.string :log
t.datetime :created_at
end
end
end
134 changes: 122 additions & 12 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,58 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170428044229) do
ActiveRecord::Schema.define(version: 20170613183247) do

create_table "activities", force: :cascade do |t|
t.integer "trackable_id"
t.string "trackable_type"
t.integer "owner_id"
t.integer "trackable_id"
t.string "owner_type"
t.integer "owner_id"
t.string "key"
t.text "parameters"
t.integer "recipient_id"
t.string "recipient_type"
t.integer "recipient_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["owner_id", "owner_type"], name: "index_activities_on_owner_id_and_owner_type"
t.index ["recipient_id", "recipient_type"], name: "index_activities_on_recipient_id_and_recipient_type"
t.index ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type"
end

create_table "attachments", force: :cascade do |t|
t.string "file_name"
t.string "attachable_type", default: ""
t.integer "attachable_id", default: 0
t.datetime "created_at"
t.datetime "updated_at"
t.index ["attachable_type", "attachable_id"], name: "index_attachments_on_attachable_type_and_attachable_id"
end

create_table "authentications", force: :cascade do |t|
t.string "uid"
t.string "provider"
t.string "oauth_token"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["user_id"], name: "index_authentications_on_user_id"
end

create_table "badges_sashes", force: :cascade do |t|
t.integer "badge_id"
t.integer "sash_id"
t.boolean "notified_user", default: false
t.datetime "created_at"
t.index ["badge_id", "sash_id"], name: "index_badges_sashes_on_badge_id_and_sash_id"
t.index ["badge_id"], name: "index_badges_sashes_on_badge_id"
t.index ["sash_id"], name: "index_badges_sashes_on_sash_id"
end

create_table "comments", force: :cascade do |t|
t.string "title", limit: 50, default: ""
t.text "comment"
t.integer "commentable_id"
t.string "commentable_type"
t.integer "commentable_id"
t.integer "user_id"
t.string "role", default: "comments"
t.datetime "created_at"
Expand All @@ -43,6 +72,16 @@
t.index ["user_id"], name: "index_comments_on_user_id"
end

create_table "event_attendees", force: :cascade do |t|
t.integer "event_id", null: false
t.integer "user_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t. "status", default: "0", null: false
t.index ["event_id"], name: "index_event_attendees_on_event_id"
t.index ["user_id"], name: "index_event_attendees_on_user_id"
end

create_table "events", force: :cascade do |t|
t.string "name"
t.datetime "event_datetime"
Expand All @@ -51,16 +90,18 @@
t.datetime "updated_at"
t.integer "cached_votes_up", default: 0
t.integer "comments_count", default: 0
t.string "location"
t.string "latlng", default: ""
t.index ["cached_votes_up"], name: "index_events_on_cached_votes_up"
t.index ["comments_count"], name: "index_events_on_comments_count"
t.index ["user_id"], name: "index_events_on_user_id"
end

create_table "follows", force: :cascade do |t|
t.integer "followable_id", null: false
t.string "followable_type", null: false
t.integer "follower_id", null: false
t.integer "followable_id", null: false
t.string "follower_type", null: false
t.integer "follower_id", null: false
t.boolean "blocked", default: false, null: false
t.datetime "created_at"
t.datetime "updated_at"
Expand All @@ -80,25 +121,86 @@
t.index ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type"
end

create_table "merit_actions", force: :cascade do |t|
t.integer "user_id"
t.string "action_method"
t.integer "action_value"
t.boolean "had_errors", default: false
t.string "target_model"
t.integer "target_id"
t.text "target_data"
t.boolean "processed", default: false
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "merit_activity_logs", force: :cascade do |t|
t.integer "action_id"
t.string "related_change_type"
t.integer "related_change_id"
t.string "description"
t.datetime "created_at"
end

create_table "merit_score_points", force: :cascade do |t|
t.integer "score_id"
t.integer "num_points", default: 0
t.string "log"
t.datetime "created_at"
end

create_table "merit_scores", force: :cascade do |t|
t.integer "sash_id"
t.string "category", default: "default"
end

create_table "photo_albums", force: :cascade do |t|
t.string "title", default: "Album"
t.string "front_image_url"
t.integer "photos_count", default: 0, null: false
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "slug"
t.integer "cached_votes_up", default: 0
t.integer "comments_count", default: 0
t.index ["slug"], name: "index_photo_albums_on_slug", unique: true
t.index ["user_id"], name: "index_photo_albums_on_user_id"
end

create_table "photos", force: :cascade do |t|
t.string "title", default: "", null: false
t.string "file", null: false
t.integer "photo_album_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["photo_album_id"], name: "index_photos_on_photo_album_id"
end

create_table "posts", force: :cascade do |t|
t.text "content", null: false
t.text "content", null: false
t.integer "user_id"
t.string "attachment"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "cached_votes_up", default: 0
t.integer "comments_count", default: 0
t.text "content_html"
t.text "preview_html", default: "", null: false
t.index ["cached_votes_up"], name: "index_posts_on_cached_votes_up"
t.index ["comments_count"], name: "index_posts_on_comments_count"
t.index ["user_id"], name: "index_posts_on_user_id"
end

create_table "sashes", force: :cascade do |t|
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", force: :cascade do |t|
t.string "name", default: "", null: false
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "about"
t.string "bio"
t.string "avatar"
t.string "cover"
t.string "reset_password_token"
Expand All @@ -120,17 +222,25 @@
t.string "phone_number"
t.integer "posts_count", default: 0, null: false
t.string "slug"
t.boolean "profile_complete", default: false, null: false
t.string "first_name", default: "", null: false
t.string "last_name", default: "", null: false
t.string "hometown"
t.string "works_at"
t.integer "photo_albums_count", default: 0, null: false
t.integer "sash_id"
t.integer "level", default: 0
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["slug"], name: "index_users_on_slug", unique: true
end

create_table "votes", force: :cascade do |t|
t.integer "votable_id"
t.string "votable_type"
t.integer "voter_id"
t.integer "votable_id"
t.string "voter_type"
t.integer "voter_id"
t.boolean "vote_flag"
t.string "vote_scope"
t.integer "vote_weight"
Expand Down

0 comments on commit 565382e

Please sign in to comment.