souls 0.24.2 → 0.24.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/souls +12 -1
- data/lib/souls.rb +54 -0
- data/lib/souls/init.rb +37 -16
- data/lib/souls/version.rb +1 -1
- metadata +16 -191
- data/.gitignore +0 -15
- data/.irbrc +0 -3
- data/.rspec +0 -3
- data/.rubocop.yml +0 -152
- data/.ruby-version +0 -1
- data/.travis.yml +0 -6
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -98
- data/Rakefile +0 -23
- data/Steepfile +0 -8
- data/apps/api/.env.sample +0 -7
- data/apps/api/.gitignore +0 -32
- data/apps/api/.irbrc +0 -4
- data/apps/api/.rspec +0 -3
- data/apps/api/.rubocop.yml +0 -132
- data/apps/api/.ruby-version +0 -1
- data/apps/api/CODE_OF_CONDUCT.md +0 -74
- data/apps/api/Dockerfile +0 -16
- data/apps/api/Dockerfile.dev +0 -17
- data/apps/api/Gemfile +0 -50
- data/apps/api/Gemfile.lock +0 -412
- data/apps/api/LICENSE.txt +0 -67
- data/apps/api/Procfile +0 -2
- data/apps/api/Procfile.dev +0 -2
- data/apps/api/README.md +0 -37
- data/apps/api/Rakefile +0 -5
- data/apps/api/app.rb +0 -114
- data/apps/api/app/engines/notification_engine.rb +0 -5
- data/apps/api/app/graphql/mutations/.keep +0 -0
- data/apps/api/app/graphql/mutations/base/article/create_article.rb +0 -30
- data/apps/api/app/graphql/mutations/base/article/delete_article.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article/destroy_delete_article.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article/update_article.rb +0 -30
- data/apps/api/app/graphql/mutations/base/article_category/create_article_category.rb +0 -21
- data/apps/api/app/graphql/mutations/base/article_category/delete_article_category.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article_category/update_article_category.rb +0 -21
- data/apps/api/app/graphql/mutations/base/user/create_user.rb +0 -31
- data/apps/api/app/graphql/mutations/base/user/delete_user.rb +0 -17
- data/apps/api/app/graphql/mutations/base/user/destroy_delete_user.rb +0 -17
- data/apps/api/app/graphql/mutations/base/user/update_user.rb +0 -31
- data/apps/api/app/graphql/mutations/base_mutation.rb +0 -65
- data/apps/api/app/graphql/mutations/managers/user_manager/add_user_role.rb +0 -22
- data/apps/api/app/graphql/mutations/managers/user_manager/remove_user_role.rb +0 -22
- data/apps/api/app/graphql/mutations/managers/user_manager/sign_in_user.rb +0 -45
- data/apps/api/app/graphql/queries/article.rb +0 -13
- data/apps/api/app/graphql/queries/article_categories.rb +0 -11
- data/apps/api/app/graphql/queries/article_category.rb +0 -13
- data/apps/api/app/graphql/queries/articles.rb +0 -11
- data/apps/api/app/graphql/queries/base_query.rb +0 -12
- data/apps/api/app/graphql/queries/me.rb +0 -11
- data/apps/api/app/graphql/queries/user.rb +0 -13
- data/apps/api/app/graphql/queries/users.rb +0 -11
- data/apps/api/app/graphql/resolvers/article_category_search.rb +0 -41
- data/apps/api/app/graphql/resolvers/article_search.rb +0 -57
- data/apps/api/app/graphql/resolvers/base.rb +0 -17
- data/apps/api/app/graphql/resolvers/user_search.rb +0 -63
- data/apps/api/app/graphql/souls_api_schema.rb +0 -43
- data/apps/api/app/graphql/types/.keep +0 -0
- data/apps/api/app/graphql/types/article_category_type.rb +0 -12
- data/apps/api/app/graphql/types/article_type.rb +0 -30
- data/apps/api/app/graphql/types/base/base_argument.rb +0 -4
- data/apps/api/app/graphql/types/base/base_enum.rb +0 -4
- data/apps/api/app/graphql/types/base/base_field.rb +0 -5
- data/apps/api/app/graphql/types/base/base_input_object.rb +0 -5
- data/apps/api/app/graphql/types/base/base_interface.rb +0 -7
- data/apps/api/app/graphql/types/base/base_object.rb +0 -6
- data/apps/api/app/graphql/types/base/base_scalar.rb +0 -4
- data/apps/api/app/graphql/types/base/base_union.rb +0 -4
- data/apps/api/app/graphql/types/base/mutation_type.rb +0 -26
- data/apps/api/app/graphql/types/base/query_type.rb +0 -18
- data/apps/api/app/graphql/types/connections/article_category_connection.rb +0 -3
- data/apps/api/app/graphql/types/connections/article_connection.rb +0 -3
- data/apps/api/app/graphql/types/connections/base_connection.rb +0 -14
- data/apps/api/app/graphql/types/connections/user_connection.rb +0 -3
- data/apps/api/app/graphql/types/edges/article_category_edge.rb +0 -5
- data/apps/api/app/graphql/types/edges/article_edge.rb +0 -5
- data/apps/api/app/graphql/types/edges/base_edge.rb +0 -4
- data/apps/api/app/graphql/types/edges/user_edge.rb +0 -5
- data/apps/api/app/graphql/types/user_type.rb +0 -24
- data/apps/api/app/models/article.rb +0 -4
- data/apps/api/app/models/article_category.rb +0 -3
- data/apps/api/app/models/user.rb +0 -19
- data/apps/api/app/policies/application_policy.rb +0 -40
- data/apps/api/app/policies/article_category_policy.rb +0 -31
- data/apps/api/app/policies/article_policy.rb +0 -31
- data/apps/api/app/policies/user_policy.rb +0 -35
- data/apps/api/app/utils/association_loader.rb +0 -50
- data/apps/api/app/utils/fire_store.rb +0 -9
- data/apps/api/app/utils/firebase_id_token.rb +0 -4
- data/apps/api/app/utils/json_web_token.rb +0 -13
- data/apps/api/app/utils/record_loader.rb +0 -10
- data/apps/api/app/utils/souls_helper.rb +0 -18
- data/apps/api/cloudbuild.yml +0 -32
- data/apps/api/config.ru +0 -17
- data/apps/api/config/database.yml +0 -33
- data/apps/api/config/souls.rb +0 -10
- data/apps/api/constants/areas.rb +0 -71
- data/apps/api/constants/column_name_ja.rb +0 -27
- data/apps/api/db/migrate/20200006095538_create_users.rb +0 -30
- data/apps/api/db/migrate/20200712180236_create_article_categories.rb +0 -12
- data/apps/api/db/migrate/20200714215521_create_articles.rb +0 -22
- data/apps/api/db/schema.rb +0 -78
- data/apps/api/db/seeds.rb +0 -44
- data/apps/api/github/workflows/delivery.yml +0 -81
- data/apps/api/log/.keep +0 -0
- data/apps/api/spec/factories/article_categories.rb +0 -9
- data/apps/api/spec/factories/articles.rb +0 -17
- data/apps/api/spec/factories/users.rb +0 -23
- data/apps/api/spec/models/article_category_spec.rb +0 -7
- data/apps/api/spec/models/article_spec.rb +0 -7
- data/apps/api/spec/models/user_spec.rb +0 -7
- data/apps/api/spec/mutations/base/article_category_spec.rb +0 -46
- data/apps/api/spec/mutations/base/article_spec.rb +0 -70
- data/apps/api/spec/mutations/base/user_spec.rb +0 -76
- data/apps/api/spec/policies/article_category_policy_spec.rb +0 -24
- data/apps/api/spec/policies/article_policy_spec.rb +0 -24
- data/apps/api/spec/policies/user_policy_spec.rb +0 -24
- data/apps/api/spec/queries/article_category_spec.rb +0 -39
- data/apps/api/spec/queries/article_spec.rb +0 -53
- data/apps/api/spec/queries/user_spec.rb +0 -59
- data/apps/api/spec/resolvers/article_category_search_spec.rb +0 -54
- data/apps/api/spec/resolvers/article_search_spec.rb +0 -68
- data/apps/api/spec/resolvers/user_search_spec.rb +0 -74
- data/apps/api/spec/spec_helper.rb +0 -110
- data/apps/api/tmp/.keep +0 -0
- data/apps/worker/.env.sample +0 -9
- data/apps/worker/.gitignore +0 -32
- data/apps/worker/.irbrc +0 -4
- data/apps/worker/.rspec +0 -3
- data/apps/worker/.rubocop.yml +0 -132
- data/apps/worker/.ruby-version +0 -1
- data/apps/worker/CODE_OF_CONDUCT.md +0 -74
- data/apps/worker/Dockerfile +0 -16
- data/apps/worker/Dockerfile.dev +0 -17
- data/apps/worker/Gemfile +0 -49
- data/apps/worker/Gemfile.lock +0 -396
- data/apps/worker/LICENSE.txt +0 -67
- data/apps/worker/Procfile +0 -1
- data/apps/worker/Procfile.dev +0 -1
- data/apps/worker/README.md +0 -37
- data/apps/worker/Rakefile +0 -5
- data/apps/worker/app.rb +0 -101
- data/apps/worker/app/engines/notification_engine.rb +0 -5
- data/apps/worker/app/graphql/mutations/.keep +0 -0
- data/apps/worker/app/graphql/mutations/base_mutation.rb +0 -16
- data/apps/worker/app/graphql/mutations/workers/send_user_mail_job.rb +0 -31
- data/apps/worker/app/graphql/souls_api_schema.rb +0 -43
- data/apps/worker/app/graphql/types/.keep +0 -0
- data/apps/worker/app/graphql/types/base/base_argument.rb +0 -4
- data/apps/worker/app/graphql/types/base/base_enum.rb +0 -4
- data/apps/worker/app/graphql/types/base/base_field.rb +0 -5
- data/apps/worker/app/graphql/types/base/base_input_object.rb +0 -5
- data/apps/worker/app/graphql/types/base/base_interface.rb +0 -7
- data/apps/worker/app/graphql/types/base/base_object.rb +0 -5
- data/apps/worker/app/graphql/types/base/base_scalar.rb +0 -4
- data/apps/worker/app/graphql/types/base/base_union.rb +0 -4
- data/apps/worker/app/graphql/types/base/mutation_type.rb +0 -12
- data/apps/worker/app/graphql/types/base/query_type.rb +0 -6
- data/apps/worker/app/models/article.rb +0 -4
- data/apps/worker/app/models/article_category.rb +0 -3
- data/apps/worker/app/models/user.rb +0 -19
- data/apps/worker/app/utils/fire_store.rb +0 -9
- data/apps/worker/app/utils/souls_helper.rb +0 -96
- data/apps/worker/cloudbuild.yml +0 -32
- data/apps/worker/config.ru +0 -17
- data/apps/worker/config/database.yml +0 -33
- data/apps/worker/config/souls.rb +0 -10
- data/apps/worker/db/migrate/20200006095538_create_users.rb +0 -30
- data/apps/worker/db/migrate/20200712180236_create_article_categories.rb +0 -12
- data/apps/worker/db/migrate/20200714215521_create_articles.rb +0 -22
- data/apps/worker/db/schema.rb +0 -78
- data/apps/worker/db/seeds.rb +0 -44
- data/apps/worker/github/workflows/delivery.yml +0 -81
- data/apps/worker/log/.keep +0 -0
- data/apps/worker/spec/factories/article_categories.rb +0 -9
- data/apps/worker/spec/factories/articles.rb +0 -17
- data/apps/worker/spec/factories/users.rb +0 -23
- data/apps/worker/spec/models/article_category_spec.rb +0 -7
- data/apps/worker/spec/models/article_spec.rb +0 -7
- data/apps/worker/spec/models/user_spec.rb +0 -7
- data/apps/worker/spec/spec_helper.rb +0 -110
- data/apps/worker/tmp/.keep +0 -0
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/config/souls.rb +0 -9
- data/db/schema.rb +0 -67
- data/rbs/init.rbs +0 -2
- data/souls.gemspec +0 -34
@@ -1,96 +0,0 @@
|
|
1
|
-
module SoulsHelper
|
2
|
-
def check_user_permissions(user, obj, method)
|
3
|
-
raise(StandardError, "Invalid or Missing Token") unless user
|
4
|
-
|
5
|
-
policy_class = obj.class.name + "Policy"
|
6
|
-
policy_clazz = policy_class.constantize.new(user, obj)
|
7
|
-
permission = policy_clazz.public_send(method)
|
8
|
-
raise(Pundit::NotAuthorizedError, "permission error!") unless permission
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.export_csv(model_name)
|
12
|
-
singularized_name = model_name.singularize.underscore
|
13
|
-
return "Please Set column names in Constants !" unless Constants.public_send("#{singularized_name}_columns").size
|
14
|
-
unless Constants.public_send("#{singularized_name}_columns").size ==
|
15
|
-
Object.const_get(singularized_name.camelize).column_names.size
|
16
|
-
|
17
|
-
return "Columns number doesn't match! Please check Constants!"
|
18
|
-
end
|
19
|
-
|
20
|
-
file_path = "./db/seed_csv/#{model_name.pluralize.underscore}.csv"
|
21
|
-
CSV.open(file_path, "w") do |csv|
|
22
|
-
csv << Object.const_get(singularized_name.camelize).column_names.map do |c|
|
23
|
-
Constants.public_send("#{singularized_name}_columns")[c.to_sym]
|
24
|
-
end
|
25
|
-
Object.const_get(singularized_name.camelize).all.reverse.each do |item|
|
26
|
-
csv << item.attributes.values
|
27
|
-
end
|
28
|
-
end
|
29
|
-
"export success!:#{file_path}"
|
30
|
-
rescue StandardError => e
|
31
|
-
e
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.export_model_to_csv(model_name)
|
35
|
-
singularized_name = model_name.singularize.underscore
|
36
|
-
pluralized_name = model_name.pluralize.underscore
|
37
|
-
time = Time.now.utc.strftime("%F-%H-%M-%S")
|
38
|
-
file_name = "#{pluralized_name}-#{time}.csv"
|
39
|
-
upload_path = "csv/#{singularized_name}/#{file_name}"
|
40
|
-
file_path = "./tmp/#{pluralized_name}-#{time}.csv"
|
41
|
-
class_name = Object.const_get(singularized_name.camelize)
|
42
|
-
CSV.open(file_path, "w") do |csv|
|
43
|
-
if Constants.public_send("#{singularized_name}_columns").size.present?
|
44
|
-
unless Constants.public_send("#{singularized_name}_columns").size ==
|
45
|
-
Object.const_get(singularized_name.camelize).column_names.size
|
46
|
-
|
47
|
-
return "Columns number doesn't match! Please check Constants !"
|
48
|
-
end
|
49
|
-
|
50
|
-
csv << class_name.column_names.map { |c| Constants.public_send("#{singularized_name}_columns")[c.to_sym] }
|
51
|
-
else
|
52
|
-
csv << class_name.column_names
|
53
|
-
end
|
54
|
-
class_name.all.reverse.each do |item|
|
55
|
-
csv << item.attributes.values
|
56
|
-
end
|
57
|
-
end
|
58
|
-
upload_to_gcs(file_path, upload_path)
|
59
|
-
FileUtils.rm(file_path)
|
60
|
-
bucket = ENV["RACK_ENV"] == "production" ? ENV["GCS_NAME_PRODUCTION"] : ENV["GCS_NAME_DEV"]
|
61
|
-
"https://storage.cloud.google.com/#{bucket}/csv/#{singularized_name}/#{file_name}"
|
62
|
-
rescue StandardError => e
|
63
|
-
e.backtrace
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.upload_to_gcs(file_path, upload_path)
|
67
|
-
storage = Google::Cloud::Storage.new
|
68
|
-
bucket =
|
69
|
-
if ENV["RACK_ENV"] == "production"
|
70
|
-
storage.bucket(ENV["GCS_NAME_PRODUCTION"])
|
71
|
-
else
|
72
|
-
storage.bucket(ENV["GCS_NAME_DEV"])
|
73
|
-
end
|
74
|
-
file = bucket.create_file(file_path, upload_path, acl: "authenticated_read")
|
75
|
-
file.public_url
|
76
|
-
rescue StandardError => e
|
77
|
-
raise(StandardError, e)
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.pubsub_queue(topic_name: "seino-schedule-scraper", message: "text!")
|
81
|
-
pubsub = Google::Cloud::Pubsub.new(project: ENV["PROJECT_ID"])
|
82
|
-
topic = pubsub.topic(topic_name)
|
83
|
-
topic.publish(message)
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.get_tables
|
87
|
-
path = "./db/schema.rb"
|
88
|
-
tables = []
|
89
|
-
File.open(path, "r") do |f|
|
90
|
-
f.each_line.with_index do |line, _i|
|
91
|
-
tables << line.split("\"")[1] if line.include?("create_table")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
tables
|
95
|
-
end
|
96
|
-
end
|
data/apps/worker/cloudbuild.yml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
steps:
|
2
|
-
- name: gcr.io/cloud-builders/docker
|
3
|
-
args:
|
4
|
-
- image
|
5
|
-
- build
|
6
|
-
- -t
|
7
|
-
- asia.gcr.io/$PROJECT_ID/$APP_NAME
|
8
|
-
- .
|
9
|
-
|
10
|
-
- name: gcr.io/cloud-builders/docker
|
11
|
-
args:
|
12
|
-
- image
|
13
|
-
- push
|
14
|
-
- asia.gcr.io/$PROJECT_ID/$APP_NAME
|
15
|
-
|
16
|
-
- name: gcr.io/cloud-builders/gcloud
|
17
|
-
args:
|
18
|
-
- run
|
19
|
-
- deploy
|
20
|
-
- $APP_NAME
|
21
|
-
- --image=asia.gcr.io/$PROJECT_ID/$APP_NAME
|
22
|
-
- --platform=managed
|
23
|
-
- --region=asia-northeast1
|
24
|
-
- --allow-unauthenticated
|
25
|
-
- --memory=2048Mi
|
26
|
-
- --concurrency=80
|
27
|
-
- --port=8080
|
28
|
-
- --set-cloudsql-instances=$APP_NAME:asia-northeast1:$APP_NAME-db
|
29
|
-
|
30
|
-
timeout: 1600s
|
31
|
-
options:
|
32
|
-
machineType: N1_HIGHCPU_8
|
data/apps/worker/config.ru
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "./app"
|
2
|
-
require "rack/cors"
|
3
|
-
require "graphql_playground"
|
4
|
-
|
5
|
-
map "/playground" do
|
6
|
-
use GraphQLPlayground, endpoint: "/endpoint"
|
7
|
-
end
|
8
|
-
|
9
|
-
run SoulsApi
|
10
|
-
|
11
|
-
use Rack::Cors do
|
12
|
-
allowed_headers = %i[get post put patch delete options head]
|
13
|
-
allow do
|
14
|
-
origins "*"
|
15
|
-
resource "*", headers: :any, methods: allowed_headers
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
default: &default
|
2
|
-
adapter: postgresql
|
3
|
-
encoding: utf8
|
4
|
-
port: 5432
|
5
|
-
|
6
|
-
development:
|
7
|
-
<<: *default
|
8
|
-
username: postgres
|
9
|
-
password: postgres
|
10
|
-
database: souls-api-dev
|
11
|
-
host: localhost
|
12
|
-
port: 5433
|
13
|
-
|
14
|
-
production:
|
15
|
-
<<: *default
|
16
|
-
username: <%= ENV.fetch("DB_USER") { "" } %>
|
17
|
-
database: souls_api_production
|
18
|
-
password: <%= ENV.fetch("DB_PW") { "" } %>
|
19
|
-
host: <%= ENV.fetch("DB_HOST") { "" } %>
|
20
|
-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
21
|
-
|
22
|
-
|
23
|
-
## Use local docker postgresql13
|
24
|
-
## `souls i run_psql` will create psql container
|
25
|
-
|
26
|
-
test:
|
27
|
-
<<: *default
|
28
|
-
username: postgres
|
29
|
-
password: postgres
|
30
|
-
database: souls-api-test
|
31
|
-
host: localhost
|
32
|
-
port: 5433
|
33
|
-
|
data/apps/worker/config/souls.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require "souls"
|
2
|
-
Souls.configure do |config|
|
3
|
-
config.app = "souls-api"
|
4
|
-
config.project_id = "souls-api"
|
5
|
-
config.strain = "worker"
|
6
|
-
config.api_repo = "elsoul/souls_api"
|
7
|
-
config.worker_repo = "elsoul/souls_worker"
|
8
|
-
config.worker_endpoint = "https://worker.com"
|
9
|
-
config.fixed_gems = ["selenium-webdriver"]
|
10
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class CreateUsers < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :users do |t|
|
4
|
-
t.string :uid, null: false, unique: true
|
5
|
-
t.string :username, null: false, default: ""
|
6
|
-
t.string :screen_name, null: false, default: ""
|
7
|
-
t.string :last_name, null: false, default: ""
|
8
|
-
t.string :first_name, null: false, default: ""
|
9
|
-
t.string :last_name_kanji, null: false, default: ""
|
10
|
-
t.string :first_name_kanji, null: false, default: ""
|
11
|
-
t.string :last_name_kana, null: false, default: ""
|
12
|
-
t.string :first_name_kana, null: false, default: ""
|
13
|
-
t.string :email, null: false, unique: true
|
14
|
-
t.string :tel, null: false, default: ""
|
15
|
-
t.string :icon_url, null: false, default: ""
|
16
|
-
t.string :birthday, null: false, default: ""
|
17
|
-
t.string :gender, null: false, default: ""
|
18
|
-
t.string :lang, null: false, default: "ja"
|
19
|
-
t.string :category, null: false, default: "user"
|
20
|
-
t.integer :roles_mask, null: false, default: 1
|
21
|
-
t.boolean :is_deleted, null: false, default: false
|
22
|
-
t.timestamps
|
23
|
-
end
|
24
|
-
add_index :users, :uid
|
25
|
-
add_index :users, :screen_name
|
26
|
-
add_index :users, :email, unique: true
|
27
|
-
add_index :users, :username
|
28
|
-
add_index :users, :is_deleted
|
29
|
-
end
|
30
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class CreateArticleCategories < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :article_categories do |t|
|
4
|
-
t.string :name, null: false
|
5
|
-
t.text :tags, array: true, default: []
|
6
|
-
t.boolean :is_deleted, null: false, default: false
|
7
|
-
t.timestamps
|
8
|
-
end
|
9
|
-
add_index :article_categories, :name
|
10
|
-
add_index :article_categories, :is_deleted
|
11
|
-
end
|
12
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class CreateArticles < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :articles do |t|
|
4
|
-
t.belongs_to :user
|
5
|
-
t.string :title, null: false, unique: true
|
6
|
-
t.text :body, null: false, default: ""
|
7
|
-
t.string :thumnail_url, null: false, default: ""
|
8
|
-
t.datetime :public_date, null: false, default: Time.now + 30.days
|
9
|
-
t.belongs_to :article_category, null: false
|
10
|
-
t.boolean :is_public, default: false, null: false
|
11
|
-
t.boolean :just_created, default: true, null: false
|
12
|
-
t.string :slag, null: false, unique: true
|
13
|
-
t.text :tags, array: true, default: []
|
14
|
-
t.boolean :is_deleted, null: false, default: false
|
15
|
-
t.timestamps
|
16
|
-
end
|
17
|
-
add_index :articles, :slag, unique: true
|
18
|
-
add_index :articles, :title, unique: true
|
19
|
-
add_index :articles, :is_public
|
20
|
-
add_index :articles, :is_deleted
|
21
|
-
end
|
22
|
-
end
|
data/apps/worker/db/schema.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead
|
2
|
-
# of editing this file, please use the migrations feature of Active Record to
|
3
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
-
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
-
# be faster and is potentially less error prone than running all of your
|
8
|
-
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
-
# migrations use external dependencies or application code.
|
10
|
-
#
|
11
|
-
# It's strongly recommended that you check this file into your version control system.
|
12
|
-
|
13
|
-
ActiveRecord::Schema.define(version: 2020_07_14_215521) do
|
14
|
-
|
15
|
-
# These are extensions that must be enabled in order to support this database
|
16
|
-
enable_extension "plpgsql"
|
17
|
-
|
18
|
-
create_table "article_categories", force: :cascade do |t|
|
19
|
-
t.string "name", null: false
|
20
|
-
t.text "tags", default: [], array: true
|
21
|
-
t.boolean "is_deleted", default: false, null: false
|
22
|
-
t.datetime "created_at", precision: 6, null: false
|
23
|
-
t.datetime "updated_at", precision: 6, null: false
|
24
|
-
t.index ["is_deleted"], name: "index_article_categories_on_is_deleted"
|
25
|
-
t.index ["name"], name: "index_article_categories_on_name"
|
26
|
-
end
|
27
|
-
|
28
|
-
create_table "articles", force: :cascade do |t|
|
29
|
-
t.bigint "user_id"
|
30
|
-
t.string "title", null: false
|
31
|
-
t.text "body", default: "", null: false
|
32
|
-
t.string "thumnail_url", default: "", null: false
|
33
|
-
t.datetime "public_date", default: "2021-08-18 18:14:54", null: false
|
34
|
-
t.bigint "article_category_id", null: false
|
35
|
-
t.boolean "is_public", default: false, null: false
|
36
|
-
t.boolean "just_created", default: true, null: false
|
37
|
-
t.string "slag", null: false
|
38
|
-
t.text "tags", default: [], array: true
|
39
|
-
t.boolean "is_deleted", default: false, null: false
|
40
|
-
t.datetime "created_at", precision: 6, null: false
|
41
|
-
t.datetime "updated_at", precision: 6, null: false
|
42
|
-
t.index ["article_category_id"], name: "index_articles_on_article_category_id"
|
43
|
-
t.index ["is_deleted"], name: "index_articles_on_is_deleted"
|
44
|
-
t.index ["is_public"], name: "index_articles_on_is_public"
|
45
|
-
t.index ["slag"], name: "index_articles_on_slag", unique: true
|
46
|
-
t.index ["title"], name: "index_articles_on_title", unique: true
|
47
|
-
t.index ["user_id"], name: "index_articles_on_user_id"
|
48
|
-
end
|
49
|
-
|
50
|
-
create_table "users", force: :cascade do |t|
|
51
|
-
t.string "uid", null: false
|
52
|
-
t.string "username", default: "", null: false
|
53
|
-
t.string "screen_name", default: "", null: false
|
54
|
-
t.string "last_name", default: "", null: false
|
55
|
-
t.string "first_name", default: "", null: false
|
56
|
-
t.string "last_name_kanji", default: "", null: false
|
57
|
-
t.string "first_name_kanji", default: "", null: false
|
58
|
-
t.string "last_name_kana", default: "", null: false
|
59
|
-
t.string "first_name_kana", default: "", null: false
|
60
|
-
t.string "email", null: false
|
61
|
-
t.string "tel", default: "", null: false
|
62
|
-
t.string "icon_url", default: "", null: false
|
63
|
-
t.string "birthday", default: "", null: false
|
64
|
-
t.string "gender", default: "", null: false
|
65
|
-
t.string "lang", default: "ja", null: false
|
66
|
-
t.string "category", default: "user", null: false
|
67
|
-
t.integer "roles_mask", default: 1, null: false
|
68
|
-
t.boolean "is_deleted", default: false, null: false
|
69
|
-
t.datetime "created_at", precision: 6, null: false
|
70
|
-
t.datetime "updated_at", precision: 6, null: false
|
71
|
-
t.index ["email"], name: "index_users_on_email", unique: true
|
72
|
-
t.index ["is_deleted"], name: "index_users_on_is_deleted"
|
73
|
-
t.index ["screen_name"], name: "index_users_on_screen_name"
|
74
|
-
t.index ["uid"], name: "index_users_on_uid"
|
75
|
-
t.index ["username"], name: "index_users_on_username"
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
data/apps/worker/db/seeds.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require "./app"
|
2
|
-
|
3
|
-
Dir[File.expand_path("#{Rack::Directory.new('').root}/spec/factories/*.rb")]
|
4
|
-
.each { |file| require file }
|
5
|
-
|
6
|
-
def create_user
|
7
|
-
gimei = Gimei.name
|
8
|
-
user =
|
9
|
-
FactoryBot.create(
|
10
|
-
:user,
|
11
|
-
username: gimei.kanji,
|
12
|
-
last_name: gimei.last.hiragana,
|
13
|
-
first_name: gimei.first.hiragana,
|
14
|
-
last_name_kanji: gimei.last.kanji,
|
15
|
-
first_name_kanji: gimei.first.kanji,
|
16
|
-
last_name_kana: gimei.last.katakana,
|
17
|
-
first_name_kana: gimei.first.katakana,
|
18
|
-
gender: gimei.gender
|
19
|
-
)
|
20
|
-
puts(user.to_json)
|
21
|
-
return user.id if user
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_article_category
|
25
|
-
article_category = FactoryBot.create(:article_category)
|
26
|
-
"Article Category Created!\n #{article_category.to_json}" if article_category
|
27
|
-
end
|
28
|
-
|
29
|
-
def create_article(user_id, article_category_id)
|
30
|
-
article = FactoryBot.create(:article, user_id: user_id, article_category_id: article_category_id)
|
31
|
-
"Article Created!\n #{article.to_json}" if article
|
32
|
-
end
|
33
|
-
|
34
|
-
%w[お知らせ 特集 レシピ].each do |name|
|
35
|
-
puts ArticleCategory.create(name: name).to_json
|
36
|
-
end
|
37
|
-
|
38
|
-
10.times { create_user }
|
39
|
-
|
40
|
-
100.times do |_i|
|
41
|
-
user_id = User.find(rand(5).to_i + 1).id
|
42
|
-
article_category_id = ArticleCategory.find(rand(3).to_i + 1).id
|
43
|
-
puts create_article(user_id, article_category_id)
|
44
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
name: Delivery
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- master
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
build:
|
10
|
-
|
11
|
-
runs-on: ubuntu-20.04
|
12
|
-
|
13
|
-
services:
|
14
|
-
db:
|
15
|
-
image: postgres:13
|
16
|
-
ports: ["5433:5432"]
|
17
|
-
env:
|
18
|
-
POSTGRES_PASSWORD: postgres
|
19
|
-
options: >-
|
20
|
-
--health-cmd pg_isready
|
21
|
-
--health-interval 10s
|
22
|
-
--health-timeout 5s
|
23
|
-
--health-retries 5
|
24
|
-
|
25
|
-
steps:
|
26
|
-
- uses: actions/checkout@v2
|
27
|
-
- name: Set up Ruby 3.0
|
28
|
-
uses: actions/setup-ruby@v1
|
29
|
-
with:
|
30
|
-
ruby-version: 3.0
|
31
|
-
- name: Build and test with Rake
|
32
|
-
env:
|
33
|
-
PGHOST: 127.0.0.1
|
34
|
-
PGUSER: postgres
|
35
|
-
RACK_ENV: test
|
36
|
-
run: |
|
37
|
-
sudo apt-get -yqq install libpq-dev
|
38
|
-
gem install bundler
|
39
|
-
bundle install --jobs 4 --retry 3
|
40
|
-
bundle exec rake db:create RACK_ENV=test
|
41
|
-
bundle exec rake db:migrate RACK_ENV=test
|
42
|
-
bundle exec rspec
|
43
|
-
|
44
|
-
- name: Checkout the repository
|
45
|
-
uses: actions/checkout@v2
|
46
|
-
|
47
|
-
- name: GCP Authenticate
|
48
|
-
uses: google-github-actions/setup-gcloud@master
|
49
|
-
with:
|
50
|
-
version: "323.0.0"
|
51
|
-
project_id: ${{ secrets.GCP_PROJECT_ID }}
|
52
|
-
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
53
|
-
export_default_credentials: true
|
54
|
-
|
55
|
-
- name: Configure Docker
|
56
|
-
run: gcloud auth configure-docker --quiet
|
57
|
-
|
58
|
-
- name: Build Docker container
|
59
|
-
run: docker build . -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}
|
60
|
-
|
61
|
-
- name: Push to Container Resistory
|
62
|
-
run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}
|
63
|
-
|
64
|
-
- name: Deploy to Cloud Run
|
65
|
-
run: |
|
66
|
-
gcloud run deploy ${{ secrets.APP_NAME }} \
|
67
|
-
--image=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}} \
|
68
|
-
--memory=4Gi \
|
69
|
-
--region=asia-northeast1 \
|
70
|
-
--allow-unauthenticated \
|
71
|
-
--platform=managed \
|
72
|
-
--quiet \
|
73
|
-
--concurrency=80 \
|
74
|
-
--port=8080 \
|
75
|
-
--set-cloudsql-instances=${{ secrets.GCLOUDSQL_INSTANCE }} \
|
76
|
-
--set-env-vars="DB_USER=${{ secrets.DB_USER }}" \
|
77
|
-
--set-env-vars="DB_PW=${{ secrets.DB_PW }}" \
|
78
|
-
--set-env-vars="DB_HOST=${{ secrets.DB_HOST }}" \
|
79
|
-
--set-env-vars="TZ=${{ secrets.TZ }}" \
|
80
|
-
--set-env-vars="SLACK=${{ secrets.SLACK }}" \
|
81
|
-
--set-env-vars="SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}" \
|