-
Notifications
You must be signed in to change notification settings - Fork 61
Db check duplicates #656
Db check duplicates #656
Conversation
✅ Deploy Preview for ubiquibot-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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 just updated the specification, but I don't see a mechanism to sync the username. Do you have that here?
Sorry, I thought it will be a new issue. I will update. |
That might have made sense actually. Hopefully it's fine I updated the existing one! |
I added the feature to update user name when ever access to user_id appears. But I don't think this is a firm approach. IMO, we need to remove all the names from database and control all of them using id. So when we need to get username, we can fetch from github api. I think this is reasonable and we can update it further... |
I figured caching the username for reads is useful to save on unnecessary network requests to the GitHub API. Intuitively to me it seems useful to be able to directly refer to the username from the database. But at the same time, perhaps it's a waste of storage space. It would be easier to determine the necessity by checking through all of the existing capabilities and see if any of them rely on knowing the username. This is not feasible for me to handle from my phone. @rndquu rfc |
I took a quick look and we never query username from database. Most of the time all user data is available in the webhook payload. |
Looks like we should get rid of the username entirely then. |
Yes, that must be the solution. |
Yes, caching (i.e. saving to DB) username is useful in case we save on redundant github API calls. But it seems that the username is not used anywhere so the |
let me know when this is ready to go into QA |
I guess it's now ready. |
@ByteBallet Could you resolve the conflicts one more time? @whilefoo @wannacfuture Could you help with the review? |
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.
@ByteBallet Could you provide QA? Just wanted to make sure if its working as normal.
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.
Code looks mostly good. Please post QA.
@@ -24,7 +25,8 @@ export const query = async (body: string) => { | |||
const user = matches?.[1]; |
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.
const user = matches?.[1]; | |
const username = matches?.[1]; |
@@ -24,7 +25,8 @@ export const query = async (body: string) => { | |||
const user = matches?.[1]; | |||
|
|||
if (user) { | |||
const walletInfo = await getWalletInfo(user, id?.toString()); | |||
const { id: user_id } = (await getUser(user)) ?? {}; |
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.
const { id: user_id } = (await getUser(user)) ?? {}; | |
const user = await getUser(user); | |
if (!user) { | |
logger.info(`Error retrieving data about user @${username}`); | |
return `Error retrieving data about user @${username}`; | |
} |
@@ -24,7 +25,8 @@ export const query = async (body: string) => { | |||
const user = matches?.[1]; | |||
|
|||
if (user) { | |||
const walletInfo = await getWalletInfo(user, id?.toString()); | |||
const { id: user_id } = (await getUser(user)) ?? {}; | |||
const walletInfo = await getWalletInfo(user, id?.toString(), user_id || 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.
const walletInfo = await getWalletInfo(user, id?.toString(), user_id || 0); | |
const walletInfo = await getWalletInfo(user, id.toString(), user.id); |
@@ -0,0 +1,27 @@ | |||
ALTER TABLE wallets |
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.
We need a data migration file here as well as the schema migration because we already have tons of data stored in the database. We can never lose them.
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.
Okay, I will have a look.
Thanks
Resolves #574