Skip to content

Commit

Permalink
Merge pull request #6770 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2023-08-03 08:48:43
  • Loading branch information
komagata authored Aug 3, 2023
2 parents 23c942a + 9ea4f62 commit 609115d
Show file tree
Hide file tree
Showing 282 changed files with 2,262 additions and 1,173 deletions.
145 changes: 145 additions & 0 deletions .cloudbuild/cloudbuild-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
steps:
- id: Fetch
name: gcr.io/cloud-builders/docker
entrypoint: bash
args:
- '-c'
- 'docker pull asia.gcr.io/$PROJECT_ID/$REPO_NAME:latest || exit 0'
- id: Build
name: gcr.io/cloud-builders/docker
args:
- build
- '-t'
- 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'
- '-t'
- 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:latest'
- '--cache-from'
- 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:latest'
- .
- '-f'
- Dockerfile
- id: Push
name: gcr.io/cloud-builders/docker
args:
- push
- 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'
waitFor:
- Build
- id: SqlProxy
name: 'gcr.io/cloudsql-docker/gce-proxy:1.16'
args:
- /cloud_sql_proxy
- '-dir=/cloudsql'
- '-instances=$_CLOUD_SQL_HOST'
waitFor:
- '-'
volumes:
- name: db
path: /cloudsql
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
args:
- '-c'
- 'gcloud sql databases delete bootcamp_staging --instance=bootcamp --quiet || gcloud sql databases create bootcamp_staging --instance=bootcamp --quiet || exit 0'
id: DropAndCreateDB
waitFor:
- Fetch
entrypoint: sh
volumes:
- name: db
path: /cloudsql
- id: DBMigrate
name: 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'
args:
- bin/rails
- db:migrate
- db:seed
waitFor:
- DropAndCreateDB
volumes:
- name: db
path: /cloudsql
env:
- RAILS_ENV=production
- DISABLE_DATABASE_ENVIRONMENT_CHECK=1
- DB_HOST=/cloudsql/$_CLOUD_SQL_HOST
- DB_NAME=$_DB_NAME
- DB_PASS=$_DB_PASS
- DB_USER=$_DB_USER
- RAILS_MASTER_KEY=$_RAILS_MASTER_KEY
- id: Kill_SqlProxy
name: gcr.io/cloud-builders/docker
entrypoint: sh
args:
- '-c'
- docker kill -s TERM $(docker ps -q --filter "volume=db")
waitFor:
- DBMigrate
- id: Deploy
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
args:
- run
- deploy
- $_SERVICE_NAME
- '--platform=managed'
- '--region=asia-northeast1'
- '--quiet'
- '--image=asia.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'
- '--allow-unauthenticated'
- '--clear-vpc-connector'
- '--add-cloudsql-instances'
- $_CLOUD_SQL_HOST
- '--memory'
- $_MEMORY
- '--timeout'
- '10m'
- '--set-env-vars=LANG=ja_JP.UTF-8'
- '--set-env-vars=TZ=Asia/Tokyo'
- '--set-env-vars=RAILS_SERVE_STATIC_FILES=true'
- '--set-env-vars=RAILS_LOG_TO_STDOUT=true'
- '--set-env-vars=RAILS_ENV=production'
- '--set-env-vars=RACK_ENV=production'
- '--set-env-vars=APP_HOST_NAME=$_APP_HOST_NAME'
- '--set-env-vars=CLOUD_RUN_HOST_NAME=$_CLOUD_RUN_HOST_NAME'
- '--set-env-vars=RAILS_MASTER_KEY=$_RAILS_MASTER_KEY'
- '--set-env-vars=DB_NAME=$_DB_NAME'
- '--set-env-vars=DB_USER=$_DB_USER'
- '--set-env-vars=DB_PASS=$_DB_PASS'
- '--set-env-vars=DB_HOST=/cloudsql/$_CLOUD_SQL_HOST'
- '--set-env-vars=GOOGLE_CREDENTIALS=$_GOOGLE_CREDENTIALS'
- '--set-env-vars=GCS_BUCKET=$_GCS_BUCKET'
- '--set-env-vars=TOKEN=$_TOKEN'
- '--set-env-vars=DISCORD_NOTICE_WEBHOOK_URL=$_DISCORD_NOTICE_WEBHOOK_URL'
- '--set-env-vars=DISCORD_INTRODUCTION_WEBHOOK_URL=$_DISCORD_INTRODUCTION_WEBHOOK_URL'
- '--set-env-vars=DISCORD_ALL_WEBHOOK_URL=$_DISCORD_ALL_WEBHOOK_URL'
- '--set-env-vars=DISCORD_ADMIN_WEBHOOK_URL=$_DISCORD_ADMIN_WEBHOOK_URL'
- '--set-env-vars=DISCORD_MENTOR_WEBHOOK_URL=$_DISCORD_MENTOR_WEBHOOK_URL'
- '--set-env-vars=DISCORD_BUG_WEBHOOK_URL=$_DISCORD_BUG_WEBHOOK_URL'
- '--set-env-vars=DISCORD_REPORT_WEBHOOK_URL=$_DISCORD_REPORT_WEBHOOK_URL'
- '--set-env-vars=DISCORD_GUILD_ID=$_DISCORD_GUILD_ID'
- '--set-env-vars=DISCORD_TIMES_CHANNEL_CATEGORY_ID=$_DISCORD_TIMES_CHANNEL_CATEGORY_ID'
- '--set-env-vars=DISCORD_BOT_TOKEN=$_DISCORD_BOT_TOKEN'
- '--set-env-vars=GOOD_JOB_USERNAME=$_GOOD_JOB_USERNAME'
- '--set-env-vars=GOOD_JOB_PASSWORD=$_GOOD_JOB_PASSWORD'
- '--set-env-vars=STRIPE_ENDPOINT_SECRET=$_STRIPE_ENDPOINT_SECRET'
- '--set-env-vars=BASIC_AUTH_USER=$_BASIC_AUTH_USER'
- '--set-env-vars=BASIC_AUTH_PASSWORD=$_BASIC_AUTH_PASSWORD'
- '--set-env-vars=RECAPTCHA_SITE_KEY=$_RECAPTCHA_SITE_KEY'
- '--set-env-vars=RECAPTCHA_SECRET_KEY=$_RECAPTCHA_SECRET_KEY'
- '--set-env-vars=ROLLBAR_CLIENT_TOKEN=$_ROLLBAR_CLIENT_TOKEN'
- '--set-env-vars=OPEN_AI_ACCESS_TOKEN=$_OPEN_AI_ACCESS_TOKEN'
- '--set-env-vars=$_ENVS'
- >-
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID,$_LABELS
- id: Notify
name: 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:latest'
args:
- bin/notify
waitFor:
- Deploy
env:
- DB_NAME=$_DB_NAME
- DEPLOY_NOTIFY_WEBHOOK_URL=$_DEPLOY_NOTIFY_WEBHOOK_URL
timeout: 7200s
images:
- 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:latest'
2 changes: 1 addition & 1 deletion .cloudbuild/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ steps:
name: 'asia.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'
args:
- bin/rails
- bootcamp:migrate
- db:migrate:with_data
waitFor:
- Push
volumes:
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def user_params
params.require(:user).permit(
:adviser, :login_name, :name,
:name_kana, :email, :course_id, :subscription_id,
:description, :discord_account, :github_account,
:twitter_account, :facebook_url, :blog_url, :times_url,
:description, :github_account,
:twitter_account, :facebook_url, :blog_url,
:password, :password_confirmation, :job,
:organization, :os, :study_place,
:experience, :company_id,
Expand All @@ -60,7 +60,7 @@ def user_params
:officekey_permission, :tag_list, :training_ends_on,
:profile_image, :profile_name, :profile_job, :mentor,
:profile_text, { authored_books_attributes: %i[id title url cover _destroy] },
:country_code, :subdivision_code
:country_code, :subdivision_code, discord_profile_attributes: %i[account_name times_url]
)
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/talks/unreplied_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class API::Talks::UnrepliedController < API::BaseController
PAGER_NUMBER = 20

