Rent index to location factor
- First commit: replace rent index + market adjustment formula and references with location factor.
- Second commit: actually recalculate location factor using the above formula (you can see those changes at aeb1589e).
I did the second commit with this Ruby script:
require 'yaml'
location_factors = YAML.load_file('data/location_factors.yml')
hot_markets = YAML.load_file('data/hotmarkets.yml')
output = ''
def hot_market_adjustment(hot_markets, country, area)
market = hot_markets.find do |hot_market|
hot_market['country'] == country && hot_market['area'] == area
end || {}
market.fetch('hotmarket', 0)
end
location_factors.each do |location_factor|
factor = location_factor['locationFactor']
adjustment = hot_market_adjustment(hot_markets, location_factor['country'], location_factor['area'])
new_location_factor = 70 * ([20, factor + adjustment].max / 126.0) + 30
comment = if adjustment > 0
" # after adding adjustment of #{adjustment}"
elsif factor < 0.2
" # 20 taken as the value was #{factor}"
else
''
end
output << <<LOCATION
- country: #{location_factor['country']}
area: #{location_factor['area']}
locationFactor: #{new_location_factor.round(3)}#{comment}
LOCATION
end
puts output
Note: that there are some small differences in output. I think these are down to rounding: essentially, we now round the result of the formula, rather than just the inputs, so we get some changes. If this isn't acceptable we can increase the precision in location_factors.yml
which should address the issue.
Closes https://gitlab.com/gitlab-com/people-ops/General/issues/253.
Edited by Sean McGivern