-
Notifications
You must be signed in to change notification settings - Fork 8
Added route and serializer for fetching output curves in bulk #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels a lot cleaner, nice work!
I left a few comments here and there, but they're just some nitpicks
# Returns a single CSV file with specified output curves as columns. | ||
# Query parameter 'curve_types' specifies which curves to include (comma-separated). | ||
def bulk_output_curves | ||
curve_types = params[:curve_types]&.split(',')&.map(&:strip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this with permit
as []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even with a require? That way we can tackle an empty csv automagically before we move into the serializer
def initialize(scenario, curve_types) | ||
@scenario = scenario | ||
@curve_types = curve_types || [] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def initialize(scenario, curve_types) | |
@scenario = scenario | |
@curve_types = curve_types || [] | |
end | |
def initialize(scenario, curve_types = []) | |
@scenario = scenario | |
@curve_types = curve_types | |
end |
end | ||
|
||
max_len = curves.values.map(&:length).max || 0 | ||
require 'csv' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move this one to the top!
@@ -26,6 +26,7 @@ | |||
get :costs_parameters, to: 'export#costs_parameters' | |||
get :sankey, to: 'export#sankey' | |||
get :storage_parameters, to: 'export#storage_parameters' | |||
get :bulk_output_curves, to: 'export#bulk_output_curves' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking the endpoint is already called (output)curves
. Maybe we can rename this to just bulk
or combined
for clarity? What do you think?
Fetching the curves this way speeds up the exports for pyetm by about a minute.
Goes with this pyetm PR