Skip to content

Instantly share code, notes, and snippets.

@Aduciicba
Created March 18, 2016 12:34
Show Gist options
  • Save Aduciicba/2a2e9c6f43a58570ae5f to your computer and use it in GitHub Desktop.
Save Aduciicba/2a2e9c6f43a58570ae5f to your computer and use it in GitHub Desktop.
Simple code to check dialer's priority calculate algorithm for duplicates result priorities
timezones = (-1..8).to_a
reg_priotity = (0..100).to_a
call_result = (1..3).to_a
call_result_coef = 10000
reg_priotity_coef = 1000
timezones_coef = 100
result = Array.new
call_result.each { |cr|
reg_priotity.each {|reg|
timezones.each { |tz|
h = { :call_result => cr,
:reg_priority => reg,
:timezone => tz,
:result_priority => (call_result_coef - cr) + (reg_priotity_coef - reg) + (timezones_coef - tz)}
result << h
}
}
}
duplicate_arr = result.group_by { |h| h[:result_priority] }.values.select { |a| a.size > 1 }#.flatten
p '-----duplicate items--------' +
duplicate_arr.each { |duplicate_item|
p '------duplicate result ' + duplicate_item[0][:result_priority].to_s + '-------'
duplicate_item.each { |item|
p item
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment