-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
347 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
web: bin/puma -C config/puma.rb | ||
job: bin/rails solid_queue:start | ||
clock: bin/clockwork config/clockwork.rb | ||
scheduler: ruby config/scheduler.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class EnergyPeriod < ApplicationRecord | ||
belongs_to :zone | ||
|
||
enum :day_type, %i[working_day weekend_holiday].to_enum_hash | ||
enum :kind, %i[p1 p2 p3].to_enum_hash # P1 (Punta), P2 (Llano), P3 (Valle) | ||
|
||
validates :start_hour, presence: true | ||
validates :end_hour, presence: true | ||
|
||
# TODO hay que tener en cuenta las zonas horarias de canarias | ||
def self.kind_for(time, zone) | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Holiday < ApplicationRecord | ||
validates :name, presence: true | ||
validates :date, presence: true, uniqueness: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class PVPC < ApplicationRecord | ||
belongs_to :zone | ||
|
||
scope :by_date, ->(date) { where(time: date.all_day).order(time: :asc) } | ||
|
||
def self.read(date, zone) | ||
create!({ import: import(date, zone) || [], export: export(date, zone) || [] }) | ||
end | ||
|
||
def self.import(date, zone) | ||
::ESIOS::Import.for_date(date, zone) | ||
end | ||
|
||
def self.export(date, zone) | ||
::ESIOS::Export.for_date(date, zone) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Zone < ApplicationRecord | ||
has_many :energy_periods, dependent: :destroy | ||
has_many :pvpc, dependent: :destroy | ||
|
||
validates :name, presence: true, uniqueness: true | ||
validates :esios_import_geo_id, presence: true | ||
validates :esios_export_geo_id, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ | |
|
||
ActiveSupport::Inflector.inflections(:en) do |inflect| | ||
inflect.acronym "ESIOS" | ||
inflect.acronym "PVPC" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require_relative "environment" | ||
|
||
scheduler = Rufus::Scheduler.new | ||
loop_interval = ENV.fetch("SOLARIS_LOOP_INTERVAL", 30).to_i | ||
|
||
scheduler.every loop_interval, name: "solaris.loop", first_at: Time.current.beginning_of_minute + 1.minute do | ||
Solaris::Loop.run | ||
end | ||
|
||
scheduler.cron "0 21 * * * Europe/Madrid", name: "solaris.energy_prices.esios_pvpc" do | ||
Solaris::EnergyPrice.store(Date.tomorrow) | ||
end | ||
|
||
scheduler.cron "1 0 * * * #{tz}", name: "solaris.archive.daily" do | ||
Solaris::DailyArchive.run | ||
end | ||
|
||
scheduler.join |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateZones < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :zones do |t| | ||
t.timestamps null: false | ||
t.string :name, null: false | ||
t.integer :esios_import_geo_id, null: false | ||
t.integer :esios_export_geo_id, null: false | ||
t.index :name, unique: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreatePVPC < ActiveRecord::Migration[7.1] | ||
def change | ||
# rubocop:disable Rails/CreateTableWithTimestamps | ||
create_table :pvpc, id: :time, primary_key: :time do |t| | ||
t.references :zone, null: false, foreign_key: true | ||
t.float :import, null: false | ||
t.float :export, null: false | ||
end | ||
# rubocop:enable Rails/CreateTableWithTimestamps | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateHolidays < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :holidays do |t| | ||
t.timestamps null: false | ||
t.string :name, null: false | ||
t.date :date, null: false | ||
t.index :date, unique: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateEnergyPeriods < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :energy_periods do |t| | ||
t.timestamps null: false | ||
t.references :zone, null: false, foreign_key: true | ||
t.string :day_type, null: false | ||
t.integer :start_hour, null: false | ||
t.integer :end_hour, null: false | ||
t.string :kind, null: false | ||
end | ||
end | ||
end |
Oops, something went wrong.