$stdout.sync = true require_relative '../lib/help-desk-dashboard/config_loader' require_relative '../lib/help-desk-dashboard/extensions' require_relative '../lib/help-desk-dashboard/provider_factory' config = load_config provider_factory = ProviderFactory.new provider = provider_factory.create config requests = provider.get_requests.map do |r| r.pick :id, :title, :status, :deadline, :assigned_to, :submitted_by, :submitted_on, :resolved_on end requests.each do |r| user = config[:users].select { |u| u[:username] == r[:assigned_to] }[0] r[:assigned_to] = user[:name] if user user = config[:users].select { |u| u[:username] == r[:submitted_by] }[0] r[:submitted_by] = user[:name] if user end data = { title: config[:title], requests: requests } public_web_dir = File.join File.dirname(__FILE__) + '/../lib/help-desk-dashboard/web/public' data_file = File.join public_web_dir, 'data.json' File.write data_file, data.to_json FileUtils.cp_r "#{public_web_dir}/.", config[:output_dir] puts 'Done.'