Skip to content

Commit

Permalink
Merge pull request #7507 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2024-03-15 10:38:54
  • Loading branch information
komagata authored Mar 15, 2024
2 parents 695fcaa + 91df335 commit 3ea7148
Show file tree
Hide file tree
Showing 164 changed files with 1,667 additions and 1,565 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
- run:
name: Slim Lint
command: bundle exec slim-lint app/views -c config/slim_lint.yml
- run:
name: Update package list
command: sudo apt-get update
- run:
name: Install libvips
command: sudo apt-get install -y libvips
- run:
name: Traceroute
command: FAIL_ON_ERROR=1 bundle exec rake traceroute
Expand Down Expand Up @@ -75,6 +81,9 @@ jobs:
- run:
name: Install japanese font
command: sudo apt-get install -y fonts-noto-cjk
- run:
name: Install libvips
command: sudo apt-get install -y libvips
- run:
name: Wait for DB
command: 'dockerize -wait tcp://localhost:5432 -timeout 1m'
Expand Down
4 changes: 4 additions & 0 deletions .cloudbuild/cloudbuild-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ steps:
- '--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=STRIPE_TAX_RATE_ID=$_STRIPE_TAX_RATE_ID'
- '--set-env-vars=DISCORD_CLIENT_ID=$_DISCORD_CLIENT_ID'
- '--set-env-vars=DISCORD_CLIENT_SECRET=$_DISCORD_CLIENT_SECRET'
- '--set-env-vars=DISCORD_AUTHENTICATION_URL=$_DISCORD_AUTHENTICATION_URL'
- '--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
Expand Down
3 changes: 3 additions & 0 deletions .cloudbuild/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ steps:
- '--set-env-vars=ROLLBAR_CLIENT_TOKEN=$_ROLLBAR_CLIENT_TOKEN'
- '--set-env-vars=OPEN_AI_ACCESS_TOKEN=$_OPEN_AI_ACCESS_TOKEN'
- '--set-env-vars=STRIPE_TAX_RATE_ID=$_STRIPE_TAX_RATE_ID'
- '--set-env-vars=DISCORD_CLIENT_ID=$_DISCORD_CLIENT_ID'
- '--set-env-vars=DISCORD_CLIENT_SECRET=$_DISCORD_CLIENT_SECRET'
- '--set-env-vars=DISCORD_AUTHENTICATION_URL=$_DISCORD_AUTHENTICATION_URL'
- '--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
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/

# Install OS packages
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends imagemagick pngcrush optipng gsfonts
&& apt-get -y install --no-install-recommends libvips42 libvips-dev pngcrush optipng gsfonts

# Install bundler
RUN gem install --no-document bundler -v 2.2.27
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-issue-event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- name: post assigned issue event
run: |
curl -X POST https://fjord-choice.herokuapp.com/api/issues \
curl -f -X POST https://fjord-choice.herokuapp.com/api/issues \
-H 'Content-Type: application/json' \
-H 'Authorization: Token ${{ secrets.FJORD_CHOICE_TOKEN }}' \
-d '{"number": ${{ github.event.issue.number }},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-pr-event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- name: post review requested pr event
run: |
curl -X POST https://fjord-choice.herokuapp.com/api/pulls \
curl -f -X POST https://fjord-choice.herokuapp.com/api/pulls \
-H 'Content-Type: application/json' \
-H 'Authorization: Token ${{ secrets.FJORD_CHOICE_TOKEN }}' \
-d '{"title": ${{ toJson(github.event.pull_request.title) }},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_only_when_reviewer_approved.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- name: post approved pr event
run: |
curl -X POST https://fjord-choice.herokuapp.com/api/pulls \
curl -f -X POST https://fjord-choice.herokuapp.com/api/pulls \
-H 'Content-Type: application/json' \
-H 'Authorization: Token ${{ secrets.FJORD_CHOICE_TOKEN }}' \
-d '{"title": ${{ toJson(github.event.pull_request.title) }},
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ RUN apk add --no-cache \
tzdata && \
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

