Skip to content

Commit

Permalink
Boilerplate-II : Cleanup migrations & misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ksashikumar committed Jun 9, 2017
1 parent d95f9e0 commit 50d54cf
Show file tree
Hide file tree
Showing 31 changed files with 233 additions and 68 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ gem 'rack-cors'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'active_model_serializers', '0.10.5'
gem 'rubocop'
gem 'elasticsearch'
gem 'dalli'
gem 'devise_token_auth'
gem 'ancestry'

group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
32 changes: 19 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ GEM
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
ancestry (3.0.0)
activerecord (>= 3.2.0)
arel (8.0.0)
ast (2.3.0)
bcrypt (3.1.11)
Expand All @@ -52,17 +54,16 @@ GEM
activesupport
concurrent-ruby (1.0.5)
dalli (2.7.6)
elasticsearch (2.0.2)
elasticsearch-api (= 2.0.2)
elasticsearch-transport (= 2.0.2)
elasticsearch-api (2.0.2)
multi_json
elasticsearch-transport (2.0.2)
faraday
multi_json
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
responders
warden (~> 1.2.3)
devise_token_auth (0.1.42)
devise (> 3.5.2, <= 4.3)
rails (< 6)
erubi (1.6.0)
faraday (0.12.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
globalid (0.4.0)
activesupport (>= 4.2.0)
Expand All @@ -82,11 +83,10 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.2)
multi_json (1.12.1)
multipart-post (2.0.0)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
orm_adapter (0.5.0)
parallel (1.11.2)
parser (2.4.0.0)
ast (~> 2.2)
Expand Down Expand Up @@ -127,6 +127,9 @@ GEM
rb-inotify (0.9.8)
ffi (>= 0.5.0)
redis (3.3.3)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
Expand All @@ -153,6 +156,8 @@ GEM
tzinfo (1.2.3)
thread_safe (~> 0.1)
unicode-display_width (1.2.1)
warden (1.2.7)
rack (>= 1.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand All @@ -162,10 +167,11 @@ PLATFORMS

DEPENDENCIES
active_model_serializers (= 0.10.5)
ancestry
bcrypt (~> 3.1.7)
byebug
dalli
elasticsearch
devise_token_auth
listen (>= 3.0.5, < 3.2)
pg (~> 0.18)
puma (~> 3.7)
Expand Down
4 changes: 0 additions & 4 deletions app/channels/application_cable/channel.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/channels/application_cable/connection.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class QuestionsController < ApplicationController
class CommentsController < ApplicationController

def create
end
Expand All @@ -15,4 +15,4 @@ def update
def destroy
end

end
end
18 changes: 18 additions & 0 deletions app/controllers/discussions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class DiscussionsController < ApplicationController

def create
end

def index
end

def show
end

def update
end

def destroy
end

end
18 changes: 18 additions & 0 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class PostsController < ApplicationController

def create
end

def index
end

def show
end

def update
end

def destroy
end

end
3 changes: 0 additions & 3 deletions app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ def index
def show
end

def update
end

def destroy
end

Expand Down
1 change: 1 addition & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Category < ApplicationRecord
has_ancestry
end
3 changes: 3 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Comment < ApplicationRecord
has_ancestry
end
2 changes: 2 additions & 0 deletions app/models/discussion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Discussion < ApplicationRecord
end
2 changes: 2 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Post < ApplicationRecord
end
2 changes: 0 additions & 2 deletions app/models/question.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/serializers/comment_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class CommentSerializer < BaseSerializer
end
2 changes: 2 additions & 0 deletions app/serializers/discussion_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class DiscussionSerializer < BaseSerializer
end
2 changes: 2 additions & 0 deletions app/serializers/post_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class PostSerializer < BaseSerializer
end
2 changes: 0 additions & 2 deletions app/serializers/question_serializer.rb

This file was deleted.

10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Rails.application.routes.draw do

api_routes = proc do
resources :questions do
end
resources :categories do
end
resources :tag do
resources :discussions do
resources :posts
end
resources :comments
resources :categories
resources :tags
end

scope '/api', defaults: { version: 'v1', format: 'json' }, constraints: { format: /(json|$^)/ } do
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20170608181811_create_categories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ def change
create_table :categories do |t|
t.string :name, limit: 30, null: false
t.text :description
t.integer :parent_id, null: false
t.string :ancestry
t.references :user, index: true, foreign_key: true

t.timestamps
end
add_index :categories, :name, unique: true
add_foreign_key :categories, :categories, column: :parent_id
add_index :categories, :ancestry
end
end
19 changes: 0 additions & 19 deletions db/migrate/20170608183355_create_questions.rb

This file was deleted.

20 changes: 20 additions & 0 deletions db/migrate/20170609163534_create_discussions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class CreateDiscussions < ActiveRecord::Migration[5.1]
def change
create_table :discussions do |t|
t.text :title, null: false
t.text :description, null: false
t.references :user, index: true, foreign_key: true
t.integer :upvotes_count, default: 0
t.integer :downvotes_count, default: 0
t.integer :posts_count, default: 0
t.integer :comments_count, default: 0
t.integer :follows_count, default: 0
t.integer :views, default: 0
t.float :score, default: 0
t.boolean :pinned, default: false
t.boolean :deleted, default: false
t.boolean :spam, default: false

t.timestamps end
end
end
17 changes: 17 additions & 0 deletions db/migrate/20170609164329_create_posts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class CreatePosts < ActiveRecord::Migration[5.1]
def change
create_table :posts do |t|
t.text :content, null: false
t.references :user, index: true, foreign_key: true
t.integer :upvotes_count, default: 0
t.integer :downvotes_count, default: 0
t.integer :comments_count, default: 0
t.integer :views, default: 0
t.float :score, default: 0
t.boolean :deleted, default: false
t.boolean :spam, default: false

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20170609170202_create_comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateComments < ActiveRecord::Migration[5.1]
def change
create_table :comments do |t|
t.text :content, null: false
t.string :ancestry
t.references :user, index: true, foreign_key: true

t.timestamps
end
add_index :comments, :ancestry
end
end
51 changes: 40 additions & 11 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,65 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170608183355) do
ActiveRecord::Schema.define(version: 20170609170202) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "categories", force: :cascade do |t|
t.string "name", limit: 30, null: false
t.text "description"
t.integer "parent_id", null: false
t.string "ancestry"
t.bigint "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["ancestry"], name: "index_categories_on_ancestry"
t.index ["name"], name: "index_categories_on_name", unique: true
t.index ["user_id"], name: "index_categories_on_user_id"
end

