-
Notifications
You must be signed in to change notification settings - Fork 12
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
1955 temperature sensor sync for temperature logs and breaches #2152
1955 temperature sensor sync for temperature logs and breaches #2152
Conversation
β¦pe functions from temperature_breach module public so that they can also be used here
It's all compiling up ok but
and I can't figure out why this isn't working when the very similar Obviously it's not ready to merge yet, until I figure this out, so I'll fill in the PR description properly at that point... |
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.
Thanks looks great, one change request though (but approving anyways, i'll be away till next tuesday, so good to get as much as possible in before you go on holiday, btw I would like to work on some things while you away if that's ok, so if you have any carry over things, can you please put in branch)
It's all compiling up ok but cargo test sync_pull is failing (everything else passes):
It's due to this one:
diff --git a/server/service/src/sync/translations/mod.rs b/server/service/src/sync/translations/mod.rs
index e9342531c..a453da43f 100644
--- a/server/service/src/sync/translations/mod.rs
+++ b/server/service/src/sync/translations/mod.rs
@@ -80,6 +80,7 @@ pub(crate) fn all_translators() -> SyncTranslators {
Box::new(sensor::SensorTranslation {}),
Box::new(temperature_log::TemperatureLogTranslation {}),
Box::new(temperature_breach::TemperatureBreachTranslation {}),
+ Box::new(temperature_breach_config::TemperatureBreachConfigTranslation {}),
Box::new(clinician::ClinicianTranslation {}),
Box::new(clinician_store_join::ClinicianStoreJoinTranslation {}),
// Remote-Central (site specific)
diff --git a/server/service/src/sync/translations/temperature_breach_config.rs b/server/service/src/sync/translations/temperature_breach_config.rs
index 0f1830782..a7a850bc3 100644
--- a/server/service/src/sync/translations/temperature_breach_config.rs
+++ b/server/service/src/sync/translations/temperature_breach_config.rs
@@ -43,7 +43,7 @@ pub(crate) struct TemperatureBreachConfigTranslation {}
impl SyncTranslation for TemperatureBreachConfigTranslation {
fn pull_dependencies(&self) -> PullDependency {
PullDependency {
- table: LegacyTableName::TEMPERATURE_BREACH,
+ table: LEGACY_TABLE_NAME,
dependencies: vec![LegacyTableName::STORE],
}
}
with CodeLLDB
in vs code and rust analyzer, you can get this inlay hints, to debug and run tests or main etc, and breakpoints work.
I first tried to remove comment one this one and run the test (through the inlay hint, otherwise you would need --nocapture
flag for cargo to see output of tests). That didn't show that translator was not found, so put breakpoint in translator, nothing hit, so put conditional breakpoint here:
sync_record.record_id == "997812e0c33911eb9757779d39ae2dbd"
nothing hit again, so realised that the records is not even being grabbed from sync_buffer.
This needs improving at some point, it's pretty easy to miss things, will look at improving at some point. I am very surprised that there are no compilation errors, since pub(crate) struct is not actually used anywhere but tests
start_timestamp {DATETIME} NOT NULL, | ||
end_timestamp {DATETIME} NOT NULL, | ||
acknowledged BOOLEAN, | ||
threshold_minimum {DOUBLE} NOT NULL, |
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.
nice! thanks for using the common types {DOUBLE}, {DATETIME} etc.. looks great
CREATE TRIGGER temperature_breach_trigger | ||
AFTER INSERT OR UPDATE OR DELETE ON temperature_breach | ||
FOR EACH ROW EXECUTE PROCEDURE update_changelog(); | ||
|
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.
kind of a personal preference, but can use the following macro in some places, instead of #[cfg] annotation
if cfg!(features = "postgres) {
// this won't be greyed out by ide, and will do compilation check without features being on
}
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.
Done here: bf73a5c
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub enum LegacyTemperatureBreachType { |
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.
btw when all are renamed like this, can use rename_all: https://serde.rs/container-attrs.html#rename_all
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
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.
Done here: bf73a5c
We can do this to let compiler help: diff --git a/server/service/src/sync/translations/mod.rs b/server/service/src/sync/translations/mod.rs
index e9342531c..89f35788c 100644
--- a/server/service/src/sync/translations/mod.rs
+++ b/server/service/src/sync/translations/mod.rs
@@ -81,6 +81,8 @@ pub(crate) fn all_translators() -> SyncTranslators {
Box::new(temperature_log::TemperatureLogTranslation {}),
Box::new(temperature_breach::TemperatureBreachTranslation {}),
Box::new(clinician::ClinicianTranslation {}),
+ // if this is missing there will be compilation error
+ temperature_breach_config::boxed(),
Box::new(clinician_store_join::ClinicianStoreJoinTranslation {}),
// Remote-Central (site specific)
Box::new(name_store_join::NameStoreJoinTranslation {}),
diff --git a/server/service/src/sync/translations/temperature_breach_config.rs b/server/service/src/sync/translations/temperature_breach_config.rs
index 0f1830782..25ac389d2 100644
--- a/server/service/src/sync/translations/temperature_breach_config.rs
+++ b/server/service/src/sync/translations/temperature_breach_config.rs
@@ -39,7 +39,13 @@ pub struct LegacyTemperatureBreachConfigRow {
pub maximum_temperature: f64,
}
-pub(crate) struct TemperatureBreachConfigTranslation {}
+// Needs to be added to all_translators()
+#[deny(dead_code)]
+pub(crate) fn boxed() -> Box<dyn SyncTranslation> {
+ Box::new(TemperatureBreachConfigTranslation {})
+}
+
+pub(super) struct TemperatureBreachConfigTranslation {}
impl SyncTranslation for TemperatureBreachConfigTranslation {
fn pull_dependencies(&self) -> PullDependency {
PullDependency { And the translation trait can be made more usable, the translator needs to implement a method that returns a table name (the translator trait has a default implementation to check that table, this can be overridden, but it means we don't need to do this ones, and also don't have to specify own table in dependency) |
I didn't get as far as I'd hoped but by all means, please carry on and make whatever changes are needed. I'll commit any work in progress.
Thanks - it's obvious now that you've pointed it out! Fixed here: bf73a5c
Thanks for all that too - still haven't used the debugger much so that's helpful advice :-) |
@andreievg I just added the mock data in here as well as I've run out of time and that's quicker than creating a whole new branch for it. Over to you :-) To be exact, I think the plural of "breach" is "breaches", not "breachs" but I'm ok to let that slide as it might just confuse things! |
Thanks @adrianwb, re-tested (with sqlite) with current state of the branch, and merging |
Fixes part of #1955
π©π»βπ» What does this PR do?
Add in sync for
temperature_log
,temperature_breach
andtemperature_breach_config
π§ͺ How has/should this change been tested?
Just the automated tests, like any other sync table
π Any notes for the reviewer?
π Documentation
No user facing changes