| @@ -3,7 +3,7 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController | |||||
| def personal | def personal | ||||
| @enterprise_identifier = params[:enterprise_identifier] || '' | @enterprise_identifier = params[:enterprise_identifier] || '' | ||||
| return render_error('请输入正确的用户ID.') if params[:user_id].blank? | return render_error('请输入正确的用户ID.') if params[:user_id].blank? | ||||
| @all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['authored', 'assigned']}) | |||||
| @all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['assigned']}) | |||||
| @all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) | @all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) | ||||
| @this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct | @this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct | ||||
| @this_week_all_issues = @this_week_all_issues.order('created_on desc') | @this_week_all_issues = @this_week_all_issues.order('created_on desc') | ||||
| @@ -65,7 +65,7 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController | |||||
| def personal_issues | def personal_issues | ||||
| @enterprise_identifier = params[:enterprise_identifier] || '' | @enterprise_identifier = params[:enterprise_identifier] || '' | ||||
| return render_error('请输入正确的用户ID.') if params[:user_id].blank? | return render_error('请输入正确的用户ID.') if params[:user_id].blank? | ||||
| @all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['authored', 'assigned']}) | |||||
| @all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['assigned']}) | |||||
| @all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) | @all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) | ||||
| @this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct | @this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct | ||||
| @this_week_all_issues = @this_week_all_issues.order('created_on desc') | @this_week_all_issues = @this_week_all_issues.order('created_on desc') | ||||
| @@ -17,6 +17,7 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| def insert_file | def insert_file | ||||
| checkout_url = 'https://gitlink.org.cn/KingChan/checkout@v4' | checkout_url = 'https://gitlink.org.cn/KingChan/checkout@v4' | ||||
| scanner_url = 'https://gitlink.org.cn/KingChan/sonarqube-scan-action@master' | scanner_url = 'https://gitlink.org.cn/KingChan/sonarqube-scan-action@master' | ||||
| doxygen_url = "https://gitlink.gitlink.net" | |||||
| begin | begin | ||||
| config = Rails.application.config_for(:configuration) | config = Rails.application.config_for(:configuration) | ||||
| sonarqube_config = config.dig('sonarqube') | sonarqube_config = config.dig('sonarqube') | ||||
| @@ -27,7 +28,9 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| if sonarqube_config.present? && sonarqube_config['scanner'].present? | if sonarqube_config.present? && sonarqube_config['scanner'].present? | ||||
| scanner_url = sonarqube_config['scanner'] | scanner_url = sonarqube_config['scanner'] | ||||
| end | end | ||||
| if sonarqube_config.present? && sonarqube_config['doxygen'].present? | |||||
| doxygen_url = sonarqube_config['doxygen'] | |||||
| end | |||||
| raise 'sonar config missing' if sonarqube_config.blank? | raise 'sonar config missing' if sonarqube_config.blank? | ||||
| rescue => ex | rescue => ex | ||||
| raise ex if Rails.env.production? | raise ex if Rails.env.production? | ||||
| @@ -61,6 +64,9 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| with: | with: | ||||
| # Disabling shallow clones is recommended for improving the relevancy of reporting | # Disabling shallow clones is recommended for improving the relevancy of reporting | ||||
| fetch-depth: 0 | fetch-depth: 0 | ||||
| - name: curl doxygen | |||||
| run: | | |||||
| curl -X GET #{doxygen_url}/generate?repo=#{@project.repository.url} | |||||
| - name: SonarQube Scan | - name: SonarQube Scan | ||||
| uses: #{scanner_url} | uses: #{scanner_url} | ||||
| env: | env: | ||||
| @@ -87,7 +93,7 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| filepath: 'sonar-project.properties', | filepath: 'sonar-project.properties', | ||||
| branch: params[:branch], | branch: params[:branch], | ||||
| new_branch: nil, | new_branch: nil, | ||||
| "content": "sonar.projectKey=#{params[:owner]}-#{@project.id}\nsonar.sources=.\nsonar.java.binaries=.", | |||||
| "content": "sonar.projectKey=#{params[:owner]}-#{@project.id}\nsonar.projectVersion=1.0\nsonar.sourceEncoding=UTF-8\nsonar.sources=.\nsonar.java.binaries=target/classes,build/classes\nsonar.javascript.lcov.reportPaths=coverage/lcov.info\nsonar.python.coverage.reportPaths=coverage.xml\nsonar.cxx.file.suffixes=.h,.cpp", | |||||
| "message": 'Add sonar-project.properties', | "message": 'Add sonar-project.properties', | ||||
| committer: { | committer: { | ||||
| email: @owner.mail, | email: @owner.mail, | ||||
| @@ -148,6 +154,14 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| render_ok data | render_ok data | ||||
| end | end | ||||
| def doxygen_url | |||||
| config = Rails.application.config_for(:configuration) | |||||
| sonarqube_config = config.dig('sonarqube') | |||||
| doxygen_url = sonarqube_config['doxygen'] | |||||
| data = {doxygen_url: "#{doxygen_url}/files/#{@project.owner.login}/#{@project.identifier}/html/"} | |||||
| render_ok data | |||||
| end | |||||
| def measures_search_history | def measures_search_history | ||||
| params_data = { | params_data = { | ||||
| from: params[:form], | from: params[:form], | ||||
| @@ -60,7 +60,7 @@ class Api::Pm::Issues::CreateService < ApplicationService | |||||
| if @root_subject.present? && [4, 5].include?(@pm_issue_type.to_i) | if @root_subject.present? && [4, 5].include?(@pm_issue_type.to_i) | ||||
| @root_issue = Issue.find_by(subject: @root_subject, pm_issue_type: [4,5], pm_project_id: @pm_project_id,enterprise_identifier: @enterprise_identifier) | @root_issue = Issue.find_by(subject: @root_subject, pm_issue_type: [4,5], pm_project_id: @pm_project_id,enterprise_identifier: @enterprise_identifier) | ||||
| unless @root_issue.present? | unless @root_issue.present? | ||||
| @root_issue = Issue.create(subject: @root_subject, pm_issue_type: [4,5], pm_project_id: @pm_project_id, enterprise_identifier: @enterprise_identifier, status_id: 1, priority_id: 1, tracker_id: Tracker.first.id, project_id: @project.id, author_id: current_user.id) | |||||
| @root_issue = Issue.create(subject: @root_subject, pm_issue_type: @pm_issue_type.to_i, pm_project_id: @pm_project_id, enterprise_identifier: @enterprise_identifier, status_id: 1, priority_id: 1, tracker_id: Tracker.first.id, project_id: @project.id, author_id: current_user.id) | |||||
| end | end | ||||
| @created_issue.root_id = @root_issue.id | @created_issue.root_id = @root_issue.id | ||||
| else | else | ||||
| @@ -97,8 +97,8 @@ class Api::V1::Issues::ListService < ApplicationService | |||||
| end | end | ||||
| end | end | ||||
| issues = issues.where(enterprise_identifier: enterprise_identifier) if enterprise_identifier.present? && [4,5].include?(pm_issue_type.to_i) | |||||
| issues = issues.where(enterprise_identifier: enterprise_identifier) if enterprise_identifier.present? && ([4,5].include?(pm_issue_type.to_i) || pm_issue_types.present?) | |||||
| #pm相关 | #pm相关 | ||||
| # root_id# -1 查一级目录 | # root_id# -1 查一级目录 | ||||
| issues = if root_id.to_i == -1 | issues = if root_id.to_i == -1 | ||||
| @@ -151,7 +151,7 @@ class Api::V1::Issues::ListService < ApplicationService | |||||
| end | end | ||||
| if update_begin_date&.present? || update_end_date&.present? | if update_begin_date&.present? || update_end_date&.present? | ||||
| issues = issues.where('issues.updated_on between ? and ?', update_begin_date&.present? ? update_begin_date.to_time : Time.now.beginning_of_day, update_end_date&.present? ? update_end_date.to_time.end_of_day : Time.now.end_of_day) | |||||
| issues = issues.where('issues.updated_on between ? and ?', update_begin_date&.present? ? update_begin_date.to_time.beginning_of_week : Time.now.beginning_of_week, update_end_date&.present? ? update_end_date.to_time.end_of_week : Time.now.end_of_week) | |||||
| end | end | ||||
| # keyword | # keyword | ||||
| @@ -30,7 +30,11 @@ json.pm_issue_type issue.pm_issue_type | |||||
| json.pm_sprint_id issue.pm_sprint_id | json.pm_sprint_id issue.pm_sprint_id | ||||
| json.pm_project_id issue.pm_project_id | json.pm_project_id issue.pm_project_id | ||||
| json.time_scale issue.time_scale | json.time_scale issue.time_scale | ||||
| json.child_count issue.child_count | |||||
| if params[:pm_issue_types].present? | |||||
| json.child_count issue.children_issues.where(pm_issue_type: 4).count | |||||
| else | |||||
| json.child_count issue.child_count | |||||
| end | |||||
| json.author do | json.author do | ||||
| json.partial! "api/v1/users/simple_user", locals: {user: issue.user} | json.partial! "api/v1/users/simple_user", locals: {user: issue.user} | ||||
| @@ -118,6 +118,7 @@ defaults format: :json do | |||||
| post :sonar_initialize | post :sonar_initialize | ||||
| post :insert_file | post :insert_file | ||||
| get :doxygen_url | |||||
| end | end | ||||
| end | end | ||||