Skip to content

Instantly share code, notes, and snippets.

@khun84
Last active January 19, 2022 02:31
Show Gist options
  • Save khun84/b7ca10f5debe834599af76631743d841 to your computer and use it in GitHub Desktop.
Save khun84/b7ca10f5debe834599af76631743d841 to your computer and use it in GitHub Desktop.
Holistics jobs export
require 'json'
require 'csv'
data = `pbpaste`
data = JSON.parse(data);nil
data = data.select{|d| d.dig('schedule', 'paused') == false && d['source_type'] == 'dbtable' };nil
keys = [
'title',
'description',
'src_db', # from_ds_name
'src_table', # source_config.fqname
'interval', # schedule.friendly_description
]
jobs = data.each_with_object([]) do |d, memo|
memo << [d['title'], d['description'], d['from_ds_name'], d.dig('source_config', 'dbtable', 'fqname'), d.dig('schedule','friendly_description')]
end;nil
CSV.open('tmp/holistics-job.csv','w', write_headers: true, headers: keys) do |csv|
jobs.each {|j| csv << j}
end;nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment