Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Db check duplicates #656

Closed

Conversation

kamaalsultan
Copy link
Contributor

Resolves #574

@netlify
Copy link

netlify bot commented Aug 22, 2023

Deploy Preview for ubiquibot-staging ready!

Name Link
🔨 Latest commit d2ae901
🔍 Latest deploy log https://app.netlify.com/sites/ubiquibot-staging/deploys/64e949c216c9c80008f76e61
😎 Deploy Preview https://deploy-preview-656--ubiquibot-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@0x4007 0x4007 left a 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?

@kamaalsultan
Copy link
Contributor Author

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.

@0x4007
Copy link
Member

0x4007 commented Aug 23, 2023

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!

@kamaalsultan
Copy link
Contributor Author

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...

@0x4007
Copy link
Member

0x4007 commented Aug 24, 2023

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

@whilefoo
Copy link
Collaborator

whilefoo commented Aug 24, 2023

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.

package-lock.json Outdated Show resolved Hide resolved
@0x4007
Copy link
Member

0x4007 commented Aug 24, 2023

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.

@kamaalsultan
Copy link
Contributor Author

Looks like we should get rid of the username entirely then.

Yes, that must be the solution.

@rndquu
Copy link
Member

rndquu commented Aug 24, 2023

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

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 user_name field can be deleted because we can get it from a github event context.

@Draeieg
Copy link
Contributor

Draeieg commented Aug 25, 2023

let me know when this is ready to go into QA

@kamaalsultan
Copy link
Contributor Author

kamaalsultan commented Aug 26, 2023

let me know when this is ready to go into QA

I guess it's now ready.

@0x4007 0x4007 added ping and removed ping labels Aug 29, 2023
@ubiquibot ubiquibot bot closed this Sep 5, 2023
@rndquu rndquu reopened this Sep 5, 2023
@rndquu rndquu requested a review from 0xcodercrane as a code owner September 5, 2023 09:53
@rndquu
Copy link
Member

rndquu commented Sep 5, 2023

@ByteBallet Could you resolve the conflicts one more time?

@whilefoo @wannacfuture Could you help with the review?

Copy link
Contributor

@wannacfuture wannacfuture left a 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.

Copy link
Collaborator

@whilefoo whilefoo left a 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];
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
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)) ?? {};
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
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);
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
const walletInfo = await getWalletInfo(user, id?.toString(), user_id || 0);
const walletInfo = await getWalletInfo(user, id.toString(), user.id);

@rndquu rndquu marked this pull request as draft September 6, 2023 14:55
@0xcodercrane 0xcodercrane marked this pull request as ready for review September 12, 2023 09:04
@@ -0,0 +1,27 @@
ALTER TABLE wallets
Copy link
Contributor

@0xcodercrane 0xcodercrane Sep 12, 2023

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.

Copy link
Contributor Author

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

@0x4007 0x4007 closed this Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Github IDs instead of names in DB
7 participants