-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix temperature breach filter #2589
Conversation
@@ -177,6 +177,7 @@ const Chart = ({ | |||
borderStyle: 'solid', | |||
borderColor: theme.palette.gray.light, | |||
padding: 3, | |||
textAlign: 'left', |
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.
Bundle size differenceComparing this PR to
|
@@ -92,6 +90,9 @@ impl<'a> TemperatureLogRepository<'a> { | |||
query = query.order(temperature_log_dsl::datetime.desc()) | |||
} | |||
|
|||
// Debug diesel query |
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.
just to help with debugging π€·
@@ -109,7 +109,7 @@ fn validate_sensor(sensor: &Sensor) -> Result<(), String> { | |||
} | |||
match sensor.log_delay { | |||
Some(log_delay) => { | |||
if log_delay < 1 { | |||
if log_delay < 0 { |
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 'add a debug sensor' function creates a record with 0
here, which meant that the sensor mutation fails for all sensors. since positive number is 0 and up, I figured changing this test still fits the intention
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 think technically positive number are greater then zero.
Ohh, what is the add a debug sensor function btw ?
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.
in the cold chain app - under developer settings you can add a sensor, and then add random logs for it.
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 haven't tested, but I can't see the difference between the queries, also there is a comment about the breach filter.
The reason I can't see the difference, is there is a referencial contraint on logs, can't set temperature_breach_id, unless the breach exists, so I can't quite see what the difference is between the new filter and the old.
Btw does cold chain app push temperature_logs first or breaches first ? If it's the former then we might have an issue with referencial contraints.
Unforntunately I don't have the cold chain app set up, I wonder if we can share sqlite filter for it, or if there are some postman queries we can use to replicate/validate ?
@@ -42,7 +41,7 @@ pub struct TemperatureLogFilterInput { | |||
pub id: Option<EqualFilterStringInput>, | |||
pub sensor: Option<SensorFilterInput>, | |||
pub location: Option<LocationFilterInput>, | |||
pub temperature_breach: Option<TemperatureBreachFilterInput>, | |||
pub temperature_breach_id: Option<EqualFilterStringInput>, |
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.
There was/is a good reason to use this filter.
- We can re-use existing repository functionality
- Can filter temperature logs by all of the existing breach filter inputs (type of breach, acknowledge/unacknowledged etc..)
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 think the breach type filter might be broken with this change ?
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.
yes it does. I searched for any usages of the existing breach filter but didn't spot that..
TemperatureBreachFilter::new().id(EqualFilter::equal_to(&id)), | ||
), | ||
), | ||
Some(TemperatureLogFilter::new().temperature_breach_id(EqualFilter::equal_to(&id))), |
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 forgot, why do we need to check that there are logs for the breach ?
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.
that would be the simplest solution. we just remove the check.
The problem is that the breach doesn't record temperature and we were asked to show 'last temperature reading' in the notification. To do this, it's looking up the log - if the breach exists and the log doesn't then that display breaks. Easy enough to skip that data element - but we do then have strange data, with a breach that has no associated log.
Thanks Andrei for review. To remove any UI strangeness I've added a check in the notification component - if there's no min/max temperature then it just doesn't show. The temperature is also blank in the breach table. |
Oh, and I'm using postgres, so don't have a sqlite file to share. You can use this postman collection to add a breach or log. I've been using CCA with some sensors that I'm shuttling in and out of the fridge to get it to breach which is a bit of a pain, but it did pick up this particular error that I'd missed earlier. |
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.
Looks good, thanks for changes @mark-prins.
Fixes #2537
π©π»βπ» What does this PR do?
Could not repro the stated issue. A related issue was raised in conversation - that the breaches aren't showing.
That's the part which I've addressed here - it turns out that the breach filter was a little over complicated and didn't function as required. The filter was looking for
temperature_breach
records.. the query waswhich will not work for new breaches, the breach has to be added before the breach can be added!
I've changed the filter to look for an
id
only, which simplifies things and allows breaches to be added.π§ͺ How has/should this change been tested?
Configure a CCA with a sensor and sync with omSupply. get the sensor into a breach and check if the breach shows in oms.
π Any notes for the reviewer?
π Documentation
No user facing changes