create_table "questions", force: :cascade do |t|
t.text "name", null: false
create_table "comments", force: :cascade do |t|
t.text "content", null: false
t.string "ancestry"
t.bigint "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["ancestry"], name: "index_comments_on_ancestry"
t.index ["user_id"], name: "index_comments_on_user_id"
end

create_table "discussions", force: :cascade do |t|
t.text "title", null: false
t.text "description", null: false
t.bigint "user_id"
t.integer "upvote_count", default: 0
t.integer "downvote_count", default: 0
t.integer "answer_count", default: 0
t.integer "follow_count", default: 0
t.integer "upvotes_count", default: 0
t.integer "downvotes_count", default: 0
t.integer "posts_count", default: 0
t.integer "comments_count", default: 0
t.integer "follows_count", default: 0
t.integer "views", default: 0
t.float "score", default: 0.0
t.boolean "pinned", default: false
t.boolean "deleted", default: false
t.boolean "spam", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_discussions_on_user_id"
end

create_table "posts", force: :cascade do |t|
t.text "content", null: false
t.bigint "user_id"
t.integer "upvotes_count", default: 0
t.integer "downvotes_count", default: 0
t.integer "comments_count", default: 0
t.integer "views", default: 0
t.float "score", default: 0.0
t.boolean "deleted", default: false
t.boolean "spam", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_questions_on_user_id"
t.index ["user_id"], name: "index_posts_on_user_id"
end

create_table "tags", force: :cascade do |t|
Expand All @@ -64,7 +92,8 @@
t.index ["email"], name: "index_users_on_email", unique: true
end

add_foreign_key "categories", "categories", column: "parent_id"
add_foreign_key "categories", "users"
add_foreign_key "questions", "users"
add_foreign_key "comments", "users"
add_foreign_key "discussions", "users"
add_foreign_key "posts", "users"
end
Loading

0 comments on commit 50d54cf

Please sign in to comment.