-
Notifications
You must be signed in to change notification settings - Fork 7
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 null values from events #82
Conversation
a059968
to
29a98c2
Compare
Gemfile
Outdated
@@ -6,6 +6,21 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |||
# Specify your gem's dependencies in dfe-analytics.gemspec | |||
gemspec | |||
|
|||
group :development do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷 If this is what rubocop wants!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work so I had to enforce the gemspec style. This required rubocop updates and subsequent updates of all the Gemfiles.
lib/dfe/analytics/event.rb
Outdated
@@ -115,10 +110,14 @@ def convert_value_to_json(value) | |||
|
|||
def hash_to_kv_pairs(hash) | |||
hash.map do |(key, values)| | |||
values_as_json = Array.wrap(values).map do |value| | |||
convert_value_to_json(value) | |||
if Array.wrap(values).count(&:nil?).positive? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Array.wrap(values).count(&:nil?).positive? | |
if Array.wrap(values).any?(&:nil?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That's better !
lib/dfe/analytics/event.rb
Outdated
values_as_json = Array.wrap(values).map do |value| | ||
convert_value_to_json(value) | ||
if Array.wrap(values).count(&:nil?).positive? | ||
message = "event has missing values in data - event: #{@event_hash} key: #{key} values: #{values}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message = "event has missing values in data - event: #{@event_hash} key: #{key} values: #{values}" | |
message = "an array field contains nulls - event: #{@event_hash} key: #{key} values: #{values}" |
974239d
to
d673ca3
Compare
d673ca3
to
c48cdd9
Compare
Trello-1253
In TV a number of events are not being sent to BQ from the vacancies table. When we attempted a backfill, there were a lot of errors in the sidekiq dead queues.
After adding more diagnosis to the error logs (See PR), we were able to find the bug.
In the values field of the event data, some value array fields have
nil
values.For example these entries for the vacancies table are causing API errors:
The following changes have been made by this PR:
nil
values and write a warning message to the logs