Skip to content

Commit

Permalink
Remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonhoc committed Mar 25, 2024
1 parent 2e24c78 commit 9692eab
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def sort_by_name(facilities)
def sort_by_recent_appointment(facilities)
appointments = Mobile::V0::Appointment.get_cached(@current_user)&.sort_by(&:start_date_utc)

log_nil_cache if appointments.nil?
return facilities if appointments.blank?

appointment_facility_ids = appointments.map(&:facility_id).uniq
Expand All @@ -68,10 +67,6 @@ def sort_by_recent_appointment(facilities)
facilities.sort_by { |facility| appointment_facilities_hash[facility.id] || appointment_facility_ids.size }
end

def log_nil_cache
Rails.logger.info('mobile facilities info appointments cache nil', user_uuid: @current_user.uuid)
end

def validate_sort_method_inclusion!
unless SORT_METHODS.include?(params[:sort])
raise Common::Exceptions::InvalidFieldValue.new('sort', params[:sort])
Expand Down
10 changes: 0 additions & 10 deletions modules/mobile/app/helpers/mobile/facilities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ def phone_from_facility(facility)
# and optional extension (until the end of the string) (?:\sx(\d*))?$
phone_captures = phone.match(/^(\d{3})-(\d{3}-\d{4})(?:\sx(\d*))?$/)

if phone_captures.nil?
Rails.logger.warn(
'mobile appointments failed to parse facility phone number',
facility_id: facility.id,
facility_phone: facility.phone
)
return nil
end

