|
|
|
@@ -7,20 +7,20 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
attr_reader :pm_project_id, :pm_sprint_id, :root_id, :pm_issue_type |
|
|
|
attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count |
|
|
|
|
|
|
|
validates :category, inclusion: {in: %w(all opened closed), message: "请输入正确的Category"} |
|
|
|
validates :participant_category, inclusion: {in: %w(all aboutme authoredme assignedme atme), message: "请输入正确的ParticipantCategory"} |
|
|
|
validates :sort_by, inclusion: {in: ['issues.created_on', 'issues.updated_on', 'issues.blockchain_token_num', 'issue_priorities.position'], message: '请输入正确的SortBy'}, allow_blank: true |
|
|
|
validates :sort_direction, inclusion: {in: %w(asc desc), message: '请输入正确的SortDirection'}, allow_blank: true |
|
|
|
validates :category, inclusion: { in: %w[all opened closed], message: '请输入正确的Category'} |
|
|
|
validates :participant_category, inclusion: { in: %w[all aboutme authoredme assignedme atme], message: '请输入正确的ParticipantCategory'} |
|
|
|
validates :sort_by, inclusion: { in: %w[issues.created_on issues.updated_on issues.blockchain_token_num issue_priorities.position issues.start_date issues.due_date] , message: '请输入正确的SortBy'}, allow_blank: true |
|
|
|
validates :sort_direction, inclusion: { in: %w[asc desc], message: '请输入正确的SortDirection'}, allow_blank: true |
|
|
|
validates :current_user, presence: true |
|
|
|
|
|
|
|
def initialize(project, params, current_user=nil) |
|
|
|
def initialize(project, params, current_user = nil) |
|
|
|
@project = project |
|
|
|
@only_name = params[:only_name] |
|
|
|
@category = params[:category] || 'all' |
|
|
|
@participant_category = params[:participant_category] || 'all' |
|
|
|
@keyword = params[:keyword] |
|
|
|
@author_id = params[:author_id] |
|
|
|
@issue_tag_ids = params[:issue_tag_ids].present? ? params[:issue_tag_ids].split(",") : [] |
|
|
|
@issue_tag_ids = params[:issue_tag_ids].present? ? params[:issue_tag_ids].split(',') : [] |
|
|
|
@milestone_id = params[:milestone_id] |
|
|
|
@assigner_id = params[:assigner_id] |
|
|
|
@status_id = params[:status_id] |
|
|
|
@@ -35,12 +35,12 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
@current_user = current_user |
|
|
|
end |
|
|
|
|
|
|
|
def call |
|
|
|
raise Error, errors.full_messages.join(", ") unless valid? |
|
|
|
def call |
|
|
|
raise Error, errors.full_messages.join(', ') unless valid? |
|
|
|
# begin |
|
|
|
issue_query_data |
|
|
|
issue_query_data |
|
|
|
|
|
|
|
return {data: queried_issues, total_issues_count: @total_issues_count, closed_issues_count: @closed_issues_count, opened_issues_count: @opened_issues_count} |
|
|
|
{data: queried_issues, total_issues_count: @total_issues_count, closed_issues_count: @closed_issues_count, opened_issues_count: @opened_issues_count} |
|
|
|
# rescue |
|
|
|
# raise Error, "服务器错误,请联系系统管理员!" |
|
|
|
# end |
|
|
|
@@ -52,7 +52,7 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
|
|
|
|
case participant_category |
|
|
|
when 'aboutme' # 关于我的 |
|
|
|
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: %w(authored assigned atme), participant_id: current_user&.id}) |
|
|
|
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: %w[authored assigned atme], participant_id: current_user&.id}) |
|
|
|
when 'authoredme' # 我创建的 |
|
|
|
issues = issues.joins(:issue_participants).where(issue_participants: {participant_type: 'authored', participant_id: current_user&.id}) |
|
|
|
when 'assignedme' # 我负责的 |
|
|
|
@@ -64,7 +64,7 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
issues = issues.where(author_id: author_id) if author_id.present? |
|
|
|
|
|
|
|
# issue_tag_ids |
|
|
|
issues = issues.ransack(issue_tags_value_cont: issue_tag_ids.sort!.join(",")).result unless issue_tag_ids.blank? |
|
|
|
issues = issues.ransack(issue_tags_value_cont: issue_tag_ids.sort!.join(',')).result unless issue_tag_ids.blank? |
|
|
|
|
|
|
|
# milestone_id |
|
|
|
issues = issues.where(fixed_version_id: milestone_id) if milestone_id.present? |
|
|
|
@@ -91,7 +91,7 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
issues = issues.where(status_id: status_id) if status_id.present? && category != 'closed' |
|
|
|
|
|
|
|
if begin_date&.present? || end_date&.present? |
|
|
|
issues = issues.where("issues.created_on between ? and ?", begin_date&.present? ? begin_date.to_time : Time.now.beginning_of_day, end_date&.present? ? end_date.to_time.end_of_day : Time.now.end_of_day) |
|
|
|
issues = issues.where('issues.created_on between ? and ?', begin_date&.present? ? begin_date.to_time : Time.now.beginning_of_day, end_date&.present? ? end_date.to_time.end_of_day : Time.now.end_of_day) |
|
|
|
end |
|
|
|
|
|
|
|
# keyword |
|
|
|
|