Updated

app/controllers/accounts / events_controller.rb

A
38 lines of codes
3 methods
13.6 complexity/method
4 churn
40.84 complexity
0 duplications
class Accounts::EventsController < InternalController
  1. Accounts::EventsController has no descriptive comment
def calendar end def calendar_events
  1. Accounts::EventsController#calendar_events has a flog score of 38
start_date = Time.zone.parse(params[:start])
  1. Accounts::EventsController#calendar_events calls 'Time.zone' 2 times Locations: 0 1
end_date = Time.zone.parse(params[:end])
  1. Accounts::EventsController#calendar_events calls 'Time.zone' 2 times Locations: 0 1
events = Event.planned.where(scheduled_at: start_date..end_date) render json: events.map { |event| { id: event.id,
  1. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
title: "#{event.title} - #{event.contact.full_name}",
  1. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
start: event.scheduled_at.iso8601,
  1. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
backgroundColor: events_kind_color(event.kind),
  1. Accounts::EventsController#calendar_events calls 'event.kind' 2 times Locations: 0 1
  2. Accounts::EventsController#calendar_events calls 'events_kind_color(event.kind)' 2 times Locations: 0 1
  3. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
borderColor: events_kind_color(event.kind),
  1. Accounts::EventsController#calendar_events calls 'event.kind' 2 times Locations: 0 1
  2. Accounts::EventsController#calendar_events calls 'events_kind_color(event.kind)' 2 times Locations: 0 1
  3. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
extendedProps: { account_id: Current.account.id,
  1. Accounts::EventsController#calendar_events calls 'Current.account' 2 times Locations: 0 1
contact_id: event.contact_id,
  1. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
deal_id: event.deal_id
  1. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
}, url: account_deal_path(Current.account, event.deal)
  1. Accounts::EventsController#calendar_events calls 'Current.account' 2 times Locations: 0 1
  2. Accounts::EventsController#calendar_events refers to 'event' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7
}} end private def events_kind_color(kind) case kind
  1. Accounts::EventsController#events_kind_color is controlled by argument 'kind'
when 'chatwoot_message' '#369EF2' when 'evolution_api_message' '#26D367' else '#6857D9' end end end