def index
@talks = Talk.eager_load(user: { avatar_attachment: :blob })
@talks = Talk.joins(:user)
.includes(user: [{ avatar_attachment: :blob }, :discord_profile])
.unreplied
.order(updated_at: :desc, id: :asc)
@talks =
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/talks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class API::TalksController < API::BaseController
def index
@target = params[:target]
@target = 'all' unless TARGETS.include?(@target)
@talks = Talk.eager_load(user: { avatar_attachment: :blob })
@talks = Talk.joins(:user)
.includes(user: [{ avatar_attachment: :blob }, :discord_profile])
.order(updated_at: :desc, id: :asc)
@talks =
if params[:search_word]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/buzz_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def edit; end

def update
if @buzz.update(buzz_params)
redirect_to buzz_path, notice: '関連リンク集を更新しました'
redirect_to buzz_path, notice: '紹介記事を更新しました'
else
render :edit
end
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/categories/practices_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class Categories::PracticesController < ApplicationController
before_action :require_admin_login

def index
@category = Category.find(params[:category_id])
@categories_practices = @category
.categories_practices
.includes(:practice)
.order(:position)
end
end
12 changes: 0 additions & 12 deletions app/controllers/courses/practices/sort_controller.rb

This file was deleted.

26 changes: 0 additions & 26 deletions app/controllers/current_user/products/index.html.slim

This file was deleted.

