Skip to content

Commit

Permalink
The source is dashboard.users, not dashboard.user_geos
Browse files Browse the repository at this point in the history
  • Loading branch information
hacodeorg committed Jun 27, 2020
1 parent f9c766b commit 7324faf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dashboard/app/models/contact_rollups_processed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,16 @@ def self.extract_roles(contact_data)
end

def self.extract_state(contact_data)
# The priority is: school state > user geo state > form geo state
# The priority is: school state > user state > form geo state
# US state in schools table is in abbreviation, must convert it back to state name.
school_state = extract_field_latest_value contact_data, 'dashboard.schools', 'state'
if school_state
state_name = get_us_state_from_abbr(school_state, true) || school_state
return {state: state_name}
end

user_geo_state = extract_field_latest_value contact_data, 'dashboard.user_geos', 'state'
return {state: user_geo_state} if user_geo_state
user_state = extract_field_latest_value contact_data, 'dashboard.users', 'state'
return {state: user_state} if user_state

form_geo_state = extract_field_latest_value contact_data, 'pegasus.form_geos', 'state'
form_geo_state.nil? ? {} : {state: form_geo_state}
Expand Down
14 changes: 7 additions & 7 deletions dashboard/test/models/contact_rollups_processed_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ class ContactRollupsProcessedTest < ActiveSupport::TestCase
]
}
}
user_geos_input = {
'dashboard.user_geos' => {
users_input = {
'dashboard.users' => {
'state' => [
{'value' => 'Texas', 'data_updated_at' => base_time - 1.day},
{'value' => 'Florida', 'data_updated_at' => base_time},
Expand All @@ -385,21 +385,21 @@ class ContactRollupsProcessedTest < ActiveSupport::TestCase
expected_output: {state: 'California'}
},
{
input: user_geos_input,
input: users_input,
expected_output: {state: 'Florida'}
},
{
input: schools_input,
expected_output: {state: 'Illinois'}
},
# user_geos data has higher priority than form_geos data
# users data has higher priority than form_geos data
{
input: form_geos_input.merge(user_geos_input),
input: form_geos_input.merge(users_input),
expected_output: {state: 'Florida'}
},
# schools data has higher priority than user_geos data
# schools data has higher priority than users data
{
input: form_geos_input.merge(user_geos_input).merge(schools_input),
input: form_geos_input.merge(users_input).merge(schools_input),
expected_output: {state: 'Illinois'}
}
]
Expand Down
2 changes: 1 addition & 1 deletion lib/test/cdo/contact_rollups/test_pardot_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_convert_to_pardot_prospect_single_value_attributes
id: 10,
db_Opt_In: 'Yes',
db_Has_Teacher_Account: 'true',
db_State: 'Washington'
db_State: 'Washington',
}
},
{
Expand Down

0 comments on commit 7324faf

Please sign in to comment.