Commit aa3d07a6 by nnnghia98

using gem config and annotate

parent 8b301c0d
......@@ -29,3 +29,7 @@
/yarn-error.log
yarn-debug.log*
.yarn-integrity
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
......@@ -25,6 +25,7 @@ gem 'sunspot_rails'
gem 'sunspot_solr'
gem 'devise'
gem 'activerecord-import'
gem 'config'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
......@@ -40,6 +41,7 @@ group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry'
gem 'annotate'
end
group :development do
......
......@@ -60,6 +60,9 @@ GEM
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
annotate (3.0.3)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 14.0)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
......@@ -84,13 +87,48 @@ GEM
childprocess (3.0.0)
coderay (1.1.2)
concurrent-ruby (1.1.5)
config (2.0.0)
activesupport (>= 4.2)
deep_merge (~> 1.2, >= 1.2.1)
dry-schema (~> 1.0)
crass (1.0.5)
deep_merge (1.2.1)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
dry-configurable (0.9.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.9)
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
dry-inflector (0.2.0)
dry-initializer (3.0.2)
dry-logic (1.0.5)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-schema (1.4.1)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.8, >= 0.8.3)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
dry-types (~> 1.2)
dry-types (1.2.1)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.2, >= 0.2.2)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
erubi (1.9.0)
faraday (0.17.1)
multipart-post (>= 1.2, < 3)
......@@ -263,10 +301,12 @@ PLATFORMS
DEPENDENCIES
activerecord-import
annotate
bootsnap (>= 1.4.2)
byebug
capybara (>= 2.15)
carrierwave
config
devise
jbuilder
jquery-rails (= 4.3.1)
......
......@@ -2,6 +2,6 @@ class StaticPagesController < ApplicationController
def index
@cities = City.all
@industries = Industry.all
@jobs = Job.page(params[:page]).per(5)
@jobs = Job.page(params[:page]).per(Settings.jobs.page.per)
end
end
# == Schema Information
#
# Table name: cities
#
# id :bigint not null, primary key
# name :string(255)
# region :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_cities_on_name (name) UNIQUE
#
# In database
# t.string :name, unique: true
# t.string :region
......
# == Schema Information
#
# Table name: city_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# city_id :bigint
# job_id :bigint
#
# Indexes
#
# index_city_jobs_on_city_id (city_id)
# index_city_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (city_id => cities.id)
# fk_rails_... (job_id => jobs.id)
#
class CityJob < ApplicationRecord
belongs_to :city
belongs_to :job
......
# == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string(255)
# code :string(255)
# description :text(65535)
# email :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_companies_on_code (code) UNIQUE
# index_companies_on_email (email) UNIQUE
#
# In db
# t.string :name
# t.string :email, unique: true
......
# == Schema Information
#
# Table name: crawl_urls
#
# id :bigint not null, primary key
# crawled :boolean default(FALSE)
# title :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class CrawlUrl < ApplicationRecord
end
# == Schema Information
#
# Table name: industries
#
# id :bigint not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_industries_on_name (name) UNIQUE
#
# In db
# t.string :name
......
# == Schema Information
#
# Table name: industry_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# industry_id :bigint
# job_id :bigint
#
# Indexes
#
# index_industry_jobs_on_industry_id (industry_id)
# index_industry_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (industry_id => industries.id)
# fk_rails_... (job_id => jobs.id)
#
class IndustryJob < ApplicationRecord
belongs_to :industry
belongs_to :job
......
# == Schema Information
#
# Table name: jobs
#
# id :bigint not null, primary key
# category :integer
# code :string(255)
# description :text(65535)
# expiration_date :datetime
# level :string(255)
# other_salary :string(255)
# post_date :datetime
# requirement :text(65535)
# salary :string(255)
# short_des :text(65535)
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# company_id :bigint
#
# Indexes
#
# index_jobs_on_code (code) UNIQUE
# index_jobs_on_company_id (company_id)
#
# Foreign Keys
#
# fk_rails_... (company_id => companies.id)
#
# In database
# t.string :title
# t.string :level
......
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# activated :boolean
# confirmation_token :string(255)
# confirmed_at :datetime
# cv_path :string(255)
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# first_name :string(255)
# last_name :string(255)
# remember_created_at :datetime
# remember_digest :string(255)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# role :integer
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
......
# == Schema Information
#
# Table name: user_jobs
#
# id :bigint not null, primary key
# applied_at :datetime
# favorited_at :datetime
# viewed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# job_id :bigint
# user_id :bigint
#
# Indexes
#
# index_user_jobs_on_job_id (job_id)
# index_user_jobs_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (job_id => jobs.id)
# fk_rails_... (user_id => users.id)
#
class UserJob < ApplicationRecord
belongs_to :user
belongs_to :job
......
......@@ -7,8 +7,7 @@ class JobsImport
:requirement, :category, :company_id]
CSV.foreach(Rails.root.join("lib", "jobss.csv"), headers: true) do |row|
jobcsv = JobCsv.new(row)
jobs << jobcsv.csv_attributes
jobs << JobCsv.new(row).csv_attributes
end
Job.import job_columns, jobs
......
<tr>
<td><%= company.name %></td>
<td><%= company.email %></td>
<td><%= company.address %></td>
</tr>
<table class="table">
<thead>
<tr>
<th scope="col">company name</th>
<th scope="col">contact email</th>
<th scope="col">company address</th>
<th scope="col">company code</th>
</tr>
</thead>
<tbody>
<% @companies.each do |company| %>
<tr>
<td><%= company.name %></td>
<td><%= company.email %></td>
<td><%= company.address %></td>
<td><%= company.code %></td>
</tr>
<% end %>
<ul class="table">
<%= render partial: "companies/company", collection: @companies %>
</ul>
</tbody>
</table>
Config.setup do |config|
# Name of the constant exposing loaded settings
config.const_name = 'Settings'
# Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
#
# config.knockout_prefix = nil
# Overwrite an existing value when merging a `nil` value.
# When set to `false`, the existing value is retained after merge.
#
# config.merge_nil_values = true
# Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
#
# config.overwrite_arrays = true
# Load environment variables from the `ENV` object and override any settings defined in files.
#
# config.use_env = false
# Define ENV variable prefix deciding which variables to load into config.
#
# config.env_prefix = 'Settings'
# What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
# with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
# using dots in variable names might not be allowed (eg. Bash).
#
# config.env_separator = '.'
# Ability to process variables names:
# * nil - no change
# * :downcase - convert to lower case
#
# config.env_converter = :downcase
# Parse numeric values as integers instead of strings.
#
# config.env_parse_values = true
# Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
#
# config.schema do
# required(:name).filled
# required(:age).maybe(:int?)
# required(:email).filled(format?: EMAIL_REGEX)
# end
end
jobs:
page:
per: 5
# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
require 'annotate'
task :set_annotation_options do
# You can override any of these by setting an environment variable of the
# same name.
Annotate.set_defaults(
'additional_file_patterns' => [],
'routes' => 'false',
'models' => 'true',
'position_in_routes' => 'before',
'position_in_class' => 'before',
'position_in_test' => 'before',
'position_in_fixture' => 'before',
'position_in_factory' => 'before',
'position_in_serializer' => 'before',
'show_foreign_keys' => 'true',
'show_complete_foreign_keys' => 'false',
'show_indexes' => 'true',
'simple_indexes' => 'false',
'model_dir' => 'app/models',
'root_dir' => '',
'include_version' => 'false',
'require' => '',
'exclude_tests' => 'false',
'exclude_fixtures' => 'false',
'exclude_factories' => 'false',
'exclude_serializers' => 'false',
'exclude_scaffolds' => 'true',
'exclude_controllers' => 'true',
'exclude_helpers' => 'true',
'exclude_sti_subclasses' => 'false',
'ignore_model_sub_dir' => 'false',
'ignore_columns' => nil,
'ignore_routes' => nil,
'ignore_unknown_models' => 'false',
'hide_limit_column_types' => 'integer,bigint,boolean',
'hide_default_column_types' => 'json,jsonb,hstore',
'skip_on_db_migrate' => 'false',
'format_bare' => 'true',
'format_rdoc' => 'false',
'format_markdown' => 'false',
'sort' => 'false',
'force' => 'false',
'frozen' => 'false',
'classified_sort' => 'true',
'trace' => 'false',
'wrapper_open' => nil,
'wrapper_close' => nil,
'with_comment' => 'true'
)
end
Annotate.load_tasks
end
# == Schema Information
#
# Table name: cities
#
# id :bigint not null, primary key
# name :string(255)
# region :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_cities_on_name (name) UNIQUE
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: city_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# city_id :bigint
# job_id :bigint
#
# Indexes
#
# index_city_jobs_on_city_id (city_id)
# index_city_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (city_id => cities.id)
# fk_rails_... (job_id => jobs.id)
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string(255)
# code :string(255)
# description :text(65535)
# email :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_companies_on_code (code) UNIQUE
# index_companies_on_email (email) UNIQUE
#
# == Schema Information
#
# Table name: crawl_urls
#
# id :bigint not null, primary key
# crawled :boolean default(FALSE)
# title :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: industries
#
# id :bigint not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_industries_on_name (name) UNIQUE
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: industry_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# industry_id :bigint
# job_id :bigint
#
# Indexes
#
# index_industry_jobs_on_industry_id (industry_id)
# index_industry_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (industry_id => industries.id)
# fk_rails_... (job_id => jobs.id)
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: jobs
#
# id :bigint not null, primary key
# category :integer
# code :string(255)
# description :text(65535)
# expiration_date :datetime
# level :string(255)
# other_salary :string(255)
# post_date :datetime
# requirement :text(65535)
# salary :string(255)
# short_des :text(65535)
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# company_id :bigint
#
# Indexes
#
# index_jobs_on_code (code) UNIQUE
# index_jobs_on_company_id (company_id)
#
# Foreign Keys
#
# fk_rails_... (company_id => companies.id)
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: user_jobs
#
# id :bigint not null, primary key
# applied_at :datetime
# favorited_at :datetime
# viewed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# job_id :bigint
# user_id :bigint
#
# Indexes
#
# index_user_jobs_on_job_id (job_id)
# index_user_jobs_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (job_id => jobs.id)
# fk_rails_... (user_id => users.id)
#
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# activated :boolean
# confirmation_token :string(255)
# confirmed_at :datetime
# cv_path :string(255)
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# first_name :string(255)
# last_name :string(255)
# remember_created_at :datetime
# remember_digest :string(255)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# role :integer
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
# == Schema Information
#
# Table name: city_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# city_id :bigint
# job_id :bigint
#
# Indexes
#
# index_city_jobs_on_city_id (city_id)
# index_city_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (city_id => cities.id)
# fk_rails_... (job_id => jobs.id)
#
require 'test_helper'
class CityJobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: cities
#
# id :bigint not null, primary key
# name :string(255)
# region :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_cities_on_name (name) UNIQUE
#
require 'test_helper'
class CityTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string(255)
# code :string(255)
# description :text(65535)
# email :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_companies_on_code (code) UNIQUE
# index_companies_on_email (email) UNIQUE
#
require 'test_helper'
class CompanyTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: crawl_urls
#
# id :bigint not null, primary key
# crawled :boolean default(FALSE)
# title :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
require 'test_helper'
class CrawlUrlTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: industry_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# industry_id :bigint
# job_id :bigint
#
# Indexes
#
# index_industry_jobs_on_industry_id (industry_id)
# index_industry_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (industry_id => industries.id)
# fk_rails_... (job_id => jobs.id)
#
require 'test_helper'
class IndustryJobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: industries
#
# id :bigint not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_industries_on_name (name) UNIQUE
#
require 'test_helper'
class IndustryTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: jobs
#
# id :bigint not null, primary key
# category :integer
# code :string(255)
# description :text(65535)
# expiration_date :datetime
# level :string(255)
# other_salary :string(255)
# post_date :datetime
# requirement :text(65535)
# salary :string(255)
# short_des :text(65535)
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# company_id :bigint
#
# Indexes
#
# index_jobs_on_code (code) UNIQUE
# index_jobs_on_company_id (company_id)
#
# Foreign Keys
#
# fk_rails_... (company_id => companies.id)
#
require 'test_helper'
class JobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: user_jobs
#
# id :bigint not null, primary key
# applied_at :datetime
# favorited_at :datetime
# viewed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# job_id :bigint
# user_id :bigint
#
# Indexes
#
# index_user_jobs_on_job_id (job_id)
# index_user_jobs_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (job_id => jobs.id)
# fk_rails_... (user_id => users.id)
#
require 'test_helper'
class UserJobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# activated :boolean
# confirmation_token :string(255)
# confirmed_at :datetime
# cv_path :string(255)
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# first_name :string(255)
# last_name :string(255)
# remember_created_at :datetime
# remember_digest :string(255)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# role :integer
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
require 'test_helper'
class UserTest < ActiveSupport::TestCase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment