Class: LesliSupport::TicketService
- Inherits:
-
Lesli::ApplicationLesliService
- Object
- Lesli::ApplicationLesliService
- LesliSupport::TicketService
- Defined in:
- app/services/lesli_support/ticket_service.rb
Instance Method Summary collapse
- #create(ticket_params) ⇒ Object
- #find(ticket_id) ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
- #update(params) ⇒ Object
- #with_deadline ⇒ Object
Instance Method Details
#create(ticket_params) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/services/lesli_support/ticket_service.rb', line 83 def create(ticket_params) ticket = current_user.account.support.tickets.new(ticket_params) #ticket.source = Catalog::TicketSource.cloud_help_source(current_user.account.help) ticket.creator = current_user ticket.user = current_user unless ticket_params.dig(:started_at) #ticket.started_at = LC::Date2.new(Time.current).date.get end if ticket.save #Ticket.log_activity_create(current_user, ticket) #Ticket::Subscriber.add_subscriber(ticket, current_user, "discussion_created", "email") #Workflow::Action.execute_actions(current_user, ticket, {}, ticket.attributes) self.resource = ticket else pp ticket.errors. self.error(ticket.errors..to_sentence) end self end |
#find(ticket_id) ⇒ Object
36 37 38 |
# File 'app/services/lesli_support/ticket_service.rb', line 36 def find ticket_id super(current_user.account.support.tickets.find_by(id: ticket_id)) end |
#index ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/services/lesli_support/ticket_service.rb', line 40 def index return current_user.account.support.tickets.left_joins( :user, :creator, :catalog_priority ).select( :id, :subject, :deadline, :creator_id, :user_id, "CONCAT_WS(' ', lesli_users.first_name, lesli_users.last_name) as user_name", "CONCAT_WS(' ', creators_lesli_support_tickets.first_name, creators_lesli_support_tickets.last_name) as creator_name", "lesli_support_tickets.updated_at", "lesli_support_tickets.created_at", "lesli_support_catalog_priorities.name as priority_name" ).order(id: :desc) .page(query[:pagination][:page]) .per(query[:pagination][:perPage]) current_user.account.help.tickets.left_joins( :priority, :type, :workspace, :category, :status, :assignments, :assigned, :user ).select( :id, :subject, :deadline, :assigned_id, :user_id, "CONCAT_WS(' ', users.first_name, users.last_name) as assigned_name", "CONCAT_WS(' ', users_cloud_help_tickets.first_name, users_cloud_help_tickets.last_name) as user_name", "cloud_help_tickets.updated_at", "cloud_help_tickets.created_at" ) end |
#show ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'app/services/lesli_support/ticket_service.rb', line 107 def show() return current_user.account.support.tickets.left_joins( :user, :creator ).select( :id, :subject, :description, :reference_url, :deadline, :started_at, :completed_at, :hours_worked, :creator_id, :user_id, :catalog_workspace_id, :catalog_type_id, :catalog_category_id, :catalog_priority_id, "CONCAT_WS(' ', lesli_users.first_name, lesli_users.last_name) as user_name", "CONCAT_WS(' ', creators_lesli_support_tickets.first_name, creators_lesli_support_tickets.last_name) as creator_name", "lesli_support_tickets.updated_at", "lesli_support_tickets.created_at" ).where("lesli_support_tickets.id = ?", self.resource.id).first end |
#update(params) ⇒ Object
132 133 134 |
# File 'app/services/lesli_support/ticket_service.rb', line 132 def update(params) self.resource.update(params) end |
#with_deadline ⇒ Object
136 137 138 139 140 141 142 143 144 145 |
# File 'app/services/lesli_support/ticket_service.rb', line 136 def with_deadline() current_user.account.support.tickets #.joins("left join cloud_help_ticket_assignments chta on chta.cloud_help_tickets_id = cloud_help_tickets.id and chta.users_id = #{current_user.id}") .select(:id, :subject, :description, :deadline) .where.not(:deadline => nil) #.where("cloud_help_tickets.deadline >= ?", query[:filters][:start_date]) #.where("cloud_help_tickets.deadline <= ? ", query[:filters][:end_date]) #.where("cloud_help_tickets.users_id = ? or cloud_help_tickets.user_main_id = ? or chta.users_id = ?", current_user.id, current_user.id, current_user.id) .order(:deadline) end |