-
Notifications
You must be signed in to change notification settings - Fork 75
OAuth APIをpjord向けに拡張(全API Doorkeeper対応 + 研修生進捗エンドポイント) #9830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3931861
OAuth APIをpjord向けに拡張
38f8329
研修生進捗APIを週次レポート向けに拡張
e533ede
CodeRabbitレビュー対応
komagata a443036
ルート順序修正: reports namespaceをresources :reportsより前に配置
komagata 4208602
RuboCop offenses修正
komagata fbdf92f
CI再実行(前回はNet::ReadTimeout flaky failure)
komagata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class API::TraineeProgressesController < API::BaseController | ||
| def index | ||
| @trainees = User.trainees | ||
| .preload(:company, :course, :avatar_attachment, :active_practices, | ||
| :reports, learnings: :practice) | ||
| .order(:company_id, :created_at) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @trainees = @trainees.where(company_id: params[:company_id]) if params[:company_id].present? | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @week_start = parse_week_start | ||
| @week_end = @week_start + 4.days # 月〜金 | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def parse_week_start | ||
| if params[:week_start].present? | ||
| Date.parse(params[:week_start]) | ||
| else | ||
| Date.current.beginning_of_week | ||
| end | ||
| rescue ArgumentError | ||
| Date.current.beginning_of_week | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| json.partial! 'api/reports/report', report: @report | ||
| json.partial! 'api/reports/checks', checks: @report.checks | ||
|
|
||
| json.user do | ||
| json.partial! 'api/users/user', user: @report.user | ||
| end | ||
|
|
||
| json.practices @report.practices do |practice| | ||
| json.id practice.id | ||
| json.title practice.title | ||
| end | ||
|
|
||
| json.comments @report.comments.order(:created_at) do |comment| | ||
| json.id comment.id | ||
| json.description comment.description | ||
| json.createdAt comment.created_at | ||
| json.user do | ||
| json.partial! 'api/users/user', user: comment.user | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| json.weekStart @week_start | ||
| json.weekEnd @week_end | ||
|
|
||
| json.trainees @trainees do |trainee| # rubocop:disable Metrics/BlockLength | ||
| user_course_practice = UserCoursePractice.new(trainee) | ||
|
|
||
| # learningsを一度取得してフィルタリング | ||
| all_learnings = trainee.learnings.reject { |l| l.status == 'unstarted' } | ||
|
|
||
| week_learnings = all_learnings.select do |l| | ||
| l.updated_at >= @week_start.beginning_of_day && | ||
| l.updated_at <= @week_end.end_of_day | ||
| end | ||
|
|
||
| current_learning = all_learnings | ||
| .select { |l| l.status == 'started' } | ||
| .max_by(&:updated_at) | ||
|
|
||
| # 対象週の平日に対応する日報 | ||
| week_reports = trainee.reports | ||
| .select { |r| r.reported_on >= @week_start && r.reported_on <= @week_end && !r.wip? } | ||
| .sort_by(&:reported_on) | ||
|
|
||
| json.id trainee.id | ||
| json.loginName trainee.login_name | ||
| json.longName trainee.long_name | ||
| json.avatarUrl trainee.avatar_url | ||
|
|
||
| json.company do | ||
| if trainee.company.present? | ||
| json.id trainee.company.id | ||
| json.name trainee.company.name | ||
| end | ||
| end | ||
|
|
||
| json.course do | ||
| if trainee.course.present? | ||
| json.id trainee.course.id | ||
| json.title trainee.course.title | ||
| end | ||
| end | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 週次アクティビティ | ||
| json.weeklyActivity do | ||
| json.reportCount week_reports.size | ||
| json.weekdays 5 | ||
| json.reportDates(week_reports.map { |r| r.reported_on.to_s }) | ||
| json.practiceStatusChanges week_learnings.size | ||
| json.practiceChanges week_learnings do |learning| | ||
| json.practiceId learning.practice_id | ||
| json.practiceTitle learning.practice.title | ||
| json.status learning.status | ||
| json.updatedAt learning.updated_at | ||
| end | ||
| end | ||
|
|
||
| # 現在のプラクティス | ||
| json.currentPractice do | ||
| if current_learning | ||
| days_on_practice = (Date.current - current_learning.updated_at.to_date).to_i | ||
| json.id current_learning.practice_id | ||
| json.title current_learning.practice.title | ||
| json.daysOnPractice days_on_practice | ||
| end | ||
| end | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 全体進捗 | ||
| json.overallProgress do | ||
| json.completedPracticesCount user_course_practice.completed_required_practices.size | ||
| json.requiredPracticesCount user_course_practice.required_practices.size | ||
| json.completedPercentage user_course_practice.completed_percentage.round(1) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.