diff --git a/app/controllers/api/pm/weekly_issues_controller.rb b/app/controllers/api/pm/weekly_issues_controller.rb index 564333535..9ed1c7537 100644 --- a/app/controllers/api/pm/weekly_issues_controller.rb +++ b/app/controllers/api/pm/weekly_issues_controller.rb @@ -56,6 +56,8 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController def group_issues @enterprise_identifier = params[:enterprise_identifier] || '' root_id = params[:root_id] || -1 + @weekly_begin_date = params[:weekly_begin_date] || Date.today.beginning_of_week.to_s + @weekly_end_date = params[:weekly_end_date] || Date.today.end_of_week.to_s @all_issues = Issue.none if root_id.to_i == -1 @all_issues = Issue.where(root_id: nil, enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) @@ -66,13 +68,15 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController end @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 = @all_issues.where("due_date >= ? and start_date <= ?", @weekly_begin_date, @weekly_end_date) @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? + @weekly_begin_date = params[:weekly_begin_date] || Date.today.beginning_of_week.to_s + @weekly_end_date = params[:weekly_end_date] || Date.today.end_of_week.to_s root_id = params[:root_id] || -1 @all_issues = Issue.none if root_id.to_i == -1 @@ -81,9 +85,9 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController @all_issues = Issue.joins(:issue_participants).where(root_id: root_id, issue_participants: {participant_id: params[:user_id], participant_type: ['assigned']}) end @all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3]) - @this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct + @this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", @weekly_begin_date, @weekly_end_date).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 = @all_issues.where("due_date >= ? and start_date <=?", (@weekly_begin_date.to_date+1.week).to_s, (@weekly_end_date.to_date+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