SEED-platform / seed

Standard Energy Efficiency Data (SEED) Platform™ is a web-based application that helps organizations easily manage data on the energy performance of large groups of buildings.
Other
110 stars 55 forks source link

Bulk Meter Reading Inserts Can Fail #4253

Open axelstudios opened 1 year ago

axelstudios commented 1 year ago

Expected Behavior Errors should be handled gracefully

Actual Behavior A 500 error occurs if an array of meter readings is sent that contains two or more readings with the same start and end times.

Steps to Reproduce

  1. Insert meter readings with the same start and end times:
POST /api/v3/properties/{property_id}/meters/{meter_id}/readings/
[{
"start_time": "2023-01-01T00:00:00",
"end_time": "2023-02-01T00:00:00",
"reading": 3.41,
"source_unit": "kWh (thousand Watt-hours)",
"conversion_factor": 3.41
}, {
"start_time": "2023-01-01T00:00:00",
"end_time": "2023-02-01T00:00:00",
"reading": 123,
"source_unit": "Wh (Watt-hours)",
"conversion_factor": 0.00341
}]

Additional Context

Error Output:
psycopg2.errors.CardinalityViolation: ON CONFLICT DO UPDATE command cannot affect row a second time
HINT:  Ensure that no rows proposed for insertion within the same command have duplicate constrained values.
github-actions[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity within 60 days. It will be closed if no further activity occurs. Thank you for your contributions.

RDmitchell commented 11 months ago

Seems like this would be a good issue to fix in the Q2 bug fix world, since many users are importing meter data.

haneslinger commented 10 months ago

I see this endpoint implemented but not used. Is that correct?

haneslinger commented 10 months ago

What should happen?

RDmitchell commented 9 months ago

Instance: dev1 SHA: 9c719a96b Org: LBNL 200 Cycle: Meter Import Testing

I imported a file with one property, 2 meters (gas and electric) with the last 2 gas meter entries duplicated, except that the value for the consumption was different between the two, even though the dates were the same. image

I then imported the file just for Meter Data image

As the data was being imported, SEED displayed this screen, which indicated that there were 13 records for Natural Gas, which is correct. image

SEED then produced this screen, which indicated that there were overlapping readings for the Natural Gas meters image

So the program imported the Electric meter data, because it didn't have overlapping readings. But it didn't import the Natural Gas meter data, which DID have overlapping readings. image

Seems like we might need a stronger message to the user, saying that "meter " data won't be imported because of overlapping readings?

perryr16 commented 9 months ago

I'll update the message in the error column of the blue Meter Reading Counts table.

RDmitchell commented 9 months ago

@perryr16 -- thanks !! Let me know when that is deployed to dev1 and I will retest.

RDmitchell commented 8 months ago

@perryr16 / @kflemin -- has the updated message been deployed to dev1 for testing?

RDmitchell commented 8 months ago

@kflemin / @perryr16

This is in 2 different projects, image

But the added message about the natural gas data not being imported has not been implemented, even though one of the projects says Test

Not sure what to do -- if it's ready to deploy, seems like it should be in just one project, maybe the bug fix project, but not both.

kflemin commented 8 months ago

@perryr16, I'm not sure that this error message got reworked...did it?

@RDmitchell, I removed this issue from tech debt since we're tracking it in the Q2 bug fix.

perryr16 commented 8 months ago

@kflemin, no the error message has not been reworked. I'll take care of that

RDmitchell commented 8 months ago

@kflemin -- I moved the status to "In Progress" rather than "Test"

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity within 60 days. It will be closed if no further activity occurs. Thank you for your contributions.