6 changes: 3 additions & 3 deletions app/controllers/current_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def user_params
user_attribute = [
:adviser, :login_name, :name,
:name_kana, :email, :course_id,
:description, :job_seeking, :discord_account,
:description, :job_seeking,
:github_account, :twitter_account, :facebook_url,
:blog_url, :times_url, :password, :password_confirmation,
:blog_url, :password, :password_confirmation,
:job, :organization, :os,
:experience, :company_id,
:nda, :avatar, :trainee,
:mail_notification, :job_seeker, :tag_list,
:after_graduation_hope, :training_ends_on, :profile_image,
:profile_name, :profile_job, :profile_text, { authored_books_attributes: %i[id title url cover _destroy] },
:feed_url, :country_code, :subdivision_code
:feed_url, :country_code, :subdivision_code, { discord_profile_attributes: %i[id account_name times_url] }
]
user_attribute.push(:retired_on, :graduated_on, :free, :github_collaborator) if current_user.admin?
params.require(:user).permit(user_attribute)
Expand Down
32 changes: 10 additions & 22 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def index
if current_user
display_dashboard
display_events_on_dashboard
display_regular_events_on_dashboard
display_welcome_message_for_adviser
set_required_fields
render aciton: :index
Expand All @@ -30,21 +29,13 @@ def set_required_fields
avatar_attached: current_user.avatar.attached?,
tag_list_count: current_user.tag_list.size,
after_graduation_hope: current_user.after_graduation_hope,
discord_account: current_user.discord_account,
discord_account_name: current_user.discord_profile.account_name,
github_account: current_user.github_account,
blog_url: current_user.blog_url,
graduated: current_user.graduated?
)
end

def today_to_tomorrow
(Time.zone.today + 9.hours)..(Time.zone.tomorrow + 9.hours)
end

def tomorrow_to_day_after_tomorrow
(Time.zone.tomorrow + 9.hours)..(Time.zone.tomorrow + 1.day + 9.hours)
end

def display_dashboard
@announcements = Announcement.with_avatar.where(wip: false).order(published_at: :desc).limit(5)
@bookmarks = current_user.bookmarks.order(created_at: :desc).limit(5)
Expand All @@ -57,18 +48,15 @@ def display_dashboard
end

def display_events_on_dashboard
cookies_ids = JSON.parse(cookies[:confirmed_event_ids]) if cookies[:confirmed_event_ids]
@events_coming_soon = Event.where(start_at: today_to_tomorrow).or(Event.where(start_at: tomorrow_to_day_after_tomorrow)).where.not(id: cookies_ids)
@events_coming_soon_except_job_hunting = @events_coming_soon.where.not(job_hunting: true)
end

def display_regular_events_on_dashboard
cookies_ids = JSON.parse(cookies[:confirmed_regular_event_ids]) if cookies[:confirmed_regular_event_ids]
@today_regular_events, @tomorrow_regular_events = RegularEvent.comming_soon_events(current_user)

cookies_ids&.each do |id|
RegularEvent.remove_event([@today_regular_events, @tomorrow_regular_events], id)
end
@today_events = (Event.today_events.related_to(current_user) \
+ RegularEvent.today_events.participated_by(current_user))
.sort_by { |e| e.start_at.strftime('%H:%M') }
@tomorrow_events = (Event.tomorrow_events.related_to(current_user) \
+ RegularEvent.tomorrow_events.participated_by(current_user))
.sort_by { |e| e.start_at.strftime('%H:%M') }
@day_after_tomorrow_events = (Event.day_after_tomorrow_events.related_to(current_user) \
+ RegularEvent.day_after_tomorrow_events.participated_by(current_user))
.sort_by { |e| e.start_at.strftime('%H:%M') }
end

def display_welcome_message_for_adviser
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def create
@user = User.new(user_params)
@user.course_id ||= Course.first.id
@user.free = true if @user.trainee?
@user.build_discord_profile
Newspaper.publish(:user_create, @user)
if @user.staff? || @user.trainee?
create_free_user!
Expand Down Expand Up @@ -147,8 +148,8 @@ def user_params
params.require(:user).permit(
:login_name, :name, :name_kana,
:email, :course_id, :description,
:discord_account, :github_account, :twitter_account,
:facebook_url, :blog_url, :times_url, :password,
:github_account, :twitter_account,
:facebook_url, :blog_url, :password,
:password_confirmation, :job, :organization,
:os, :experience,
:company_id, :nda, :avatar,
Expand Down
10 changes: 1 addition & 9 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# frozen_string_literal: true

module HomeHelper
def today_or_tommorow(event)
if event.holding_today?
'今日'
elsif event.holding_tomorrow?
'明日'
end
end

def anchor_to_required_field(attribute)
{
avatar_attached: 'form-user-avatar',
tag_list_count: 'form-tag-list',
after_graduation_hope: 'form-after-graduation-hope',
discord_account: 'form-discord-account',
discord_account_name: 'form-discord-account',
github_account: 'form-github-account',
blog_url: 'form-blog-url'
}[attribute]
Expand Down
Loading

0 comments on commit 609115d

Please sign in to comment.