Mobile::V0::AppointmentPhone.new(
area_code: phone_captures[1].presence,
number: phone_captures[2].presence,
Expand All @@ -104,7 +95,6 @@ def phone_from_facility(facility)
# Returns the distance between these two
# points in either miles or kilometers
def haversine_distance(geo_a, geo_b, miles: true)
Rails.logger.info('haversine_distance coords', geo_a, geo_b)
# Get latitude and longitude
lat1, lon1 = geo_a
lat2, lon2 = geo_b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ def format_service_period(service_period)

def discharge_code_section(service_period)
discharge_code = service_period[:character_of_discharge_code]
if discharge_code.present? && DISCHARGE_CODE_MAP.keys.exclude?(discharge_code)
Rails.logger.error('Invalid discharge code', code: discharge_code)
end
DISCHARGE_CODE_MAP[discharge_code]
end
end
Expand Down
240 changes: 113 additions & 127 deletions modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def build_appointment_model

Mobile::V0::Appointment.new(adapted_appointment)
end

# rubocop:enable Metrics/MethodLength

private
Expand Down Expand Up @@ -174,15 +175,15 @@ def utc_to_fileman_date(datetime)

def timezone
@timezone ||= begin
time_zone = appointment.dig(:location, :time_zone, :time_zone_id)
return time_zone if time_zone
time_zone = appointment.dig(:location, :time_zone, :time_zone_id)
return time_zone if time_zone

return nil unless facility_id
return nil unless facility_id

# not always correct if clinic is different time zone than parent
facility = Mobile::VA_FACILITIES_BY_ID["dfn-#{facility_id[0..2]}"]
facility ? facility[:time_zone] : nil
end
# not always correct if clinic is different time zone than parent
facility = Mobile::VA_FACILITIES_BY_ID["dfn-#{facility_id[0..2]}"]
facility ? facility[:time_zone] : nil
end

Check failure on line 186 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/BeginEndAlignment: `end` at 186, 24 is not aligned with `@timezone ||= begin` at 177, 10.
end

def cancel_id
Expand All @@ -203,15 +204,7 @@ def type_of_care(service_type)

def cancellation_reason(cancellation_reason)
if cancellation_reason.nil?
if status == STATUSES[:cancelled]
Rails.logger.info('cancelled appt missing cancellation reason with debug info',
type: appointment_type,
kind: appointment[:kind],
vista_status: appointment.dig(:extension, :vista_status),
facility_id:,
clinic: appointment[:clinic])
return CANCELLATION_REASON[:prov]
end
return CANCELLATION_REASON[:prov] if status == STATUSES[:cancelled]

Check failure on line 207 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
return nil
end

Expand Down Expand Up @@ -251,34 +244,34 @@ def status

def requested_periods
@requested_periods ||= begin
if reason_code_contains_embedded_data?
date_string = embedded_data[:preferred_dates]
return date_string&.split(',')
end
if reason_code_contains_embedded_data?
date_string = embedded_data[:preferred_dates]
return date_string&.split(',')
end

appointment[:requested_periods]
end
appointment[:requested_periods]
end

Check failure on line 253 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/BeginEndAlignment: `end` at 253, 33 is not aligned with `@requested_periods ||= begin` at 246, 10.
end

def start_date_utc
@start_date_utc ||= begin
start = appointment[:start]
if start.nil?
sorted_dates = requested_periods.map { |period| time_to_datetime(period[:start]) }.sort
future_dates = sorted_dates.select { |period| period > DateTime.now }
future_dates.any? ? future_dates.first : sorted_dates.first
else
time_to_datetime(start)
end
end
start = appointment[:start]
if start.nil?
sorted_dates = requested_periods.map { |period| time_to_datetime(period[:start]) }.sort

Check failure on line 260 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/LineLength: Line is too long. [121/120]
future_dates = sorted_dates.select { |period| period > DateTime.now }
future_dates.any? ? future_dates.first : sorted_dates.first
else
time_to_datetime(start)
end
end

Check failure on line 266 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/BeginEndAlignment: `end` at 266, 30 is not aligned with `@start_date_utc ||= begin` at 257, 10.
end

def start_date_local
@start_date_local ||= begin
DateTime.parse(appointment[:local_start_time])
rescue
start_date_utc&.in_time_zone(timezone)
end
DateTime.parse(appointment[:local_start_time])
rescue

Check failure on line 272 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/RescueEnsureAlignment: `rescue` at 272, 32 is not aligned with `@start_date_local ||= begin` at 270, 10.
start_date_utc&.in_time_zone(timezone)
end

Check failure on line 274 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/BeginEndAlignment: `end` at 274, 32 is not aligned with `@start_date_local ||= begin` at 270, 10.
end

def appointment_type
Expand Down Expand Up @@ -309,91 +302,92 @@ def appointment_type
# rubocop:disable Metrics/MethodLength
def location
@location ||= begin
location = {
id: nil,
name: nil,
address: {
street: nil,
city: nil,
state: nil,
zip_code: nil
},
lat: nil,
long: nil,
phone: {
area_code: nil,
number: nil,
extension: nil
},
url: nil,
code: nil
}

case appointment_type
when APPOINTMENT_TYPES[:cc]
cc_location = appointment.dig(:extension, :cc_location)

if cc_location.present?
location[:name] = cc_location[:practice_name]
location[:address] = {
street: cc_location.dig(:address, :line)&.join(' ')&.strip,
city: cc_location.dig(:address, :city),
state: cc_location.dig(:address, :state),
zip_code: cc_location.dig(:address, :postal_code)
}
if cc_location[:telecom].present?
phone_number = cc_location[:telecom]&.find do |contact|
contact[:system] == CONTACT_TYPE[:phone]
end&.dig(:value)

location[:phone] = parse_phone(phone_number)
end

end
when APPOINTMENT_TYPES[:va_video_connect_atlas],
APPOINTMENT_TYPES[:va_video_connect_home],
APPOINTMENT_TYPES[:va_video_connect_gfe]

location[:name] = appointment.dig(:location, :name)
location[:phone] = parse_phone(appointment.dig(:location, :phone, :main))
telehealth = appointment[:telehealth]

if telehealth
address = telehealth.dig(:atlas, :address)

if address
location[:address] = {
street: address[:street_address],
city: address[:city],
state: address[:state],
zip_code: address[:zip_code],
country: address[:country]
}
end
location[:url] = telehealth[:url]
location[:code] = telehealth.dig(:atlas, :confirmation_code)
end
else
location[:id] = appointment.dig(:location, :id)
location[:name] = appointment.dig(:location, :name)

address = appointment.dig(:location, :physical_address)
if address.present?
location[:address] = {
street: address[:line]&.join(' ')&.strip,
city: address[:city],
state: address[:state],
zip_code: address[:postal_code]
}
end
location[:lat] = appointment.dig(:location, :lat)
location[:long] = appointment.dig(:location, :long)
location[:phone] = parse_phone(appointment.dig(:location, :phone, :main))
end

location
end
location = {
id: nil,
name: nil,
address: {
street: nil,
city: nil,
state: nil,
zip_code: nil
},
lat: nil,
long: nil,
phone: {
area_code: nil,
number: nil,
extension: nil
},
url: nil,
code: nil
}

case appointment_type
when APPOINTMENT_TYPES[:cc]
cc_location = appointment.dig(:extension, :cc_location)

if cc_location.present?
location[:name] = cc_location[:practice_name]
location[:address] = {
street: cc_location.dig(:address, :line)&.join(' ')&.strip,
city: cc_location.dig(:address, :city),
state: cc_location.dig(:address, :state),
zip_code: cc_location.dig(:address, :postal_code)
}
if cc_location[:telecom].present?
phone_number = cc_location[:telecom]&.find do |contact|
contact[:system] == CONTACT_TYPE[:phone]
end&.dig(:value)

location[:phone] = parse_phone(phone_number)
end

end
when APPOINTMENT_TYPES[:va_video_connect_atlas],
APPOINTMENT_TYPES[:va_video_connect_home],
APPOINTMENT_TYPES[:va_video_connect_gfe]

location[:name] = appointment.dig(:location, :name)
location[:phone] = parse_phone(appointment.dig(:location, :phone, :main))
telehealth = appointment[:telehealth]

if telehealth
address = telehealth.dig(:atlas, :address)

if address
location[:address] = {
street: address[:street_address],
city: address[:city],
state: address[:state],
zip_code: address[:zip_code],
country: address[:country]
}
end
location[:url] = telehealth[:url]
location[:code] = telehealth.dig(:atlas, :confirmation_code)
end
else
location[:id] = appointment.dig(:location, :id)
location[:name] = appointment.dig(:location, :name)

address = appointment.dig(:location, :physical_address)
if address.present?
location[:address] = {
street: address[:line]&.join(' ')&.strip,
city: address[:city],
state: address[:state],
zip_code: address[:postal_code]
}
end
location[:lat] = appointment.dig(:location, :lat)
location[:long] = appointment.dig(:location, :long)
location[:phone] = parse_phone(appointment.dig(:location, :phone, :main))
end

location
end

Check failure on line 388 in modules/mobile/app/models/mobile/v0/adapters/vaos_v2_appointment.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/BeginEndAlignment: `end` at 388, 24 is not aligned with `@location ||= begin` at 304, 10.
end

# rubocop:enable Metrics/MethodLength

def parse_phone(phone)
Expand All @@ -409,14 +403,6 @@ def parse_phone(phone)
}
end

unless phone.nil?
# this logging is intended to be temporary. Remove if it's not occurring
Rails.logger.warn(
'mobile appointments failed to parse VAOS V2 phone number',
phone:
)
end

{ area_code: nil, number: nil, extension: nil }
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def get_disability_ratings # rubocop:disable Metrics/MethodLength
raise Common::Exceptions::BackendServiceException, 'MOBL_502_upstream_error'
rescue => e
if e.respond_to?('response')
Rails.logger.info('LEGACY DR ERRORS WITH RESPONSE', error: e)
case e.response[:status]
when 400
raise Common::Exceptions::BackendServiceException, 'MOBL_404_rating_not_found'
Expand All @@ -41,7 +40,6 @@ def get_disability_ratings # rubocop:disable Metrics/MethodLength
raise e
end
else
Rails.logger.info('LEGACY DR ERRORS WITHOUT RESPONSE', error: e)
raise e
end
end
Expand Down
Loading

0 comments on commit 9692eab

Please sign in to comment.