| @@ -30,8 +30,8 @@ class Api::Pm::BaseController < ApplicationController | |||||
| end | end | ||||
| def load_issue | def load_issue | ||||
| return render_parameter_missing if params[:pm_project_id].blank? | |||||
| @issue = Issue.issue_issue.where(pm_project_id: params[:pm_project_id]).find_by_id(params[:issue_id]) | |||||
| # return render_parameter_missing if params[:pm_project_id].blank? | |||||
| @issue = Issue.issue_issue.find_by_id(params[:issue_id]) | |||||
| render_not_found('疑修不存在!') if @issue.blank? | render_not_found('疑修不存在!') if @issue.blank? | ||||
| end | end | ||||
| # 具有对仓库的管理权限 | # 具有对仓库的管理权限 | ||||
| @@ -284,11 +284,18 @@ class Api::Pm::IssuesController < Api::Pm::BaseController | |||||
| end | end | ||||
| def load_issue | def load_issue | ||||
| return render_parameter_missing if params[:pm_project_id].blank? | |||||
| @issue = Issue.issue_issue.where(pm_project_id: params[:pm_project_id]).find_by_id(params[:id]) | |||||
| # return render_parameter_missing if params[:pm_project_id].blank? | |||||
| @issue = Issue.issue_issue.find_by_id(params[:id]) | |||||
| render_not_found('疑修不存在!') if @issue.blank? | render_not_found('疑修不存在!') if @issue.blank? | ||||
| end | end | ||||
| # def load_issue_by_index | |||||
| # return render_parameter_missing if params[:pm_project_id].blank? || params[:pm_issue_type].blank? || params[:enterprise_identifier].blank? | |||||
| # @issue = Issue.find_issues_by_pm(params[:enterprise_identifier], params[:pm_issue_type]) | |||||
| # .find_by(pm_issue_type_index3: params[:index]) | |||||
| # render_not_found('疑修不存在!') if @issue.blank? | |||||
| # end | |||||
| def load_issues | def load_issues | ||||
| return render_error('请输入正确的ID数组!') unless params[:ids].is_a?(Array) | return render_error('请输入正确的ID数组!') unless params[:ids].is_a?(Array) | ||||
| params[:ids].each do |id| | params[:ids].each do |id| | ||||
| @@ -315,7 +322,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController | |||||
| :update_begin_date, :update_end_date, | :update_begin_date, :update_end_date, | ||||
| :sort_by, :sort_direction, :root_id, | :sort_by, :sort_direction, :root_id, | ||||
| :issue_tag_ids, :pm_project_id, :pm_sprint_id, :pm_issue_type, :pm_project_ids, | :issue_tag_ids, :pm_project_id, :pm_sprint_id, :pm_issue_type, :pm_project_ids, | ||||
| :status_ids, :ids, :exclude_ids, :pm_issue_types, :participator_id | |||||
| :status_ids, :ids, :exclude_ids, :pm_issue_types, :participator_id, :enterprise_identifier | |||||
| ) | ) | ||||
| end | end | ||||
| @@ -327,6 +334,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController | |||||
| :branch_name, :start_date, :due_date, :time_scale, | :branch_name, :start_date, :due_date, :time_scale, | ||||
| :subject, :description, :blockchain_token_num, :root_subject, | :subject, :description, :blockchain_token_num, :root_subject, | ||||
| :pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :link_able_id, :project_id, | :pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :link_able_id, :project_id, | ||||
| :status_msg, :enterprise_identifier, | |||||
| issue_tag_ids: [], | issue_tag_ids: [], | ||||
| assigner_ids: [], | assigner_ids: [], | ||||
| attachment_ids: [], | attachment_ids: [], | ||||
| @@ -0,0 +1,77 @@ | |||||
| class Api::Pm::PipelinesController < Api::Pm::BaseController | |||||
| include RepositoriesHelper | |||||
| def index | |||||
| @owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s) | |||||
| tip_exception('组织未找到') if @owner.blank? | |||||
| unless @owner.is_a?(Organization) && @owner.is_member?(current_user.id) | |||||
| tip_exception('没有查看组织的权限') | |||||
| end | |||||
| @project_ids = @owner.projects.ids | |||||
| project_gpids = @owner.projects.pluck(:gpid) | |||||
| action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) | |||||
| group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count | |||||
| pipelines = Action::Pipeline.where(project_id: @project_ids).order(updated_at: :desc) | |||||
| run_files = Gitea::ActionRun.select(:workflow_id, :repo_id).where(owner_id: @owner.gitea_uid).group(:workflow_id, :repo_id) | |||||
| db_files = pipelines.pluck(:file_name) | |||||
| @run_result = [] | |||||
| run_files.each do |file_info| | |||||
| file = file_info.workflow_id | |||||
| project = Project.find_by(gpid: file_info.repo_id) | |||||
| next if project.blank? | |||||
| unless db_files.include?(".gitea/workflows/#{file}") | |||||
| pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), | |||||
| file_name: ".gitea/workflows/#{file}", | |||||
| branch: project.default_branch, | |||||
| is_graphic_design: false, | |||||
| disable: false, | |||||
| project_id: project.id) | |||||
| interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch) | |||||
| if interactor.success? | |||||
| pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil) | |||||
| end | |||||
| pipeline.user_id = current_user.id | |||||
| pipeline.save | |||||
| # 导入的流水线统一先禁用 | |||||
| $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil | |||||
| end | |||||
| last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first | |||||
| last_action_run_json = last_action_run.present? ? { | |||||
| id: last_action_run.id, | |||||
| schedule: last_action_run.schedule_id > 0, | |||||
| title: last_action_run.title, | |||||
| index: last_action_run.index, | |||||
| status: last_action_run.status, | |||||
| started: last_action_run.started, | |||||
| stopped: last_action_run.stopped, | |||||
| length: last_action_run.stopped-last_action_run.started, | |||||
| created: last_action_run.created, | |||||
| updated: last_action_run.updated, | |||||
| } : {} | |||||
| total = 0 | |||||
| success = 0 | |||||
| failure = 0 | |||||
| group_data.each do |k,v| | |||||
| total += v if k[0] == file | |||||
| success += v if k[0] == file && k[1] == 1 | |||||
| failure += v if k[0] == file && k[1] == 2 | |||||
| end | |||||
| @run_result << { | |||||
| repo_id: last_action_run.repo_id, | |||||
| filename: ".gitea/workflows/#{file}", | |||||
| total: total, | |||||
| success: success, | |||||
| failure: failure | |||||
| }.merge(last_action_run_json) | |||||
| end | |||||
| # Rails.logger.info("@run_result======#{@run_result}") | |||||
| @disabled_workflows = Gitea::RepoUnit.where(repo_id: project_gpids, type: 10).where("config is not null") | |||||
| @pipelines = Action::Pipeline.select("distinct project_id,max(updated_at) as updated_at") | |||||
| .where(project_id: @project_ids).group(:project_id).order("updated_at desc") | |||||
| @pipelines = @pipelines.where("pipeline_name like ?", "%#{params[:pipeline_name]}%") if params[:pipeline_name].present? | |||||
| @pipelines = @pipelines.where(pipeline_type: params[:pipeline_type]) if params[:pipeline_type].present? | |||||
| @pipelines = kaminari_paginate(@pipelines) | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,82 @@ | |||||
| class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController | |||||
| def personal | |||||
| @enterprise_identifier = params[:enterprise_identifier] || '' | |||||
| 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: ['assigned']}) | |||||
| @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 = @this_week_all_issues.order('created_on desc') | |||||
| @next_week_all_issues = @all_issues.where("due_date >= ? and start_date <=?", (Date.today.beginning_of_week+1.week).to_s, (Date.today.end_of_week+1.week).to_s).distinct | |||||
| @next_week_all_issues = @next_week_all_issues.order('created_on desc') | |||||
| @this_week_requirement_issues = @this_week_all_issues.where(pm_issue_type: 1) | |||||
| @this_week_task_issues = @this_week_all_issues.where(pm_issue_type: 2) | |||||
| @this_week_bug_issues = @this_week_all_issues.where(pm_issue_type: 3) | |||||
| @close_requirement_issues = @this_week_requirement_issues.where(status_id: [3,5]) | |||||
| @close_task_issues = @this_week_task_issues.where(status_id: [3,5]) | |||||
| @close_bug_issues = @this_week_bug_issues.where(status_id: [3,5]) | |||||
| this_week_page = params[:this_week_page] || 1 | |||||
| this_week_limit = params[:this_week_limit] || 15 | |||||
| @this_week_all_issues = @this_week_all_issues.page(this_week_page).per(this_week_limit) | |||||
| next_week_page = params[:next_week_page] || 1 | |||||
| next_week_limit = params[:next_week_limit] || 15 | |||||
| @next_week_all_issues = @next_week_all_issues.page(next_week_page).per(next_week_limit) | |||||
| end | |||||
| def group | |||||
| @enterprise_identifier = params[:enterprise_identifier] || '' | |||||
| @all_issues = Issue.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) | |||||
| @all_issues = @all_issues.where(pm_project_id: params[:pm_project_ids].split(",")) if params[:pm_project_ids].present? | |||||
| @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) | |||||
| @this_week_all_issues_group_count = @this_week_all_issues.group(:pm_project_id).count | |||||
| data = {} | |||||
| @this_week_all_issues_group_count.keys.each do |pm_project_id| | |||||
| this_project_id_requirements = @this_week_all_issues.where(pm_project_id: pm_project_id, pm_issue_type: 1) | |||||
| this_project_id_tasks = @this_week_all_issues.where(pm_project_id: pm_project_id, pm_issue_type: 2) | |||||
| this_project_id_bugs = @this_week_all_issues.where(pm_project_id: pm_project_id, pm_issue_type: 3) | |||||
| this_project_id_close_requirements = this_project_id_requirements.where(status_id: [3,5]) | |||||
| this_project_id_close_tasks = this_project_id_tasks.where(status_id: [3,5]) | |||||
| this_project_id_close_bugs = this_project_id_bugs.where(status_id: [3,5]) | |||||
| data[pm_project_id] = { | |||||
| this_week_requirement_issues_count: this_project_id_requirements.count, | |||||
| this_week_task_issues_count: this_project_id_tasks.count, | |||||
| this_week_bug_issues_count: this_project_id_bugs.count, | |||||
| close_requirement_issues_count: this_project_id_close_requirements.count, | |||||
| close_task_issues_count: this_project_id_close_tasks.count, | |||||
| close_bug_issues_count: this_project_id_close_bugs.count, | |||||
| this_week_task_issues: this_project_id_tasks | |||||
| } | |||||
| end | |||||
| render :json => data | |||||
| end | |||||
| def group_issues | |||||
| @enterprise_identifier = params[:enterprise_identifier] || '' | |||||
| @all_issues = Issue.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) | |||||
| @all_issues = @all_issues.where(pm_project_id: params[:pm_project_ids].split(",")) if params[:pm_project_ids].present? | |||||
| @all_issues = @all_issues.where(pm_issue_type: params[:pm_issue_type].to_i) if params[:pm_issue_type].present? | |||||
| @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) | |||||
| @this_week_all_issues = @this_week_all_issues.order('created_on desc') | |||||
| @this_week_all_issues = kaminari_paginate(@this_week_all_issues) | |||||
| end | |||||
| def personal_issues | |||||
| @enterprise_identifier = params[:enterprise_identifier] || '' | |||||
| 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: ['assigned']}) | |||||
| @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 = @this_week_all_issues.order('created_on desc') | |||||
| @next_week_all_issues = @all_issues.where("due_date >= ? and start_date <=?", (Date.today.beginning_of_week+1.week).to_s, (Date.today.end_of_week+1.week).to_s).distinct | |||||
| @next_week_all_issues = @next_week_all_issues.order('created_on desc') | |||||
| this_week_page = params[:this_week_page] || 1 | |||||
| this_week_limit = params[:this_week_limit] || 15 | |||||
| @this_week_all_issues = @this_week_all_issues.page(this_week_page).per(this_week_limit) | |||||
| next_week_page = params[:next_week_page] || 1 | |||||
| next_week_limit = params[:next_week_limit] || 15 | |||||
| @next_week_all_issues = @next_week_all_issues.page(next_week_page).per(next_week_limit) | |||||
| end | |||||
| end | |||||
| @@ -1,9 +1,12 @@ | |||||
| class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController | class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController | ||||
| def index | def index | ||||
| @result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token) | |||||
| @begin_num = (page.to_i - 1) * limit.to_i | |||||
| # puts @result_object | |||||
| @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") rescue [] | |||||
| @has_file = @files.select { |i| i['name'] == params[:workflow] }.present? | |||||
| if @has_file | |||||
| @result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token) | |||||
| @begin_num = (page.to_i - 1) * limit.to_i | |||||
| end | |||||
| end | end | ||||
| def create | def create | ||||
| @@ -36,11 +36,13 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController | |||||
| def create | def create | ||||
| @result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token) | @result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token) | ||||
| @project.update_column(:updated_on, Time.now) | |||||
| end | end | ||||
| def destroy | def destroy | ||||
| @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:name], current_user&.gitea_token) | @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:name], current_user&.gitea_token) | ||||
| if @result_object | if @result_object | ||||
| @project.update_column(:updated_on, Time.now) | |||||
| # 有开启的pr需要一同关闭 | # 有开启的pr需要一同关闭 | ||||
| # 1、删除本仓库中存在未关闭的pr,即本仓库分支1->分支2 | # 1、删除本仓库中存在未关闭的pr,即本仓库分支1->分支2 | ||||
| # 2、如果是fork仓库,考虑删除主仓库中存在未关闭的pr,即本仓库:分支1->主:分支2,同时分两种删除:1删除本仓库分支1,2删除主仓库分支2 | # 2、如果是fork仓库,考虑删除主仓库中存在未关闭的pr,即本仓库:分支1->主:分支2,同时分两种删除:1删除本仓库分支1,2删除主仓库分支2 | ||||
| @@ -59,6 +61,7 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController | |||||
| def restore | def restore | ||||
| @result_object = Api::V1::Projects::Branches::RestoreService.call(@project, params[:branch_id], params[:branch_name], current_user&.gitea_token) | @result_object = Api::V1::Projects::Branches::RestoreService.call(@project, params[:branch_id], params[:branch_name], current_user&.gitea_token) | ||||
| if @result_object | if @result_object | ||||
| @project.update_column(:updated_on, Time.now) | |||||
| return render_ok | return render_ok | ||||
| else | else | ||||
| return render_error('恢复分支失败!') | return render_error('恢复分支失败!') | ||||
| @@ -70,6 +73,7 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController | |||||
| def update_default_branch | def update_default_branch | ||||
| @result_object = Api::V1::Projects::Branches::UpdateDefaultBranchService.call(@project, params[:name], current_user&.gitea_token) | @result_object = Api::V1::Projects::Branches::UpdateDefaultBranchService.call(@project, params[:name], current_user&.gitea_token) | ||||
| if @result_object | if @result_object | ||||
| @project.update_column(:updated_on, Time.now) | |||||
| return render_ok | return render_ok | ||||
| else | else | ||||
| return render_error('更新默认分支失败!') | return render_error('更新默认分支失败!') | ||||
| @@ -11,13 +11,11 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||||
| @run_result = [] | @run_result = [] | ||||
| @files.map { |i| i['name'] }.each do |file| | @files.map { |i| i['name'] }.each do |file| | ||||
| unless db_files.include?(".gitea/workflows/#{file}") | unless db_files.include?(".gitea/workflows/#{file}") | ||||
| disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config | |||||
| disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] | |||||
| pipeline = Action::Pipeline.new(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), | |||||
| pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), | |||||
| file_name: ".gitea/workflows/#{file}", | file_name: ".gitea/workflows/#{file}", | ||||
| branch: @project.default_branch, | branch: @project.default_branch, | ||||
| is_graphic_design: false, | is_graphic_design: false, | ||||
| disable: disabled_workflows.include?(file.to_s), | |||||
| disable: false, | |||||
| project_id: @project.id) | project_id: @project.id) | ||||
| interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, ".gitea/workflows/#{file}", ref: @project.default_branch) | interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, ".gitea/workflows/#{file}", ref: @project.default_branch) | ||||
| if interactor.success? | if interactor.success? | ||||
| @@ -25,6 +23,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||||
| end | end | ||||
| pipeline.user_id = current_user.id | pipeline.user_id = current_user.id | ||||
| pipeline.save | pipeline.save | ||||
| # 导入的流水线统一先禁用 | |||||
| $gitea_hat_client.post_repos_actions_disable(@project&.owner&.login, @project&.identifier, {query: {workflow: file}}) rescue nil | |||||
| end | end | ||||
| last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first | last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first | ||||
| last_action_run_json = last_action_run.present? ? { | last_action_run_json = last_action_run.present? ? { | ||||
| @@ -55,9 +55,11 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||||
| failure: failure | failure: failure | ||||
| }.merge(last_action_run_json) | }.merge(last_action_run_json) | ||||
| end | end | ||||
| Rails.logger.info("@run_result======#{@run_result}") | |||||
| # Rails.logger.info("@run_result======#{@run_result}") | |||||
| disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config | |||||
| @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] | |||||
| @pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) | @pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) | ||||
| @pipelines = paginate @pipelines | |||||
| @pipelines = kaminari_paginate(@pipelines) | |||||
| end | end | ||||
| def test_yaml | def test_yaml | ||||
| @@ -94,14 +96,15 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||||
| def save_yaml | def save_yaml | ||||
| @pipeline = params[:id].present? ? Action::Pipeline.find(params[:id]) : Action::Pipeline.find_or_initialize_by(pipeline_name: params[:pipeline_name], project_id: @project.id) | @pipeline = params[:id].present? ? Action::Pipeline.find(params[:id]) : Action::Pipeline.find_or_initialize_by(pipeline_name: params[:pipeline_name], project_id: @project.id) | ||||
| @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yml" | @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yml" | ||||
| @pipeline.branch = params[:branch] || @project.default_branch | |||||
| @pipeline.branch = params[:branch] if params[:branch].present? | |||||
| @pipeline.json = params[:pipeline_json].to_json if params[:pipeline_json].present? | @pipeline.json = params[:pipeline_json].to_json if params[:pipeline_json].present? | ||||
| @pipeline.pipeline_name = params[:pipeline_name] if params[:pipeline_name].present? | @pipeline.pipeline_name = params[:pipeline_name] if params[:pipeline_name].present? | ||||
| pipeline_yaml = params[:pipeline_yaml].present? ? params[:pipeline_yaml] : build_pipeline_yaml_new(@pipeline.pipeline_name, params[:pipeline_json]) | pipeline_yaml = params[:pipeline_yaml].present? ? params[:pipeline_yaml] : build_pipeline_yaml_new(@pipeline.pipeline_name, params[:pipeline_json]) | ||||
| tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank? | tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank? | ||||
| @pipeline.yaml = pipeline_yaml | @pipeline.yaml = pipeline_yaml | ||||
| Rails.logger.info "pipeline_yaml base64=========================#{Base64.encode64(@pipeline.yaml).gsub(/\n/, '')}" | |||||
| #Rails.logger.info "pipeline_yaml base64=========================#{Base64.encode64(@pipeline.yaml).gsub(/\n/, '')}" | |||||
| sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) | sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) | ||||
| #Rails.logger.info "content_params=========#{content_params("create")}" | |||||
| interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) | interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) | ||||
| tip_exception(interactor.error) unless interactor.success? | tip_exception(interactor.error) unless interactor.success? | ||||
| file = interactor.result | file = interactor.result | ||||
| @@ -145,6 +148,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||||
| interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params(sha).merge(identifier: @project.identifier)) | interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params(sha).merge(identifier: @project.identifier)) | ||||
| tip_exception(interactor.error) unless interactor.success? | tip_exception(interactor.error) unless interactor.success? | ||||
| end | end | ||||
| Gitea::ActionRun.where(repo_id: @pipeline.project.gpid).destroy_all | |||||
| @pipeline.destroy! | @pipeline.destroy! | ||||
| end | end | ||||
| render_ok | render_ok | ||||
| @@ -176,6 +180,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||||
| def show | def show | ||||
| @pipeline = Action::Pipeline.find_by(id: params[:id]) | @pipeline = Action::Pipeline.find_by(id: params[:id]) | ||||
| disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config | |||||
| @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] | |||||
| # @pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank? | # @pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank? | ||||
| end | end | ||||
| @@ -2,51 +2,203 @@ class Api::V1::Projects::PortraitController < Api::V1::BaseController | |||||
| before_action :require_public_and_member_above | before_action :require_public_and_member_above | ||||
| def index | def index | ||||
| platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| Cache::V2::PlatformStatisticService.new().reset | |||||
| @platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| # 社区影响力 | # 社区影响力 | ||||
| praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count | praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count | ||||
| praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count | |||||
| watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count | watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count | ||||
| fork_count = ForkUser.where(project_id: @project.id).count | fork_count = ForkUser.where(project_id: @project.id).count | ||||
| community_impact_praise = platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/platform_statistic['max-praise-count'].to_i) | |||||
| community_impact_watcher = platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/platform_statistic['max-watcher-count'].to_i) | |||||
| community_impact_fork = platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/platform_statistic['max-fork-count'].to_i) | |||||
| community_impact_praise = @platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/@platform_statistic['max-praise-count'].to_i) | |||||
| community_impact_watcher = @platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/@platform_statistic['max-watcher-count'].to_i) | |||||
| community_impact_fork = @platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/@platform_statistic['max-fork-count'].to_i) | |||||
| community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork) | community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork) | ||||
| # 项目成熟度 | # 项目成熟度 | ||||
| pullrequest_count = PullRequest.where(project_id: @project.id).count | |||||
| issue_count = Issue.issue_issue.where(project_id: @project.id).count | |||||
| commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).count | |||||
| project_maturity_pullrequest = platform_statistic['max-pullrequest-count'].to_i == 0 ? 0 : 30*(pullrequest_count.to_f/platform_statistic['max-pullrequest-count'].to_i) | |||||
| project_maturity_issue = platform_statistic['max-issue-count'].to_i == 0 ? 0 : 30*(issue_count.to_f/platform_statistic['max-issue-count'].to_i) | |||||
| project_maturity_commit = platform_statistic['max-commit-count'].to_i == 0 ? 0 : 40*(commit_count.to_f/platform_statistic['max-commit-count'].to_i) | |||||
| project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_issue + project_maturity_commit) | |||||
| pullrequest_count = PullRequest.where(project_id: @project.id).count | |||||
| complete_issue_count = Issue.issue_issue.where(project_id: @project.id, status_id: [3,5]).count | |||||
| project_create_day = (Time.now.to_i - @project.created_on.to_i)/(3600*24) | |||||
| max_project_create_day = (Time.now.to_i - Project.order("created_on desc").last.created_on.to_i)/(3600*24) | |||||
| project_maturity_pullrequest = @platform_statistic['max-pullrequest-count'].to_i == 0? 0 : 40*(pullrequest_count.to_f/@platform_statistic['max-pullrequest-count'].to_i) | |||||
| project_maturity_complete_issue = @platform_statistic['max-complete-issue-count'].to_i == 0? 0 : 40*(complete_issue_count.to_f/@platform_statistic['max-complete-issue-count'].to_i) | |||||
| project_maturity_project_create_day = max_project_create_day.to_i <= 0 || project_create_day.to_i <= 0 ? 0 : 20*(Math.sqrt(project_create_day).to_f/Math.sqrt(max_project_create_day)) | |||||
| project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_complete_issue + project_maturity_project_create_day) | |||||
| # 项目健康度 | # 项目健康度 | ||||
| closed_pullrequest_count = PullRequest.where(project_id: @project.id).merged_and_closed.count | |||||
| closed_issue_count = Issue.issue_issue.where(project_id: @project.id).closed.count | |||||
| member_count = Member.where(project_id: @project.id).count | |||||
| max_member_count = @platform_statistic['max-member-count'].to_i | |||||
| project_last_commit = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).order("created_at desc").first | |||||
| last_commit_day = project_last_commit.present? ? (Time.now.to_i - project_last_commit.created_at.to_i)/(3600*24) : 0 | |||||
| has_license = @project.license.present? ? 1 : 0 | has_license = @project.license.present? ? 1 : 0 | ||||
| project_health_issue = (issue_count < 10 || closed_issue_count < 10) ? 0 : 40*(closed_issue_count-10).to_f/(issue_count-10) | |||||
| project_health_pullrequest = (pullrequest_count < 5 || closed_pullrequest_count < 5) ? 0 : 30*(closed_pullrequest_count-5).to_f/(pullrequest_count-5) | |||||
| project_health_license = 20*has_license | |||||
| project_health = format("%.2f", project_health_issue + project_health_pullrequest + project_health_license) | |||||
| closed_pullrequest_count = PullRequest.where(project_id: @project.id).merged_and_closed.count | |||||
| closed_issue_count = Issue.issue_issue.where(project_id: @project.id).closed.count | |||||
| pullrequest_count = PullRequest.where(project_id: @project.id).count | |||||
| issue_count = Issue.issue_issue.where(project_id: @project.id).count | |||||
| health_code1 = max_member_count.to_i == 0 ? 0 : 0.3*(member_count.to_f/max_member_count) | |||||
| health_code2 = last_commit_day.to_i == 0 ? 0 : 0.7*(1.to_f/(1+last_commit_day)) | |||||
| health_code = 10 * (health_code1 + health_code2) | |||||
| health_license = 10 * has_license | |||||
| health_pullrequest = pullrequest_count <= 1 ? 0 : 40 * (closed_pullrequest_count.to_f/pullrequest_count)*(1-1/Math.sqrt(pullrequest_count+1)) | |||||
| health_issue = issue_count <= 1 ? 0 : 40 * (closed_issue_count.to_f/issue_count)*(1-1/Math.sqrt(issue_count+1)) | |||||
| project_health = format("%.2f", health_code + health_license + health_pullrequest + health_issue) | |||||
| # 团队影响度 | # 团队影响度 | ||||
| member_count = Member.where(project_id: @project.id).count | |||||
| recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on > ?", Time.now - 30.days).count | |||||
| team_impact_member = platform_statistic['max-member-count'].to_i == 0 ? 0 : 40*(member_count.to_f/platform_statistic['max-member-count'].to_i) | |||||
| team_impact_recent_member = platform_statistic['max-recent-one-month-member-count'].to_i == 0 ? 0 : 60*(recent_one_month_member_count.to_f/platform_statistic['max-recent-one-month-member-count'].to_i) | |||||
| team_impact = format("%.2f", team_impact_member + team_impact_recent_member) | |||||
| member_count = Member.where(project_id: @project.id).count | |||||
| max_member_count = @platform_statistic['max-member-count'].to_i | |||||
| recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on >?", Time.now - 30.days).count | |||||
| max_recent_one_month_member_count = @platform_statistic['max-recent-one-month-member-count'].to_i | |||||
| issue_assigner_count = IssueAssigner.joins(:issue).merge(Issue.issue_issue).where(issues: {project_id: @project.id}).distinct.count | |||||
| team_impact_member = 40*(member_count.to_f/max_member_count) | |||||
| team_impact_recent_member = 40*(recent_one_month_member_count.to_f/max_recent_one_month_member_count) | |||||
| team_impact_issue_assigner = 20*(issue_assigner_count.to_f/max_member_count) | |||||
| team_impact = format("%.2f", team_impact_member + team_impact_recent_member + team_impact_issue_assigner) | |||||
| # 开发活跃度 | # 开发活跃度 | ||||
| recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count | |||||
| recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on > ?", Time.now - 30.days).count | |||||
| recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count | |||||
| develop_activity_pullrequest = platform_statistic['max-recent-one-month-pullrequest-count'].to_i == 0 ? 0 : 20*(recent_one_month_pullrequest_count.to_f/platform_statistic['max-recent-one-month-pullrequest-count'].to_i) | |||||
| develop_activity_issue = platform_statistic['max-recent-one-month-issue-count'].to_i == 0 ? 0 : 20*(recent_one_month_issue_count.to_f/platform_statistic['max-recent-one-month-issue-count'].to_i) | |||||
| develop_activity_commit = platform_statistic['max-recent-one-month-commit-count'].to_i == 0 ? 0 : 40*(recent_one_month_commit_count.to_f/platform_statistic['max-recent-one-month-commit-count'].to_i) | |||||
| develop_activity = format("%.2f", 20 + develop_activity_pullrequest + develop_activity_issue + develop_activity_commit) | |||||
| recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count | |||||
| recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count | |||||
| recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on >?", Time.now - 30.days).count | |||||
| recent_one_month_release_count = VersionRelease.joins(:repository).where(repositories: {project_id: @project.id}).where("created_at >?", Time.now - 30.days).count | |||||
| max_recent_one_month_commit_count = @platform_statistic['max-recent-one-month-commit-count'].to_i | |||||
| max_recent_one_month_pullrequest_count = @platform_statistic['max-recent-one-month-pullrequest-count'].to_i | |||||
| max_recent_one_month_issue_count = @platform_statistic['max-recent-one-month-issue-count'].to_i | |||||
| max_recent_one_month_release_count = @platform_statistic['max-recent-one-month-release-count'].to_i | |||||
| develop_activity_commit = max_recent_one_month_commit_count.zero? ? 0 : 40*(recent_one_month_commit_count.to_f/max_recent_one_month_commit_count) | |||||
| develop_activity_issue = max_recent_one_month_issue_count.zero? ? 0 : 20*(recent_one_month_issue_count.to_f/max_recent_one_month_issue_count) | |||||
| develop_activity_pullrequest = max_recent_one_month_pullrequest_count.zero? ? 0 : 20*(recent_one_month_pullrequest_count.to_f/max_recent_one_month_pullrequest_count) | |||||
| develop_activity_release = max_recent_one_month_release_count.zero? ? 0 : 20*(recent_one_month_release_count.to_f/max_recent_one_month_release_count) | |||||
| develop_activity = format("%.2f", develop_activity_commit + develop_activity_issue + develop_activity_pullrequest + develop_activity_release) | |||||
| render :json => {community_impact: community_impact, project_maturity: project_maturity, project_health: project_health, team_impact: team_impact, develop_activity: develop_activity} | render :json => {community_impact: community_impact, project_maturity: project_maturity, project_health: project_health, team_impact: team_impact, develop_activity: develop_activity} | ||||
| end | end | ||||
| # 社区影响力 | |||||
| def community_impact | |||||
| Cache::V2::PlatformStatisticService.new().reset | |||||
| @platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count | |||||
| watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count | |||||
| fork_count = ForkUser.where(project_id: @project.id).count | |||||
| community_impact_praise = @platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/@platform_statistic['max-praise-count'].to_i) | |||||
| community_impact_watcher = @platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/@platform_statistic['max-watcher-count'].to_i) | |||||
| community_impact_fork = @platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/@platform_statistic['max-fork-count'].to_i) | |||||
| community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork) | |||||
| render :json => { | |||||
| community_impact_praise: community_impact_praise, | |||||
| community_impact_watcher: community_impact_watcher, | |||||
| community_impact_fork: community_impact_fork, | |||||
| community_impact: community_impact | |||||
| } | |||||
| end | |||||
| # 项目成熟度 | |||||
| def project_maturity | |||||
| Cache::V2::PlatformStatisticService.new().reset | |||||
| @platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| pullrequest_count = PullRequest.where(project_id: @project.id).count | |||||
| complete_issue_count = Issue.issue_issue.where(project_id: @project.id, status_id: [3,5]).count | |||||
| project_create_day = (Time.now.to_i - @project.created_on.to_i)/(3600*24) | |||||
| max_project_create_day = (Time.now.to_i - Project.order("created_on desc").last.created_on.to_i)/(3600*24) | |||||
| project_maturity_pullrequest = @platform_statistic['max-pullrequest-count'].to_i == 0? 0 : 40*(pullrequest_count.to_f/@platform_statistic['max-pullrequest-count'].to_i) | |||||
| project_maturity_complete_issue = @platform_statistic['max-complete-issue-count'].to_i == 0? 0 : 40*(complete_issue_count.to_f/@platform_statistic['max-complete-issue-count'].to_i) | |||||
| project_maturity_project_create_day = max_project_create_day.to_i <= 0 || project_create_day.to_i <= 0 ? 0 : 20*(Math.sqrt(project_create_day).to_f/Math.sqrt(max_project_create_day)) | |||||
| project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_complete_issue + project_maturity_project_create_day) | |||||
| render :json => { | |||||
| project_maturity_pullrequest: project_maturity_pullrequest, | |||||
| project_maturity_complete_issue: project_maturity_complete_issue, | |||||
| project_maturity_project_create_day: project_maturity_project_create_day, | |||||
| project_maturity: project_maturity | |||||
| } | |||||
| end | |||||
| # 项目健康度 | |||||
| def project_health | |||||
| Cache::V2::PlatformStatisticService.new().reset | |||||
| @platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| member_count = Member.where(project_id: @project.id).count | |||||
| max_member_count = @platform_statistic['max-member-count'].to_i | |||||
| project_last_commit = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).order("created_at desc").first | |||||
| last_commit_day = project_last_commit.present? ? (Time.now.to_i - project_last_commit.created_at.to_i)/(3600*24) : 0 | |||||
| has_license = @project.license.present? ? 1 : 0 | |||||
| closed_pullrequest_count = PullRequest.where(project_id: @project.id, status: 1).count | |||||
| closed_issue_count = Issue.issue_issue.where(project_id: @project.id, status_id: [3,5]).count | |||||
| pullrequest_count = PullRequest.where(project_id: @project.id).count | |||||
| issue_count = Issue.issue_issue.where(project_id: @project.id).count | |||||
| health_code1 = max_member_count.to_i == 0 ? 0 : 0.3*(member_count.to_f/max_member_count) | |||||
| health_code2 = last_commit_day.to_i == 0 ? 0 : 0.7*(1.to_f/(1+last_commit_day*0.1)) | |||||
| health_code = 10 * (health_code1 + health_code2) | |||||
| health_license = 10 * has_license | |||||
| health_pullrequest = pullrequest_count <= 1 ? 0 : 40 * (closed_pullrequest_count.to_f/pullrequest_count)*(1-1/Math.sqrt(pullrequest_count+1)) | |||||
| health_issue = issue_count <= 1 ? 0 : 40 * (closed_issue_count.to_f/issue_count)*(1-1/Math.sqrt(issue_count+1)) | |||||
| project_health = format("%.2f", health_code + health_license + health_pullrequest + health_issue) | |||||
| render :json => { | |||||
| health_code: health_code, | |||||
| health_license: health_license, | |||||
| health_pullrequest: health_pullrequest, | |||||
| health_issue: health_issue, | |||||
| project_health: project_health | |||||
| } | |||||
| end | |||||
| # 团队健康度 | |||||
| def team_impact | |||||
| Cache::V2::PlatformStatisticService.new().reset | |||||
| @platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| member_count = Member.where(project_id: @project.id).count | |||||
| max_member_count = @platform_statistic['max-member-count'].to_i | |||||
| recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on >?", Time.now - 30.days).count | |||||
| max_recent_one_month_member_count = @platform_statistic['max-recent-one-month-member-count'].to_i | |||||
| issue_assigner_count = IssueAssigner.joins(:issue).merge(Issue.issue_issue).where(issues: {project_id: @project.id}).distinct.count | |||||
| project_member_count = @project.owner.is_a?(User) ? member_count : @project.owner.organization_users.count | |||||
| team_impact_member = 40*(member_count.to_f/max_member_count) | |||||
| team_impact_recent_member = 40*(recent_one_month_member_count.to_f/max_recent_one_month_member_count) | |||||
| team_impact_issue_assigner = 20*(issue_assigner_count.to_f/project_member_count) | |||||
| team_impact = format("%.2f", team_impact_member + team_impact_recent_member + team_impact_issue_assigner) | |||||
| render :json => { | |||||
| team_impact_member: team_impact_member, | |||||
| team_impact_recent_member: team_impact_recent_member, | |||||
| team_impact_issue_assigner: team_impact_issue_assigner, | |||||
| team_impact: team_impact | |||||
| } | |||||
| end | |||||
| # 开发活跃度 | |||||
| def develop_activity | |||||
| Cache::V2::PlatformStatisticService.new().reset | |||||
| @platform_statistic = $redis_cache.hgetall("v2-platform-statistic") | |||||
| recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count | |||||
| recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count | |||||
| recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on >?", Time.now - 30.days).count | |||||
| recent_one_month_release_count = VersionRelease.joins(:repository).where(repositories: {project_id: @project.id}).where("created_at >?", Time.now - 30.days).count | |||||
| max_recent_one_month_commit_count = @platform_statistic['max-recent-one-month-commit-count'].to_i | |||||
| max_recent_one_month_pullrequest_count = @platform_statistic['max-recent-one-month-pullrequest-count'].to_i | |||||
| max_recent_one_month_issue_count = @platform_statistic['max-recent-one-month-issue-count'].to_i | |||||
| max_recent_one_month_release_count = @platform_statistic['max-recent-one-month-release-count'].to_i | |||||
| develop_activity_commit = max_recent_one_month_commit_count.zero? ? 0 : 40*(recent_one_month_commit_count.to_f/max_recent_one_month_commit_count) | |||||
| develop_activity_issue = max_recent_one_month_issue_count.zero? ? 0 : 20*(recent_one_month_issue_count.to_f/max_recent_one_month_issue_count) | |||||
| develop_activity_pullrequest = max_recent_one_month_pullrequest_count.zero? ? 0 : 20*(recent_one_month_pullrequest_count.to_f/max_recent_one_month_pullrequest_count) | |||||
| develop_activity_release = max_recent_one_month_release_count.zero? ? 0 : 20*(recent_one_month_release_count.to_f/max_recent_one_month_release_count) | |||||
| develop_activity = format("%.2f", develop_activity_commit + develop_activity_issue + develop_activity_pullrequest + develop_activity_release) | |||||
| render :json => { | |||||
| develop_activity_commit: develop_activity_commit, | |||||
| develop_activity_issue: develop_activity_issue, | |||||
| develop_activity_pullrequest: develop_activity_pullrequest, | |||||
| develop_activity_release: develop_activity_release, | |||||
| develop_activity: develop_activity | |||||
| } | |||||
| end | |||||
| end | end | ||||
| @@ -1,5 +1,8 @@ | |||||
| class Api::V1::SonarqubesController < Api::V1::BaseController | class Api::V1::SonarqubesController < Api::V1::BaseController | ||||
| before_action :load_repository | before_action :load_repository | ||||
| include Repository::LanguagesPercentagable | |||||
| include SonarService | |||||
| def sonar_initialize | def sonar_initialize | ||||
| gitea_params = { has_actions: params[:has_actions] == 'true' ? true :false } | gitea_params = { has_actions: params[:has_actions] == 'true' ? true :false } | ||||
| gitea_setting = Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params) | gitea_setting = Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params) | ||||
| @@ -17,6 +20,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 +31,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 +67,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: | ||||
| @@ -83,11 +92,13 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| Gitea::CreateFileInteractor.call(@owner.gitea_token, @owner.login, sonar_scanner_content) | Gitea::CreateFileInteractor.call(@owner.gitea_token, @owner.login, sonar_scanner_content) | ||||
| end | end | ||||
| sonar_content = build_sonar_content(params[:owner], @project.id, languages_precentagable.keys) | |||||
| sonar_project_content = { | sonar_project_content = { | ||||
| 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_content, | |||||
| "message": 'Add sonar-project.properties', | "message": 'Add sonar-project.properties', | ||||
| committer: { | committer: { | ||||
| email: @owner.mail, | email: @owner.mail, | ||||
| @@ -95,6 +106,7 @@ class Api::V1::SonarqubesController < Api::V1::BaseController | |||||
| }, | }, | ||||
| identifier: @project.identifier | identifier: @project.identifier | ||||
| } | } | ||||
| sonar_project_exit = Repositories::EntriesInteractor.call(@owner, @project.identifier, 'sonar-project.properties', ref: params[:branch]) | sonar_project_exit = Repositories::EntriesInteractor.call(@owner, @project.identifier, 'sonar-project.properties', ref: params[:branch]) | ||||
| if sonar_project_exit.success? | if sonar_project_exit.success? | ||||
| Gitea::UpdateFileInteractor.call(@owner.gitea_token, @owner.login, sonar_project_content.merge(sha:sonar_project_exit.result['sha'])) | Gitea::UpdateFileInteractor.call(@owner.gitea_token, @owner.login, sonar_project_content.merge(sha:sonar_project_exit.result['sha'])) | ||||
| @@ -148,6 +160,31 @@ 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 analyze_doxygen | |||||
| config = Rails.application.config_for(:configuration) | |||||
| sonarqube_config = config.dig('sonarqube') | |||||
| doxygen_url = sonarqube_config['doxygen'] | |||||
| url = "#{doxygen_url}/files/#{@project.owner.login}/#{@project.identifier}/html/analyze_doxygen.json" | |||||
| uri = URI.parse(url) | |||||
| response = Net::HTTP.get_response(uri) | |||||
| if response.code.to_i != 200 | |||||
| puts "======= 接口请求失败!" | |||||
| data = { data: nil, msg: '文件不存在' } | |||||
| else | |||||
| data = { data: JSON.parse(response.body), msg: 'ok' } | |||||
| end | |||||
| render_ok data | |||||
| end | |||||
| def measures_search_history | def measures_search_history | ||||
| params_data = { | params_data = { | ||||
| from: params[:form], | from: params[:form], | ||||
| @@ -32,18 +32,8 @@ module LaboratoryHelper | |||||
| end | end | ||||
| def default_course_links | def default_course_links | ||||
| # my_projects: "/users/#{current_user.try(:login)}/projects", | |||||
| # my_projects: "https://www.trustie.net/users/#{current_user.try(:login)}/user_projectlist", | |||||
| { | { | ||||
| new_syllabuses: "https://www.trustie.net/syllabuses/new", | |||||
| new_course: "https://www.trustie.net/courses/new", | |||||
| edit_account: "https://www.trustie.net/my/account", | |||||
| my_courses: "https://www.trustie.net/users/#{current_user.try(:login)}/user_courselist", | |||||
| my_projects: "/users/#{current_user.try(:login)}/projects", | |||||
| my_organ: "https://www.trustie.net/users/#{current_user.try(:login)}/user_organizations", | |||||
| default_url: Rails.application.config_for(:configuration)['platform_url'], | |||||
| tiding_url: "https://www.trustie.net/users/#{current_user.try(:login)}/user_messages", | |||||
| register_url: "https://www.trustie.net/login?login=false" | |||||
| default_url: Rails.application.config_for(:configuration)['platform_url'] | |||||
| } | } | ||||
| end | end | ||||
| end | end | ||||
| @@ -0,0 +1,17 @@ | |||||
| class HomeController < ApplicationController | |||||
| def index | |||||
| @user_count = Rails.cache.fetch("homecontroller:user_count", expires_in: 1.hours) do | |||||
| User.count | |||||
| end | |||||
| @project_count = Rails.cache.fetch("homecontroller:project_count", expires_in: 1.hours) do | |||||
| Project.count | |||||
| end | |||||
| @project_dataset_count = Rails.cache.fetch("homecontroller:project_dataset_count", expires_in: 1.hours) do | |||||
| ProjectDataset.count | |||||
| end | |||||
| @commit_count = Rails.cache.fetch("homecontroller:commit_count", expires_in: 1.hours) do | |||||
| CommitLog.count | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -37,6 +37,10 @@ class RepositoriesController < ApplicationController | |||||
| @fork_project = Project.find_by(id: @project_fork_id) | @fork_project = Project.find_by(id: @project_fork_id) | ||||
| @fork_project_user = @fork_project.owner | @fork_project_user = @fork_project.owner | ||||
| end | end | ||||
| # 修正默认分支 | |||||
| if @result[:repo].present? && @result[:repo]['default_branch'].present? && @result[:repo]['default_branch'] != @project.default_branch | |||||
| @project.update_column('default_branch', @result[:repo]['default_branch']) | |||||
| end | |||||
| rescue Exception => e | rescue Exception => e | ||||
| uid_logger_error(e.message) | uid_logger_error(e.message) | ||||
| tip_exception(e.message) | tip_exception(e.message) | ||||
| @@ -1,13 +1,12 @@ | |||||
| class SettingsController < ApplicationController | class SettingsController < ApplicationController | ||||
| def show | def show | ||||
| @old_projects_url = nil | |||||
| get_navbar | get_navbar | ||||
| site_page_deploy_domain | site_page_deploy_domain | ||||
| get_add_menu | get_add_menu | ||||
| get_common_menu | get_common_menu | ||||
| get_sub_competitions | get_sub_competitions | ||||
| get_personal_menu | get_personal_menu | ||||
| get_third_party | |||||
| # get_third_party | |||||
| get_third_party_new | get_third_party_new | ||||
| get_top_system_notification | get_top_system_notification | ||||
| end | end | ||||
| @@ -10,6 +10,8 @@ class Users::MessagesController < Users::BaseController | |||||
| result = Notice::Read::ListService.call(observed_user.id, message_type, message_status, page, limit) | result = Notice::Read::ListService.call(observed_user.id, message_type, message_status, page, limit) | ||||
| return render_error if result.nil? | return render_error if result.nil? | ||||
| @data = result[2] | @data = result[2] | ||||
| rescue | |||||
| render_ok | |||||
| end | end | ||||
| def create | def create | ||||
| @@ -0,0 +1,44 @@ | |||||
| module SonarService | |||||
| def build_sonar_content(owner,project_id,lang_keys) | |||||
| lang_map = { | |||||
| 'Java' => :java, | |||||
| 'Python' => :python, | |||||
| 'JavaScript' => :js, | |||||
| 'TypeScript' => :ts, | |||||
| 'C++' => :cpp, | |||||
| 'C' => :cpp | |||||
| } | |||||
| detected_langs = lang_keys.map { |l| lang_map[l] }.compact.to_set | |||||
| lines = [] | |||||
| lines << "sonar.projectKey=#{owner}-#{project_id}" | |||||
| lines << "sonar.projectVersion=1.0" | |||||
| lines << "sonar.sourceEncoding=UTF-8" | |||||
| lines << "sonar.sources=." | |||||
| lines << "sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**" | |||||
| if detected_langs.include?(:java) | |||||
| lines << "sonar.java.binaries=" | |||||
| end | |||||
| if detected_langs.include?(:js) | |||||
| lines << "sonar.javascript.lcov.reportPaths=coverage/lcov.info" | |||||
| end | |||||
| if detected_langs.include?(:ts) | |||||
| lines << "sonar.typescript.tsconfigPath=tsconfig.json" | |||||
| end | |||||
| if detected_langs.include?(:python) | |||||
| lines << "sonar.python.coverage.reportPaths=coverage.xml" | |||||
| end | |||||
| if detected_langs.include?(:cpp) | |||||
| lines << "sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh" | |||||
| lines << "sonar.cxx.errorRecoveryEnabled=true" | |||||
| end | |||||
| lines.join("\n") | |||||
| end | |||||
| end | |||||
| @@ -298,6 +298,38 @@ class Issue < ApplicationRecord | |||||
| self.project.decrement!(:closed_issues_count) if self.status_id == 5 && self.project.present? | self.project.decrement!(:closed_issues_count) if self.status_id == 5 && self.project.present? | ||||
| end | end | ||||
| # def self.find_issues_by_pm(enterprise_identifier, pm_issue_type) | |||||
| # case pm_issue_type.to_i | |||||
| # when 1 | |||||
| # Issue.issue_issue.where(enterprise_identifier: enterprise_identifier) | |||||
| # .where(pm_issue_type: pm_issue_type) | |||||
| # .where(pm_issue_type_index1: index) | |||||
| # when 2 | |||||
| # Issue.issue_issue.where(enterprise_identifier: enterprise_identifier) | |||||
| # .where(pm_issue_type: pm_issue_type) | |||||
| # .where(pm_issue_type_index2: index) | |||||
| # when 3 | |||||
| # Issue.issue_issue.where(enterprise_identifier: enterprise_identifier) | |||||
| # .where(pm_issue_type: pm_issue_type) | |||||
| # .where(pm_issue_type_index3: index) | |||||
| # end | |||||
| # end | |||||
| # | |||||
| # def self.build_pm_index(enterprise_identifier, pm_issue_type) | |||||
| # last_issue = Issue.find_issues_by_pm(enterprise_identifier, pm_issue_type).order("pm_issue_type_index#{pm_issue_type.to_i} asc").last | |||||
| # deleted_issue_count = ($redis_cache.hget("pm_issue_cache_delete_count", enterprise_identifier) || 0).to_i | |||||
| # | |||||
| # last_issue.send("pm_issue_type_index#{pm_issue_type.to_i}").present? ? last_issue.send("pm_issue_type_index#{pm_issue_type.to_i}") + deleted_issue_count : 0 | |||||
| # end | |||||
| # | |||||
| # def incre_pm_issue_cache_delete_count(count=1) | |||||
| # $redis_cache.hincrby("pm_issue_cache_delete_count", self.enterprise_identifier, count) | |||||
| # end | |||||
| # | |||||
| # def del_pm_issue_cache_delete_count | |||||
| # $redis_cache.hdel("pm_issue_cache_delete_count", self.enterprise_identifier) | |||||
| # end | |||||
| def send_update_message_to_notice_system | def send_update_message_to_notice_system | ||||
| SendTemplateMessageJob.perform_later('IssueExpire', self.id) if Site.has_notice_menu? && self.due_date == Date.today + 1.days | SendTemplateMessageJob.perform_later('IssueExpire', self.id) if Site.has_notice_menu? && self.due_date == Date.today + 1.days | ||||
| end | end | ||||
| @@ -23,7 +23,7 @@ class ProjectUnit < ApplicationRecord | |||||
| def self.init_types(project_id, project_type='common') | def self.init_types(project_id, project_type='common') | ||||
| unit_types = project_type == 'sync_mirror' ? ProjectUnit::unit_types.except("pulls") : ProjectUnit::unit_types | unit_types = project_type == 'sync_mirror' ? ProjectUnit::unit_types.except("pulls") : ProjectUnit::unit_types | ||||
| unit_types = unit_types.except("dataset") | |||||
| unit_types = unit_types.except("dataset") unless EduSetting.get("is_local") == "true" | |||||
| unit_types.each do |_, v| | unit_types.each do |_, v| | ||||
| self.create!(project_id: project_id, unit_type: v) | self.create!(project_id: project_id, unit_type: v) | ||||
| end | end | ||||
| @@ -20,7 +20,8 @@ class Projects::ListMyQuery < ApplicationQuery | |||||
| if params[:category].blank? | if params[:category].blank? | ||||
| normal_projects = projects.members_projects(user.id).to_sql | normal_projects = projects.members_projects(user.id).to_sql | ||||
| org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql | org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql | ||||
| projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects")#.distinct | |||||
| watched_projects = projects.where.not(user_id: user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: user.id}).to_sql | |||||
| projects = Project.from("( #{ normal_projects} UNION #{ org_projects } UNION #{ watched_projects } ) AS projects")#.distinct | |||||
| elsif params[:category].to_s == "join" | elsif params[:category].to_s == "join" | ||||
| normal_projects = projects.where.not(user_id: user.id).members_projects(user.id).to_sql | normal_projects = projects.where.not(user_id: user.id).members_projects(user.id).to_sql | ||||
| org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql | org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql | ||||
| @@ -5,7 +5,7 @@ class Api::Pm::Issues::CreateService < ApplicationService | |||||
| attr_reader :project, :current_user | attr_reader :project, :current_user | ||||
| attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num, :root_subject | attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num, :root_subject | ||||
| attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login | |||||
| attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login, :enterprise_identifier, :pm_issue_type | |||||
| attr_accessor :created_issue | attr_accessor :created_issue | ||||
| validates :subject, presence: true | validates :subject, presence: true | ||||
| @@ -36,6 +36,7 @@ class Api::Pm::Issues::CreateService < ApplicationService | |||||
| @time_scale = params[:time_scale] | @time_scale = params[:time_scale] | ||||
| @linkable_id = params[:link_able_id] | @linkable_id = params[:link_able_id] | ||||
| @root_subject = params[:root_subject] | @root_subject = params[:root_subject] | ||||
| @enterprise_identifier = params[:enterprise_identifier] | |||||
| end | end | ||||
| def call | def call | ||||
| @@ -56,10 +57,10 @@ class Api::Pm::Issues::CreateService < ApplicationService | |||||
| try_lock("Api::Pm::Issues::CreateService:#{project.id}") # 开始写数据,加锁 | try_lock("Api::Pm::Issues::CreateService:#{project.id}") # 开始写数据,加锁 | ||||
| @created_issue = Issue.new(issue_attributes) | @created_issue = Issue.new(issue_attributes) | ||||
| @created_issue.pm_issue_type = @pm_issue_type | @created_issue.pm_issue_type = @pm_issue_type | ||||
| if @root_subject.present? && @pm_issue_type.to_i == 4 | |||||
| @root_issue = Issue.find_by(subject: @root_subject, pm_issue_type: 4, pm_project_id: @pm_project_id) | |||||
| 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) | |||||
| unless @root_issue.present? | unless @root_issue.present? | ||||
| @root_issue = Issue.create(subject: @root_subject, pm_issue_type: 4, pm_project_id: @pm_project_id, 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 | ||||
| @@ -74,6 +75,7 @@ class Api::Pm::Issues::CreateService < ApplicationService | |||||
| @created_issue.attachments = @attachments unless attachment_ids.blank? | @created_issue.attachments = @attachments unless attachment_ids.blank? | ||||
| @created_issue.issue_tags = @issue_tags unless issue_tag_ids.blank? | @created_issue.issue_tags = @issue_tags unless issue_tag_ids.blank? | ||||
| @created_issue.pm_project_id = @pm_project_id | @created_issue.pm_project_id = @pm_project_id | ||||
| @created_issue.enterprise_identifier = @enterprise_identifier | |||||
| @created_issue.pm_sprint_id = @pm_sprint_id | @created_issue.pm_sprint_id = @pm_sprint_id | ||||
| @created_issue.time_scale = @time_scale | @created_issue.time_scale = @time_scale | ||||
| @created_issue.issue_tags_value = @issue_tags.order('id asc').pluck(:id).join(',') unless issue_tag_ids.blank? | @created_issue.issue_tags_value = @issue_tags.order('id asc').pluck(:id).join(',') unless issue_tag_ids.blank? | ||||
| @@ -4,7 +4,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService | |||||
| include Api::V1::Issues::Concerns::Loadable | include Api::V1::Issues::Concerns::Loadable | ||||
| attr_reader :project, :issue, :current_user, :operate_by | attr_reader :project, :issue, :current_user, :operate_by | ||||
| attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num | |||||
| attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num,:status_msg | |||||
| attr_reader :target_pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :time_scale | attr_reader :target_pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :time_scale | ||||
| attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login, :before_issue_tag_ids, :before_assigner_ids, :project_id | attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login, :before_issue_tag_ids, :before_assigner_ids, :project_id | ||||
| attr_accessor :add_assigner_ids, :previous_issue_changes, :updated_issue, :atme_receivers | attr_accessor :add_assigner_ids, :previous_issue_changes, :updated_issue, :atme_receivers | ||||
| @@ -18,6 +18,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService | |||||
| @current_user = current_user | @current_user = current_user | ||||
| @operate_by = operate_by | @operate_by = operate_by | ||||
| @status_id = params[:status_id] | @status_id = params[:status_id] | ||||
| @status_msg = params[:status_msg] | |||||
| @priority_id = params[:priority_id] | @priority_id = params[:priority_id] | ||||
| @milestone_id = params[:milestone_id] | @milestone_id = params[:milestone_id] | ||||
| @branch_name = params[:branch_name] | @branch_name = params[:branch_name] | ||||
| @@ -201,7 +202,12 @@ class Api::Pm::Issues::UpdateService < ApplicationService | |||||
| # 修改状态 | # 修改状态 | ||||
| if @updated_issue.previous_changes["status_id"].present? | if @updated_issue.previous_changes["status_id"].present? | ||||
| journal = @updated_issue.journals.create!({user_id: current_user.id, operate_by: @operate_by}) | journal = @updated_issue.journals.create!({user_id: current_user.id, operate_by: @operate_by}) | ||||
| journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, prop_key: "status_id", old_value: @updated_issue.previous_changes["status_id"][0], value: @updated_issue.previous_changes["status_id"][1]}) | |||||
| journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, | |||||
| prop_key: "status_id", | |||||
| status_msg: @status_msg, | |||||
| old_value: @updated_issue.previous_changes["status_id"][0], | |||||
| value: @updated_issue.previous_changes["status_id"][1]} | |||||
| ) | |||||
| end | end | ||||
| # 修改优先级 | # 修改优先级 | ||||
| @@ -3,7 +3,7 @@ class Api::V1::Issues::ListService < ApplicationService | |||||
| attr_reader :project, :only_name, :category, :participant_category, :keyword, :author_id, :issue_tag_ids | attr_reader :project, :only_name, :category, :participant_category, :keyword, :author_id, :issue_tag_ids | ||||
| attr_reader :begin_date, :end_date, :update_begin_date, :update_end_date | attr_reader :begin_date, :end_date, :update_begin_date, :update_end_date | ||||
| attr_reader :milestone_id, :assigner_id, :status_id, :priority_id, :sort_by, :sort_direction, :current_user | |||||
| attr_reader :milestone_id, :assigner_id, :status_id, :priority_id, :sort_by, :sort_direction, :current_user, :enterprise_identifier | |||||
| attr_reader :pm_project_id, :pm_project_ids, :pm_sprint_id, :root_id, :pm_issue_type, :status_ids, :ids, :exclude_ids, :pm_issue_types | attr_reader :pm_project_id, :pm_project_ids, :pm_sprint_id, :root_id, :pm_issue_type, :status_ids, :ids, :exclude_ids, :pm_issue_types | ||||
| attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count, :complete_issues_count, :participator | attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count, :complete_issues_count, :participator | ||||
| @@ -30,6 +30,7 @@ class Api::V1::Issues::ListService < ApplicationService | |||||
| @update_begin_date = params[:update_begin_date] | @update_begin_date = params[:update_begin_date] | ||||
| @update_end_date = params[:update_end_date] | @update_end_date = params[:update_end_date] | ||||
| @sort_by = params[:sort_by].present? ? params[:sort_by] : 'issues.updated_on' | @sort_by = params[:sort_by].present? ? params[:sort_by] : 'issues.updated_on' | ||||
| @enterprise_identifier = params[:enterprise_identifier] | |||||
| @pm_project_id = params[:pm_project_id] | @pm_project_id = params[:pm_project_id] | ||||
| @pm_project_ids = params[:pm_project_ids] | @pm_project_ids = params[:pm_project_ids] | ||||
| @pm_sprint_id = params[:pm_sprint_id] | @pm_sprint_id = params[:pm_sprint_id] | ||||
| @@ -96,6 +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) || 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 | ||||
| @@ -148,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 | ||||
| @@ -92,7 +92,7 @@ class Api::V1::Issues::UpdateService < ApplicationService | |||||
| @updated_issue.project_id = @project_id unless @project_id.nil? | @updated_issue.project_id = @project_id unless @project_id.nil? | ||||
| @updated_issue.updated_on = Time.now | @updated_issue.updated_on = Time.now | ||||
| @updated_issue.changer_id = @current_user.id | @updated_issue.changer_id = @current_user.id | ||||
| @updated_issue.due_date = Time.now if @due_date.blank? | |||||
| @updated_issue.due_date = Time.now if @updated_issue.status_id == 5 && @due_date.blank? | |||||
| @updated_issue.save! | @updated_issue.save! | ||||
| build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 | build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 | ||||
| @@ -23,8 +23,8 @@ class Api::V1::Users::DeleteUserService < ApplicationService | |||||
| end | end | ||||
| @user.destroy! | @user.destroy! | ||||
| del_user_data_by_sql(@user.id) | del_user_data_by_sql(@user.id) | ||||
| Gitea::User::DeleteService.call(@user.login, true) | |||||
| end | end | ||||
| Gitea::User::DeleteService.call(@user.login, true) | |||||
| return true | return true | ||||
| rescue | rescue | ||||
| raise Error, "服务器错误,请联系系统管理员!" | raise Error, "服务器错误,请联系系统管理员!" | ||||
| @@ -32,7 +32,11 @@ class Api::V1::Users::DeleteUserService < ApplicationService | |||||
| end | end | ||||
| def del_user_data_by_sql(user_id) | def del_user_data_by_sql(user_id) | ||||
| sql1 = "delete from memos where author_id=#{user_id}" | |||||
| ActiveRecord::Base.connection.execute(sql1) | |||||
| if ActiveRecord::Base.connection.table_exists?("memos") | |||||
| sql1 = "delete from memos where author_id=#{user_id}" | |||||
| ActiveRecord::Base.connection.execute(sql1) | |||||
| else | |||||
| Rails.logger.info "memos table does not exist" | |||||
| end | |||||
| end | end | ||||
| end | end | ||||
| @@ -56,6 +56,11 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| "max-issue-count" | "max-issue-count" | ||||
| end | end | ||||
| # 平台最高已解决issue数 | |||||
| def max_complete_issue_count_key | |||||
| "max-complete-issue-count" | |||||
| end | |||||
| # 平台最高commit数 | # 平台最高commit数 | ||||
| def max_commit_count_key | def max_commit_count_key | ||||
| "max-commit-count" | "max-commit-count" | ||||
| @@ -86,6 +91,11 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| "max-recent-one-month-commit-count" | "max-recent-one-month-commit-count" | ||||
| end | end | ||||
| # 平台近一个月release最大值 | |||||
| def max_recent_one_month_release_count_key | |||||
| "max-recent-one-month-release-count" | |||||
| end | |||||
| def follow_count_key | def follow_count_key | ||||
| "follow-count" | "follow-count" | ||||
| end | end | ||||
| @@ -216,6 +226,11 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| $redis_cache.hset(platform_statistic_key, max_issue_count_key, max_issue[1].nil? ? 0 : max_issue[1]) | $redis_cache.hset(platform_statistic_key, max_issue_count_key, max_issue[1].nil? ? 0 : max_issue[1]) | ||||
| end | end | ||||
| def reset_platform_max_complete_issue_count | |||||
| max_complete_issue = Issue.where.not(project_id: 0).issue_issue.where(status_id: [3,5]).group(:project_id).count.sort_by{|i|i[1]}.last || [] | |||||
| $redis_cache.hset(platform_statistic_key, max_complete_issue_count_key, max_complete_issue[1].nil? ? 0 : max_complete_issue[1]) | |||||
| end | |||||
| def reset_platform_max_commit_count | def reset_platform_max_commit_count | ||||
| max_commit = CommitLog.joins(:project).merge(Project.common).group(:project_id).count.sort_by{|i|i[1]}.last || [] | max_commit = CommitLog.joins(:project).merge(Project.common).group(:project_id).count.sort_by{|i|i[1]}.last || [] | ||||
| $redis_cache.hset(platform_statistic_key, max_commit_count_key, max_commit[1].nil? ? 0 : max_commit[1]) | $redis_cache.hset(platform_statistic_key, max_commit_count_key, max_commit[1].nil? ? 0 : max_commit[1]) | ||||
| @@ -237,7 +252,7 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| end | end | ||||
| def reset_platform_max_recent_one_month_issue_count | def reset_platform_max_recent_one_month_issue_count | ||||
| max_recent_one_month_issue = Issue.issue_issue.where("created_on > ?", Time.now - 30.days).group(:project_id).count.sort_by{|i|i[1]}.last || [] | |||||
| max_recent_one_month_issue = Issue.where.not(project_id: 0).issue_issue.where("created_on > ?", Time.now - 30.days).group(:project_id).count.sort_by{|i|i[1]}.last || [] | |||||
| $redis_cache.hset(platform_statistic_key, max_recent_one_month_issue_count_key, max_recent_one_month_issue[1].nil? ? 0 : max_recent_one_month_issue[1]) | $redis_cache.hset(platform_statistic_key, max_recent_one_month_issue_count_key, max_recent_one_month_issue[1].nil? ? 0 : max_recent_one_month_issue[1]) | ||||
| end | end | ||||
| @@ -246,6 +261,11 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| $redis_cache.hset(platform_statistic_key, max_recent_one_month_commit_count_key, max_recent_one_month_commit[1].nil? ? 0 : max_recent_one_month_commit[1]) | $redis_cache.hset(platform_statistic_key, max_recent_one_month_commit_count_key, max_recent_one_month_commit[1].nil? ? 0 : max_recent_one_month_commit[1]) | ||||
| end | end | ||||
| def reset_platform_max_recent_one_month_release_count | |||||
| max_recent_one_month_release = VersionRelease.where("created_at >?", Time.now - 30.days).group(:repository_id).count.sort_by{|i|i[1]}.last || [] | |||||
| $redis_cache.hset(platform_statistic_key, max_recent_one_month_release_count_key, max_recent_one_month_release[1].nil? ? 0 : max_recent_one_month_release[1]) | |||||
| end | |||||
| def reset_platform_follow_count | def reset_platform_follow_count | ||||
| $redis_cache.hset(platform_statistic_key, follow_count_key, Watcher.where(watchable_type: 'User').count) | $redis_cache.hset(platform_statistic_key, follow_count_key, Watcher.where(watchable_type: 'User').count) | ||||
| end | end | ||||
| @@ -255,7 +275,7 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| end | end | ||||
| def reset_platform_issue_count | def reset_platform_issue_count | ||||
| $redis_cache.hset(platform_statistic_key, issue_count_key, Issue.count) | |||||
| $redis_cache.hset(platform_statistic_key, issue_count_key, Issue.where.not(project_id: 0).count) | |||||
| end | end | ||||
| def reset_platform_project_count | def reset_platform_project_count | ||||
| @@ -299,6 +319,8 @@ class Cache::V2::PlatformStatisticService < ApplicationService | |||||
| reset_platform_max_recent_one_month_pullrequest_count | reset_platform_max_recent_one_month_pullrequest_count | ||||
| reset_platform_max_recent_one_month_issue_count | reset_platform_max_recent_one_month_issue_count | ||||
| reset_platform_max_recent_one_month_commit_count | reset_platform_max_recent_one_month_commit_count | ||||
| reset_platform_max_recent_one_month_release_count | |||||
| reset_platform_max_complete_issue_count | |||||
| $redis_cache.hgetall(platform_statistic_key) | $redis_cache.hgetall(platform_statistic_key) | ||||
| end | end | ||||
| @@ -51,7 +51,7 @@ | |||||
| <li> | <li> | ||||
| <%= sidebar_item_group('#setting-index', '首页配置', icon: 'file', has_permission: current_user.admin? || current_user.business?) do %> | <%= sidebar_item_group('#setting-index', '首页配置', icon: 'file', has_permission: current_user.admin? || current_user.business?) do %> | ||||
| <li><%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners', has_permission: current_user.admin? || current_user.business?) %></li> | <li><%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners', has_permission: current_user.admin? || current_user.business?) %></li> | ||||
| <!--<li><%#= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards', has_permission: current_user.admin? || current_user.business?) %></li>--> | |||||
| <li><%= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards', has_permission: current_user.admin? || current_user.business?) %></li> | |||||
| <li><%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums', has_permission: current_user.admin? || current_user.business?) %></li> | <li><%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums', has_permission: current_user.admin? || current_user.business?) %></li> | ||||
| <li><%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects', has_permission: current_user.admin? || current_user.business?) %></li> | <li><%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects', has_permission: current_user.admin? || current_user.business?) %></li> | ||||
| <li><%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums', has_permission: current_user.admin? || current_user.business?) %></li> | <li><%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums', has_permission: current_user.admin? || current_user.business?) %></li> | ||||
| @@ -13,6 +13,7 @@ if journal.is_journal_detail? | |||||
| detail = journal.journal_details.take | detail = journal.journal_details.take | ||||
| json.operate_category journal.pm_operate_category | json.operate_category journal.pm_operate_category | ||||
| json.operate_content journal.is_journal_detail? ? journal.pm_operate_content : nil | json.operate_content journal.is_journal_detail? ? journal.pm_operate_content : nil | ||||
| json.status_msg detail.status_msg | |||||
| else | else | ||||
| json.notes journal.notes | json.notes journal.notes | ||||
| json.comments_count journal.comments_count | json.comments_count journal.comments_count | ||||
| @@ -0,0 +1,30 @@ | |||||
| json.status 0 | |||||
| json.message "success" | |||||
| json.count @pipelines.total_count | |||||
| json.projects @pipelines.map(&:project_id).uniq.each do |project_id| | |||||
| json.id project_id | |||||
| project = Project.find_by(id: project_id) | |||||
| if project.present? | |||||
| json.owner project.owner.name | |||||
| json.identifier project.identifier | |||||
| json.name project.name | |||||
| json.url "#{Rails.application.config_for(:configuration)['platform_url']}/#{project.owner.name}/#{project.identifier}" | |||||
| pipelines = Action::Pipeline.where(project_id: project.id).order(updated_at: :desc) | |||||
| json.pipelines pipelines.each do |pipeline| | |||||
| json.extract! pipeline, :id, :project_id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, | |||||
| :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at | |||||
| repo_config = @disabled_workflows.select { |config| config.repo_id == pipeline.project.gpid } | |||||
| if repo_config.present? | |||||
| json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) | |||||
| else | |||||
| json.disable pipeline.disable | |||||
| end | |||||
| json.pipeline_type pipeline.pipeline_type | |||||
| if pipeline.json.blank? && pipeline.yaml.blank? | |||||
| json.run_data nil | |||||
| else | |||||
| json.run_data @run_result.select { |result| result[:repo_id] == project.gpid && result[:filename] == pipeline.file_name}.first | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,4 @@ | |||||
| json.total_count @this_week_all_issues.total_count | |||||
| json.issues @this_week_all_issues.each do |issue| | |||||
| json.partial! "api/v1/issues/simple_detail", locals: {issue: issue} | |||||
| end | |||||
| @@ -0,0 +1,18 @@ | |||||
| json.this_week_all_issues @this_week_all_issues.each do |issue| | |||||
| json.partial! "api/v1/issues/simple_detail", locals: {issue: issue} | |||||
| end | |||||
| json.this_week_total_count @this_week_all_issues.total_count | |||||
| json.next_week_all_issues @next_week_all_issues.each do |issue| | |||||
| json.partial! "api/v1/issues/simple_detail", locals: {issue: issue} | |||||
| end | |||||
| json.next_week_total_count @next_week_all_issues.total_count | |||||
| json.this_week_requirement_issues_count @this_week_requirement_issues.count | |||||
| json.this_week_task_issues_count @this_week_task_issues.count | |||||
| json.this_week_bug_issues_count @this_week_bug_issues.count | |||||
| json.close_requirement_issues_count @close_requirement_issues.count | |||||
| json.close_task_issues_count @close_task_issues.count | |||||
| json.close_bug_issues_count @close_bug_issues.count | |||||
| json.unclose_count @this_week_all_issues.count - @close_requirement_issues.count - @close_task_issues.count - @close_bug_issues.count | |||||
| json.close_task_issues @close_task_issues.each do |issue| | |||||
| json.partial! "api/v1/issues/simple_detail", locals: {issue: issue} | |||||
| end | |||||
| @@ -0,0 +1,8 @@ | |||||
| json.this_week_all_issues @this_week_all_issues.each do |issue| | |||||
| json.partial! "api/v1/issues/simple_detail", locals: {issue: issue} | |||||
| end | |||||
| json.this_week_total_count @this_week_all_issues.total_count | |||||
| json.next_week_all_issues @next_week_all_issues.each do |issue| | |||||
| json.partial! "api/v1/issues/simple_detail", locals: {issue: issue} | |||||
| end | |||||
| json.next_week_total_count @next_week_all_issues.total_count | |||||
| @@ -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} | ||||
| @@ -1,24 +1,29 @@ | |||||
| json.total_data @result_object[:total_data].to_i | |||||
| if @result_object[:data]["Runs"].present? | |||||
| json.runs @result_object[:data]["Runs"].each_with_index.to_a do |run, index| | |||||
| json.num @result_object[:total_data].to_i - @begin_num - index | |||||
| json.workflow run["WorkflowID"] | |||||
| json.index run["Index"] | |||||
| json.title run["Title"] | |||||
| json.trigger_user do | |||||
| json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(run['TriggerUser']), name: run['TriggerUser']['Name'] } | |||||
| end | |||||
| if @has_file | |||||
| json.total_data @result_object[:total_data].to_i | |||||
| if @result_object[:data]["Runs"].present? | |||||
| json.runs @result_object[:data]["Runs"].each_with_index.to_a do |run, index| | |||||
| json.num @result_object[:total_data].to_i - @begin_num - index | |||||
| json.workflow run["WorkflowID"] | |||||
| json.index run["Index"] | |||||
| json.title run["Title"] | |||||
| json.trigger_user do | |||||
| json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(run['TriggerUser']), name: run['TriggerUser']['Name'] } | |||||
| end | |||||
| if run["Ref"].starts_with?("refs/tags") | |||||
| json.ref run["Ref"].gsub!("/refs/tags/", "") | |||||
| else | |||||
| json.ref run["Ref"].gsub!("refs/heads/", "") | |||||
| end | |||||
| if run["Ref"].starts_with?("refs/tags") | |||||
| json.ref run["Ref"].gsub!("/refs/tags/", "") | |||||
| else | |||||
| json.ref run["Ref"].gsub!("refs/heads/", "") | |||||
| end | |||||
| json.status run["Status"] | |||||
| json.time_ago time_from_now(run["Created"]) | |||||
| json.holding_time run["Status"] == 6 ? Time.now.to_i - run["Created"] : run["Stopped"] - run["Created"] | |||||
| json.status run["Status"] | |||||
| json.time_ago time_from_now(run["Created"]) | |||||
| json.holding_time run["Status"] == 6 ? Time.now.to_i - run["Created"] : run["Stopped"] - run["Created"] | |||||
| end | |||||
| else | |||||
| json.runs [] | |||||
| end | end | ||||
| else | else | ||||
| json.runs [] | |||||
| json.total_data 0 | |||||
| json.runs [] | |||||
| end | end | ||||
| @@ -1,9 +1,11 @@ | |||||
| json.status 0 | json.status 0 | ||||
| json.message "success" | json.message "success" | ||||
| json.count @pipelines.total_count | |||||
| json.pipelines @pipelines.each do |pipeline| | json.pipelines @pipelines.each do |pipeline| | ||||
| json.extract! pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, | json.extract! pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, | ||||
| :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at | :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at | ||||
| json.disable @disabled_workflows.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) | |||||
| json.pipeline_type pipeline.pipeline_type | json.pipeline_type pipeline.pipeline_type | ||||
| json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first | json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first | ||||
| end | end | ||||
| @@ -1,4 +1,5 @@ | |||||
| json.status 0 | json.status 0 | ||||
| json.message "success" | json.message "success" | ||||
| json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :pipeline_type, | json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :pipeline_type, | ||||
| :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at | |||||
| :repo_name, :repo_identifier, :branch, :event, :sha, :json, :yaml, :created_at, :updated_at | |||||
| json.disable @disabled_workflows.include?(@pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) | |||||
| @@ -1,21 +1,9 @@ | |||||
| json.images_url @images_url | |||||
| json.reps @rep_list | |||||
| json.shixuns do | |||||
| json.partial! 'shixuns/shixun', locals: {shixuns: @shixuns} | |||||
| end | |||||
| json.subjects do | |||||
| json.partial! 'subjects/subject', locals: {subjects: @subjects} | |||||
| json.status 0 | |||||
| json.message "success" | |||||
| json.statistics_data do | |||||
| json.user_count @user_count | |||||
| json.project_count @project_count | |||||
| json.project_dataset_count @project_dataset_count | |||||
| json.commit_count @commit_count | |||||
| end | end | ||||
| # if current_laboratory.main_site? | |||||
| # json.teachers do | |||||
| # json.partial! 'users/user_small', users: @tea_users | |||||
| # end | |||||
| # | |||||
| # json.students do | |||||
| # json.partial! 'users/user_small', users: @stu_users | |||||
| # end | |||||
| # end | |||||
| @@ -1,33 +1,4 @@ | |||||
| json.setting do | json.setting do | ||||
| # if @laboratory.present? | |||||
| # setting = @laboratory.laboratory_setting | |||||
| # json.name setting.name || default_setting.name | |||||
| # json.nav_logo_url (setting.nav_logo_url || default_setting.nav_logo_url)&.[](1..-1) | |||||
| # json.login_logo_url (setting.login_logo_url || default_setting.login_logo_url)&.[](1..-1) | |||||
| # json.tab_logo_url (setting.tab_logo_url || default_setting.tab_logo_url)&.[](1..-1) | |||||
| # | |||||
| # json.subject_banner_url (setting.subject_banner_url || default_setting.subject_banner_url)&.[](1..-1) | |||||
| # json.course_banner_url (setting.course_banner_url || default_setting.course_banner_url)&.[](1..-1) | |||||
| # json.competition_banner_url (setting.competition_banner_url || default_setting.competition_banner_url)&.[](1..-1) | |||||
| # json.moop_cases_banner_url (setting.moop_cases_banner_url || default_setting.moop_cases_banner_url)&.[](1..-1) | |||||
| # json.oj_banner_url (setting.oj_banner_url || default_setting.oj_banner_url)&.[](1..-1) | |||||
| # | |||||
| # json.navbar setting.navbar || default_setting.navbar | |||||
| # | |||||
| # json.footer setting.footer || default_setting.footer | |||||
| # | |||||
| # end | |||||
| # nav_bar = default_setting.navbar | |||||
| # if User.current.logged? | |||||
| # nav_bar[2]["link"] = "https://forgeplus.trustie.net/users/#{current_user.login}/projects" | |||||
| # nav_bar[2]["hidden"] = false | |||||
| # else | |||||
| # nav_bar[2]["link"] = "" | |||||
| # nav_bar[2]["hidden"] = true | |||||
| # end | |||||
| json.name default_setting.name | json.name default_setting.name | ||||
| json.nav_logo_url default_setting.nav_logo_url&.[](1..-1) | json.nav_logo_url default_setting.nav_logo_url&.[](1..-1) | ||||
| json.login_logo_url default_setting.login_logo_url&.[](1..-1) | json.login_logo_url default_setting.login_logo_url&.[](1..-1) | ||||
| @@ -35,11 +6,11 @@ json.setting do | |||||
| json.site_page_deploy_domain @deploy_domain | json.site_page_deploy_domain @deploy_domain | ||||
| json.subject_banner_url default_setting.subject_banner_url&.[](1..-1) | json.subject_banner_url default_setting.subject_banner_url&.[](1..-1) | ||||
| json.course_banner_url default_setting.course_banner_url&.[](1..-1) | |||||
| # json.course_banner_url default_setting.course_banner_url&.[](1..-1) | |||||
| json.competition_banner_url EduSetting.get("competition_banner_url").to_s | json.competition_banner_url EduSetting.get("competition_banner_url").to_s | ||||
| json.competition_banner_href EduSetting.get("competition_banner_href").to_s | json.competition_banner_href EduSetting.get("competition_banner_href").to_s | ||||
| json.moop_cases_banner_url default_setting.moop_cases_banner_url&.[](1..-1) | |||||
| json.oj_banner_url default_setting.oj_banner_url&.[](1..-1) | |||||
| # json.moop_cases_banner_url default_setting.moop_cases_banner_url&.[](1..-1) | |||||
| # json.oj_banner_url default_setting.oj_banner_url&.[](1..-1) | |||||
| json.navbar @navbar | json.navbar @navbar | ||||
| @@ -62,15 +33,15 @@ json.setting do | |||||
| end | end | ||||
| json.common @common | json.common @common | ||||
| json.third_party @third_party | |||||
| # json.third_party @third_party | |||||
| json.third_party_new @third_party_new | json.third_party_new @third_party_new | ||||
| if @top_system_notification.present? | |||||
| json.system_notification do | |||||
| json.(@top_system_notification, :id, :subject, :sub_subject, :content) | |||||
| json.is_read @top_system_notification.read_member?(current_user&.id) | |||||
| end | |||||
| else | |||||
| json.system_notification nil | |||||
| end | |||||
| # if @top_system_notification.present? | |||||
| # json.system_notification do | |||||
| # json.(@top_system_notification, :id, :subject, :sub_subject, :content) | |||||
| # json.is_read @top_system_notification.read_member?(current_user&.id) | |||||
| # end | |||||
| # else | |||||
| # json.system_notification nil | |||||
| # end | |||||
| end | end | ||||
| @@ -1,6 +1,14 @@ | |||||
| defaults format: :json do | defaults format: :json do | ||||
| namespace :api do | namespace :api do | ||||
| namespace :pm do | namespace :pm do | ||||
| resources :weekly_issues, only: [:index] do | |||||
| collection do | |||||
| get :personal | |||||
| get :group | |||||
| get :group_issues | |||||
| get :personal_issues | |||||
| end | |||||
| end | |||||
| resources :dashboards,only: [:index] do | resources :dashboards,only: [:index] do | ||||
| collection do | collection do | ||||
| get :todo | get :todo | ||||
| @@ -51,6 +59,7 @@ defaults format: :json do | |||||
| end | end | ||||
| end | end | ||||
| resources :action_runs, only: [:index] | resources :action_runs, only: [:index] | ||||
| resources :pipelines, only: [:index] | |||||
| end | end | ||||
| namespace :v1 do | namespace :v1 do | ||||
| @@ -109,6 +118,8 @@ defaults format: :json do | |||||
| post :sonar_initialize | post :sonar_initialize | ||||
| post :insert_file | post :insert_file | ||||
| get :doxygen_url | |||||
| get :analyze_doxygen | |||||
| end | end | ||||
| end | end | ||||
| @@ -148,7 +159,15 @@ defaults format: :json do | |||||
| get :keyid | get :keyid | ||||
| end | end | ||||
| end | end | ||||
| resources :portrait, only: [:index] | |||||
| resources :portrait, only: [:index] do | |||||
| collection do | |||||
| get :community_impact | |||||
| get :project_maturity | |||||
| get :project_health | |||||
| get :team_impact | |||||
| get :develop_activity | |||||
| end | |||||
| end | |||||
| resources :sync_repositories, only: [:create, :index] do | resources :sync_repositories, only: [:create, :index] do | ||||
| collection do | collection do | ||||
| post :update_info | post :update_info | ||||
| @@ -0,0 +1,5 @@ | |||||
| class AddUserIndexPhone < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_index :users, :phone | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,5 @@ | |||||
| class AddJournalDetailMsg < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_column :journal_details, :status_msg, :string | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,7 @@ | |||||
| class AddIssueEnterprise < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_column :issues, :enterprise_identifier, :string | |||||
| add_index :issues, :enterprise_identifier | |||||
| end | |||||
| end | |||||