新增:自动生成周报数据返回
This commit is contained in:
parent
330ab008a8
commit
1af1917579
|
@ -0,0 +1,47 @@
|
||||||
|
class Api::Pm::WeeklyIssuesController < ApplicationController
|
||||||
|
|
||||||
|
def personal
|
||||||
|
@enterprise_identifier = params[:enterprise_identifier] || ''
|
||||||
|
@all_issues = Issue.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)
|
||||||
|
@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)
|
||||||
|
@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])
|
||||||
|
end
|
||||||
|
|
||||||
|
def group
|
||||||
|
@enterprise_identifier = params[:enterprise_identifier] || ''
|
||||||
|
@all_issues = Issue.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)
|
||||||
|
@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
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
json.this_week_all_issues @this_week_all_issues.each do |issue|
|
||||||
|
json.partial! "api/v1/issues/simple_detail", locals: {issue: issue}
|
||||||
|
end
|
||||||
|
json.next_week_all_issues @next_week_all_issues.each do |issue|
|
||||||
|
json.partial! "api/v1/issues/simple_detail", locals: {issue: issue}
|
||||||
|
end
|
||||||
|
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
|
|
@ -1,6 +1,12 @@
|
||||||
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
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :dashboards,only: [:index] do
|
resources :dashboards,only: [:index] do
|
||||||
collection do
|
collection do
|
||||||
get :todo
|
get :todo
|
||||||
|
|
Loading…
Reference in New Issue