BathHacked/energy-sparks

View on GitHub
lib/tasks/deployment/20231016121907_update_data_feed_config_titles_and_comments.rake

Summary

Maintainability
Test Coverage
namespace :after_party do
  desc 'Deployment task: update_data_feed_config_titles_and_comments'
  task update_data_feed_config_titles_and_comments: :environment do
    puts "Running deploy task 'update_data_feed_config_titles_and_comments'"

    UPDATES = {
      'energy-assets' => {
        description: 'Energy assets generic feed'
      },
      'crown' => {
        notes: 'This data config is used to process files sent to the data inbox from hello@crowngas.co.uk'
      },
      'npower-ia' => {
        description: 'Npower Intelligent Analytics'
      },
      'sse1' => {
        description: 'SSE1 (can include volume and reactive energy)'
      },
      'digital-energy' => {
        notes: 'This data config is used to process files sent to the data inbox from noreply@digitalenergy.org.uk. Digital Energy generate reports for schools who purchase through Doncaster Council.'
      },
      'sse2' => {
        description: 'SSE2 (Includes Lag and Lead)'
      },
      'smartest-energy-portal' => {
        notes: 'This data config is used to process files downloaded manually from the Source Profile data portal for Smartest Energy customers.'
      },
      'stark-portal-electricity' => {
        notes: 'This data config is used to process files downloaded manually from the Stark portal. This config can be used for electricity files only.'
      },
      'smartestenergy-stark' => {
        notes: 'This data config is used to process files sent to the data inbox from SavenergyOnline@stark.co.uk. These reports are generated by Stark on behalf of the SourceProfile team (Smartest Energy.)'
      },
      'corona-weekly' => {
        notes: 'This data config is used to process files sent to the data inbox from Customer-Service@coronaenergy.co.uk.'
      },
      'generic1' => {
        description: 'Generic manual upload'
      },
      'generic2' => {
        description: 'Generic 2'
      },
      'npower-eon' => {
        notes: 'This data config is used to process files requested manually from DataBusinessUnit@npower.com.'
      },
      'tgp-gas' => {
        notes: 'This data config is used to process files sent to the data inbox from do-not-reply@edi.totalgp.com and any files downloaded manually from the TGP Gas portal.'
      },
      'stark' => {
        notes: 'This data config is used to process files sent to the data inbox from SavenergyOnline@stark.co.uk. These reports are generated by Stark.'
      },
      'orsis-portal' => {
        description: 'Orsis portal'
      },
      'opus-hh' => {
        notes: 'This data config is used to process files requested manually from corporate.accounts_new@opusenergy.com for half-hourly electricity meters.'
      },
      'my-sefe-portal' => {
        notes: 'This data config is used to process files downloaded manually from the My SEFE portal for gas meters.'
      }
    }

    UPDATES.each do |identifier, updates|
      amr_data_feed_config = AmrDataFeedConfig.find_by(identifier: identifier)
      if amr_data_feed_config
        amr_data_feed_config.update!(updates)
      else
        puts "Unable to find #{identifier}"
      end
    end

    # Update task as completed.  If you remove the line below, the task will
    # run with every deploy (or every time you call after_party:run).
    AfterParty::TaskRecord
      .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
  end
end