-
Notifications
You must be signed in to change notification settings - Fork 0
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
DSR GET Method - Filter by Column #133
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.
Overall really good, but there are a couple of small details that need changing. Specifically that we need to use the field name and not the alias in the query because spaces in urls are not good. I tied myself in knots trying to work out the parts of the code that need to change, so I ended up just making the changes myself. I'll push them.
Let me know if you're ok with my changes and I'll approve and merge it.
datahub/main.py
Outdated
@@ -155,7 +155,9 @@ def upload_dsr(file: UploadFile) -> dict[str, str | None]: | |||
|
|||
|
|||
@app.get("/dsr", response_class=ORJSONResponse) | |||
def get_dsr_data(start: int = 0, end: int | None = None) -> ORJSONResponse: | |||
def get_dsr_data( | |||
start: int = len(dt.dsr_data) - 1, end: int | None = None, col: str | None = None |
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.
The default value of start
won't update with dt.dsr_data
, if will just get the value from the first time it is defined. Luckily, we can just use -1
(it has probably worked so far because the length would be 0 to begin with).
start: int = len(dt.dsr_data) - 1, end: int | None = None, col: str | None = None | |
start: int = -1, end: int | None = None, col: str | None = None |
Yep, all looks good to me. Happy to get this merged. |
e8eea76
to
f6dafe2
Compare
Added functionality for filtering by column when making a GET request for DSR data. Columns can be specified with a query parameter with multiple values being separated by comma. E.g.
/dsr?col=activity types,kwh cost
Default behaviour of index filtering has also been modified. By default, the DSR GET method now only exports the most recent value in the DSR data array. This can be changed with the
start
andend
query parameters.Closes #131
Opened in draft as tests need to be updated.