-
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
77 changed files
with
900 additions
and
551 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class ApplicationAggregation | ||
def initialize(date, archives) | ||
@date = date | ||
@archives = archives | ||
end | ||
|
||
def run | ||
instance = model.find_or_initialize_by(date: @date) | ||
instance.assign_attributes(aggregations) | ||
instance.save! | ||
end | ||
|
||
private | ||
|
||
def aggregations_columns | ||
%i[max maxtime min mintime sum avg] | ||
end | ||
|
||
def aggregations | ||
aggregations_columns.each_with_object({}) do |column, hash| | ||
hash[column] = send(column) if respond_to?(column) | ||
end | ||
end | ||
|
||
def model | ||
"ArchiveDaily#{self.class.name.demodulize}".constantize | ||
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,31 @@ | ||
class DailyGridEnergyExportAggregation < Base | ||
def max | ||
sum_by_hour.values.max.round(2) | ||
end | ||
|
||
def maxtime | ||
date.to_time.change(hour: sum_by_hour.max_by { |a| a[1] }.first) | ||
end | ||
|
||
def sum | ||
(archives_array.last.grid_energy_export - archives_array.first.grid_energy_export).round(2) | ||
end | ||
|
||
private | ||
|
||
def archives_array | ||
@archives_array ||= archives.to_a | ||
end | ||
|
||
def group_by_hour | ||
@group_by_hour ||= archives_array.group_by do |archive| | ||
archive.created_at.hour | ||
end | ||
end | ||
|
||
def sum_by_hour | ||
@sum_by_hour ||= group_by_hour.transform_values do |archives| | ||
archives.last.grid_energy_export - archives.first.grid_energy_export | ||
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
module Solaris | ||
module PVPCs | ||
module Daily | ||
class ExportPrice < Base | ||
def max | ||
::EnergyPrice.by_date(date).maximum(:export) | ||
end | ||
|
||
def maxtime | ||
::EnergyPrice.by_date(date).where(export: max).first.datetime | ||
end | ||
|
||
def min | ||
::EnergyPrice.by_date(date).minimum(:export) | ||
end | ||
|
||
def mintime | ||
::EnergyPrice.by_date(date).where(export: min).first.datetime | ||
end | ||
|
||
def avg | ||
::EnergyPrice.by_date(date).average(:export).round(4) | ||
end | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
class Cost < ApplicationRecord | ||
belongs_to :country | ||
|
||
validates :start_at, presence: true | ||
validates :transport_toll_p1, presence: true | ||
validates :distribution_toll_p1, presence: true | ||
validates :charges_p1, presence: true | ||
validates :transport_toll_p2, presence: true | ||
validates :distribution_toll_p2, presence: true | ||
validates :charges_p2, presence: true | ||
validates :transport_toll_p3, presence: true | ||
validates :distribution_toll_p3, presence: true | ||
validates :charges_p3, presence: true | ||
|
||
def self.for_time(time) | ||
where('start_at <= ?', time).order(start_at: :desc).first | ||
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,2 @@ | ||
class DailyEnergyExportPrice < ApplicationRecord | ||
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,2 @@ | ||
class DailyEnergyImportPrice < ApplicationRecord | ||
end |
Oops, something went wrong.