Skip to content
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

[BACK-43] Dedup hash val #195

Closed
wants to merge 33 commits into from
Closed

[BACK-43] Dedup hash val #195

wants to merge 33 commits into from

Conversation

jh-bate
Copy link
Contributor

@jh-bate jh-bate commented Oct 4, 2023

  • generate platform style dedup hash for migration

NOTE:

@@ -21,6 +21,7 @@ var schema = require('./schema.js');

var idFields = ['type', 'deviceId', 'time'];
schema.registerIdFields('urineKetone', idFields);
schema.registerFieldsForDuplicator('urineKetone');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - I don't think platform handles this data type. If Uploader sends this data type, we'll need to update platform. Please note this in the narrative.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploader does not use urineKetone, only bloodKetone

@@ -21,6 +21,7 @@ var schema = require('./schema.js');

var idFields = ['type', 'time', 'creatorId', 'text', 'deviceId'];
schema.registerIdFields('note', idFields);
schema.registerFieldsForDuplicator('note');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - I don't think platform handles this data type. If Uploader sends this data type, we'll need to update platform. Please note this in the narrative.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploader does not use note, but I think Tidepool Mobile and Blip does? Then again, they're probably both using Platform, right?

"_active": true
"_active": true,
"_deduplicator": {
"name": "org.tidepool.deduplicator.device.deactivate.hash",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to make sure that by using this deduplicator name it isn't going to cause an issue with future uploads via platform. I think just getting this in the narrative for now is good.

@@ -1,8 +1,7624 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should back out any changes to the lock files for this PR and use the other PR updating the actual dependencies to update the lock files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I will merge it in

@@ -3,4203 +3,4205 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should back out any changes to the lock files for this PR and use the other PR updating the actual dependencies to update the lock files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

@@ -0,0 +1,77 @@
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Why is this file called duplicate.js? Perhaps, platform.js or similar to indicate it is the platform deduplicator? That way when it has used it would be platform.registerFieldsForDuplicator which easily shows it is for platform.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, perhaps include "platform" in the exported functions so it is clear that it is for platform deduplication.

}
var idHashFields = idHashFieldMap[datum.type];
if (!idHashFields) {
return '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the caller check for empty string and not write the platform deduplicator hash? We don't want any with empty strings in the database I think.

if (idHashFields[i] === 'time') {
const dateTime = new Date(val);
// NOTE: platform `time` is being returned minus millis so we need to do the same here
val = dateTime.toISOString().split('.')[0] + 'Z';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I didn't know this. And it has the Z timezone at the end?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to convert timezones here?

datum.type === 'cbg'
) {
// NOTE: platform `value` precision is being used so that the hash will be the same
if (val.toString().length > 7) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only want to do this for mg/dL per our platform discussion.

@@ -513,3 +521,7 @@ exports.makeId = function(datum) {

return exports.generateId(datum, idFields);
};

exports.generateHash = duplicate.generateHash;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps include "platform" name in exports so it is clear it is for the platform deduplication.

@jh-bate jh-bate changed the title Dedup hash val [BACK-43] Dedup hash val Oct 11, 2023
@jh-bate
Copy link
Contributor Author

jh-bate commented Nov 30, 2023

/deploy qa3

1 similar comment
@jh-bate
Copy link
Contributor Author

jh-bate commented Nov 30, 2023

/deploy qa3

@tidebot
Copy link
Collaborator

tidebot commented Nov 30, 2023

jh-bate updated values.yaml file in qa3

@tidebot
Copy link
Collaborator

tidebot commented Nov 30, 2023

jh-bate updated flux policies file in qa3

@tidebot
Copy link
Collaborator

tidebot commented Nov 30, 2023

jh-bate deployed jellyfish dedup-hash-val branch to qa3 namespace

@jh-bate
Copy link
Contributor Author

jh-bate commented Dec 1, 2023

/deploy qa3

@tidebot
Copy link
Collaborator

tidebot commented Dec 1, 2023

jh-bate updated values.yaml file in qa3

@tidebot
Copy link
Collaborator

tidebot commented Dec 1, 2023

jh-bate updated flux policies file in qa3

@tidebot
Copy link
Collaborator

tidebot commented Dec 1, 2023

jh-bate deployed jellyfish dedup-hash-val branch to qa3 namespace

@jh-bate jh-bate requested a review from darinkrauss April 9, 2024 05:19
Copy link
Contributor

@darinkrauss darinkrauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple more things that may need to be addressed.

if (idHashFields[i] === 'time') {
const dateTime = new Date(val);
// NOTE: platform `time` is being returned minus millis so we need to do the same here
val = dateTime.toISOString().split('.')[0] + 'Z';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If, for some reason there isn't a ., then it will end up with and extra Z. For example "2011-10-05T14:48:00Z" becomes "2011-10-05T14:48:00ZZ", I think.

) {
// NOTE: platform `value` precision is being used so that the hash will be the same
if (val.toString().length > 7) {
val = convertMgToMmol(val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we aren't actually truncating the value in the datum, but computing it separately just for the hash. I think the current migrator is actually persisting the truncated value in the datum, right? Is that an issue?

@jh-bate
Copy link
Contributor Author

jh-bate commented Sep 17, 2024

superseded by #203

@jh-bate jh-bate closed this Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants