Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fix for ignored columns #99

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions lib/dfe/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def self.models_for_entity(entity)
def self.extract_model_attributes(model, attributes = nil)
# if no list of attrs specified, consider all attrs belonging to this model
attributes ||= model.attributes
add_ignored_columns_to_attributes(model, attributes) if model.class.ignored_columns.any?
table_name = model.class.table_name

exportable_attrs = allowlist[table_name.to_sym].presence || []
Expand All @@ -194,14 +193,6 @@ def self.extract_model_attributes(model, attributes = nil)
allowed_attributes.deep_merge(obfuscated_attributes.transform_values { |value| pseudonymise(value) })
end

def self.add_ignored_columns_to_attributes(model, attributes)
ignored_columns = model.class.ignored_columns
return attributes if ignored_columns.blank?

nil_values_hash = ignored_columns.to_h { |key| [key, nil] }
attributes.merge!(nil_values_hash)
end

def self.anonymise(value)
pseudonymise(value)
end
Expand Down
46 changes: 0 additions & 46 deletions spec/dfe/analytics/entities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@

with_model :Candidate do
table do |t|
t.string :type
t.string :email_address
t.string :last_name
t.string :first_name
t.string :user_id
t.boolean :degree
end
end

before do
stub_const('Teacher', Class.new(Candidate))
stub_const('Assistant', Class.new(Candidate))
Teacher.ignored_columns = %w[user_id]
Assistant.ignored_columns = %w[user_id degree]
allow(DfE::Analytics::SendEvents).to receive(:perform_later)
allow(DfE::Analytics).to receive(:enabled?).and_return(true)

Expand Down Expand Up @@ -134,46 +128,6 @@
.with([a_hash_including({ 'event_type' => 'create_entity' })])
end
end

context 'when there is an ignored_column on the entity' do
let(:interesting_fields) { %w[email_address first_name user_id degree] }

it 'is included in the payload as a null value' do
Candidate.create(id: 123, first_name: 'Adrienne', email_address: 'adrienne@example.com', user_id: '45', degree: true)
Teacher.create(id: 124, first_name: 'Brianne', email_address: 'brianne@example.com', degree: true)
Assistant.create(id: 125, first_name: 'Taryn', email_address: 'taryn@example.com')

expect(DfE::Analytics::SendEvents).to have_received(:perform_later)
.with([a_hash_including({
'data' => [
{ 'key' => 'email_address', 'value' => ['adrienne@example.com'] },
{ 'key' => 'first_name', 'value' => ['Adrienne'] },
{ 'key' => 'user_id', 'value' => ['45'] },
{ 'key' => 'degree', 'value' => ['true'] }
]
})])

expect(DfE::Analytics::SendEvents).to have_received(:perform_later)
.with([a_hash_including({
'data' => [
{ 'key' => 'email_address', 'value' => ['brianne@example.com'] },
{ 'key' => 'first_name', 'value' => ['Brianne'] },
{ 'key' => 'user_id', 'value' => [] },
{ 'key' => 'degree', 'value' => ['true'] }
]
})])

expect(DfE::Analytics::SendEvents).to have_received(:perform_later)
.with([a_hash_including({
'data' => [
{ 'key' => 'email_address', 'value' => ['taryn@example.com'] },
{ 'key' => 'first_name', 'value' => ['Taryn'] },
{ 'key' => 'user_id', 'value' => [] },
{ 'key' => 'degree', 'value' => [] }
]
})])
end
end
end

describe 'update_entity events' do
Expand Down
Loading