# ImageMagick
RUN apk add --no-cache imagemagick imagemagick-heic imagemagick-jpeg imagemagick-pdf imagemagick-svg imagemagick-webp bash pngcrush optipng=0.7.8-r0 ghostscript-fonts
# libvips
RUN apk add --no-cache vips-dev orc-dev bash pngcrush optipng=0.7.8-r0 ghostscript-fonts

# Install npm packages
COPY package.json yarn.lock ./
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ GEM
raabro (1.4.0)
racc (1.7.3)
rack (2.2.8.1)
rack-cors (2.0.1)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-dev-mark (0.7.11)
rack (>= 1.1, < 4.0)
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@

## インストールと起動

```
$ bin/setup
$ foreman start -f Procfile.dev
```
### 1. OSに応じた画像ライブラリの設定
wiki 内の[画像ライブラリの設定](https://github.com/fjordllc/bootcamp/wiki/%E7%94%BB%E5%83%8F%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA%E3%81%AE%E8%A8%AD%E5%AE%9A)ページを参照してください。

## practiceの所要時間の集計

学習時間記入した日報を投稿した上で、
### 2. OS共通の設定とサーバーの起動

```
$ rake bootcamp:statistics:save_learning_minute_statistics
$ bin/setup
$ foreman start -f Procfile.dev
```

## テスト
Expand Down
38 changes: 0 additions & 38 deletions app/controllers/api/memos_controller.rb

This file was deleted.

3 changes: 1 addition & 2 deletions app/controllers/api/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def show
def update
question = Question.find(params[:id])
if question.update(question_params)
Newspaper.publish(:question_update, { question: }) if question.saved_change_to_wip?
head :ok
else
head :bad_request
Expand All @@ -41,6 +40,6 @@ def update
private

def question_params
params.require(:question).permit(:title, :description, :practice_id, :tag_list, :wip)
params.require(:question).permit(:tag_list)
end
end
18 changes: 1 addition & 17 deletions app/controllers/api/talks/action_uncompleted_controller.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# frozen_string_literal: true

class API::Talks::ActionUncompletedController < API::BaseController
PAGER_NUMBER = 20

def index
@talks = Talk.joins(:user)
.includes(user: [{ avatar_attachment: :blob }, :discord_profile])
.action_uncompleted
.order(updated_at: :desc, id: :asc)
@talks =
if params[:search_word]
@talks.merge(
User.search_by_keywords({ word: params[:search_word] })
.unscope(where: :retired_on)
)
else
@talks.page(params[:page]).per(PAGER_NUMBER)
end
end
def index; end
end
21 changes: 1 addition & 20 deletions app/controllers/api/talks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,8 @@

class API::TalksController < API::BaseController
ALLOWED_TARGETS = %w[all student_and_trainee mentor graduate adviser trainee retired].freeze
PAGER_NUMBER = 20

def index
@target = params[:target]
@talks = Talk.joins(:user)
.includes(user: [{ avatar_attachment: :blob }, :discord_profile])
.order(updated_at: :desc, id: :asc)
users = User.users_role(@target, allowed_targets: ALLOWED_TARGETS, default_target: 'all')
@talks =
if params[:search_word]
# search_by_keywords内では { unretired } というスコープが設定されている
# 退会したユーザーも検索対象に含めたいので、unscope(where: :retired_on) で上記のスコープを削除
searched_users = users.search_by_keywords(word: params[:search_word]).unscope(where: :retired_on)
# もし検索対象が退会したユーザーである場合、searched_usersには退会していないユーザーも含まれているため、retired スコープを設定する
searched_users = searched_users.retired if @target == 'retired'
@talks.merge(searched_users)
else
@talks.merge(users)
.page(params[:page]).per(PAGER_NUMBER)
end
end
def index; end

def update
talk = Talk.find(params[:id])
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/api/users/areas_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class API::Users::AreasController < API::BaseController
def index
tokyo_area_id = '13'
@users = Area.users(params[:region], params[:area] || tokyo_area_id)
end
end
4 changes: 3 additions & 1 deletion app/controllers/mentor/practices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ class Mentor::PracticesController < ApplicationController
before_action :set_course, only: %i[new]
before_action :set_practice, only: %i[edit update]

def index; end
def index
@practices = Practice.preload(:categories, :products, :reports, :questions).order(:id)
end

def new
@practice = Practice.new
Expand Down
65 changes: 29 additions & 36 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,26 @@
class QuestionsController < ApplicationController
include Rails.application.routes.url_helpers
before_action :set_question, only: %i[show destroy]
before_action :set_editable_question, only: %i[edit update]
before_action :set_categories, only: %i[new show create]
before_action :set_watch, only: %i[show]
before_action :require_admin_or_mentor_login, only: [:destroy]
skip_before_action :require_active_user_login, only: %i[show]

QuestionsProperty = Struct.new(:title, :empty_message)

MAX_PRACTICE_QUESTIONS_DISPLAYED = 20

def index
questions =
case params[:target]
when 'solved'
Question.solved
when 'not_solved'
Question.not_solved.not_wip
else
Question.all
end
@tag = ActsAsTaggableOn::Tag.find_by(name: params[:tag])
@tags = Question.all.all_tags
questions = params[:practice_id].present? ? questions.where(practice_id: params[:practice_id]) : questions
questions = questions.tagged_with(params[:tag]) if params[:tag]
@questions = questions
@questions = Question
.by_target(params[:target])
.by_practice_id(params[:practice_id])
.by_tag(params[:tag])
.with_avatar
.includes(:practice, :answers, :tags, :correct_answer)
.order(updated_at: :desc, id: :desc)
.latest_update_order
.page(params[:page])
@questions_property = questions_property
@questions_property = Question.generate_questions_property(params[:target])
end

def show
Expand All @@ -40,7 +31,7 @@ def show
.where(practice: @question.practice)
.where.not(id: @question.id)
.includes(:correct_answer)
.order(updated_at: :desc, id: :desc)
.latest_update_order
.limit(MAX_PRACTICE_QUESTIONS_DISPLAYED)
respond_to do |format|
format.html
Expand All @@ -58,18 +49,29 @@ def new
@question = Question.new
end

def edit; end

def create
@question = Question.new(question_params)
@question.user = current_user
@question.wip = params[:commit] == 'WIP'
@question = current_user.questions.new(question_params)
set_wip
if @question.save
Newspaper.publish(:question_create, { question: @question })
redirect_to @question, notice: notice_message(@question)
redirect_to Redirection.determin_url(self, @question), notice: @question.generate_notice_message(:create)
else
render :new
end
end

def update
set_wip
if @question.update(question_params)
Newspaper.publish(:question_update, { question: @question }) if @question.saved_change_to_wip?
redirect_to Redirection.determin_url(self, @question), notice: @question.generate_notice_message(:update)
else
render :edit
end
end

def destroy
@question.destroy
redirect_to questions_url, notice: '質問を削除しました。'
Expand All @@ -81,6 +83,10 @@ def set_question
@question = Question.find(params[:id])
end

def set_editable_question
@question = current_user.mentor? ? Question.find(params[:id]) : current_user.questions.find(params[:id])
end

def set_categories
@categories =
Category
Expand All @@ -97,20 +103,7 @@ def set_watch
@watch = Watch.new
end

def questions_property
case params[:target]
when 'solved'
QuestionsProperty.new('解決済みのQ&A', '解決済みのQ&Aはありません。')
when 'not_solved'
QuestionsProperty.new('未解決のQ&A', '未解決のQ&Aはありません。')
else
QuestionsProperty.new('全てのQ&A', 'Q&Aはありません。')
end
end

def notice_message(question)
return '質問をWIPとして保存しました。' if question.wip?

'質問を作成しました。'
def set_wip
@question.wip = params[:commit] == 'WIP'
end
end
Loading

0 comments on commit 3ea7148

Please sign in to comment.