Skip to content

Conversation

@Ebioro
Copy link
Contributor

@Ebioro Ebioro commented Mar 16, 2020

adding hash to the subscription object to avoid duplications in mongo

Copy link
Collaborator

@orbitlens orbitlens left a comment

Choose a reason for hiding this comment

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

First of all, good job! Thanks for contributing!
What do you think about replacing a generic subscription id with the hash you generate? It makes sense from the perspective of subscription uniqueness and a hash itself is more meaningful than auto-generated ids.

Most dbs do support binary primary keys, and for those rare cases when it is not supported directly, we can use a stringified representation in a storage plugin.

HISTORY.MD Outdated
@@ -1,3 +1,7 @@
0.4.2 /2020-03-15
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
0.4.2 /2020-03-15
0.4.3 /2020-03-15

And please bump version in package.json

.then(() => {
// Create hash in the subscription to avoid duplication

let hashData = `${subscriptionParams.account} ${subscriptionParams.asset_type} ${subscriptionParams.asset_code} ${subscriptionParams.asset_issuer}`
Copy link
Collaborator

@orbitlens orbitlens Mar 17, 2020

Choose a reason for hiding this comment

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

Please check all meaningful subscription params here:

createSubscription(subscriptionParams, user) {

We can use account, memo, operation_types, asset_code, asset_issuer, expires, and reaction_url. Maybe it makes sense to do something like JSON.stringify(subscriptionParams) to transparently handle all future parameters changes. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are welcome!

  • Adding the relevant parameters for the hash --> will do

  • having the hash as the generic_id --> I am in favor of it. However, I think that we need to be able to deal with older versions that will GET and DELETE based on the old id's. How do we deal with that? Finally, the DELETE endpoint does not DELETE the subscription from mongo, I could not find the code for it. Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a bit more of research and found that Mongo uses 24 character hex string for its _id. The hash generated is a 32 character hex string. No idea how to use the has as the generic id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And about the delete endpoint I saw that the deleted subscriptions have a status of 1 👍

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.

2 participants