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

feat: project & rounds related repositories w/kysely #7

Merged
merged 4 commits into from
Oct 11, 2024

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Oct 10, 2024

🤖 Linear

Closes GIT-90 GIT-91

Description

  • repositories package
  • Project and Rounds repositories using Kysely Query Builder

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

Just some minor/typing comments.

One question re: PG tables just to get a better context of the project: who's going to create the tables (ie executing CREATE TABLE clause) in the DB? A third party tool or this repo?

"test:cov": "vitest run --config vitest.config.ts --coverage"
},
"dependencies": {
"@grants-stack-indexer/shared": "workspace:0.0.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to use fixed versions for local packages or should we use *?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aaa good q, idk

cc @0xkenj1 @jahabeebs thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

lets use * for development phase, to avoid assuming that we are managing versions on the monorepo

Comment on lines 61 to 66
/* @inheritdoc */
async getRoundByRole(
chainId: ChainId,
roleName: "admin" | "manager",
roleValue: string,
): Promise<Round | undefined> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • I'm not able to find this method in the IRoundRepository interface. Might be missing in the interface?
  • Probably want to use the newly defined RoundRoleNames for typing roleName?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks good catch

};

export type NewRoundRole = RoundRole;
export type PartialRoundRole = Partial<RoundRole>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to be used in the future? I think it's not being used anywhere at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's used in the updateRound function, for Kysely this types are complaint with their customs Selectable, Updatable, etc, types but in case you wanted to use a different ORM, probably we'll need a mapping from model to ORM entity

Comment on lines +68 to +74
export type PendingRoundRole = {
id?: number;
chainId: ChainId;
role: string;
address: Address;
createdAtBlock: bigint;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be something like the following? Or it'd introduce too much coupling?

Suggested change
export type PendingRoundRole = {
id?: number;
chainId: ChainId;
role: string;
address: Address;
createdAtBlock: bigint;
};
export type PendingRoundRole = { id?: number } & Omit<RoundRole, "roundId">;

If role should be typed as RoundRoleNames in both types, this would have saved you from having a role: string in one place and role: RoundRoleNames in the other.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

regarding schema typing, we're just copy-pasting their definitions since we don't want to introduce any modifications (in the first place), but your suggestion makes sense

Copy link
Collaborator

Choose a reason for hiding this comment

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

this suggestion makes lot of sense , but since they are different tables, i would keep it as it is to about coupling them

@0xnigir1
Copy link
Collaborator Author

Just some minor/typing comments.

One question re: PG tables just to get a better context of the project: who's going to create the tables (ie executing CREATE TABLE clause) in the DB? A third party tool or this repo?

it will be in another PR, we will improve their current migration mechanism
but i already leave a Question:

  • should migrations file be in the package or goes in the app?

cc @0xyaco @0xkenj1 @jahabeebs

0xyaco
0xyaco previously approved these changes Oct 11, 2024
Copy link
Collaborator

@0xkenj1 0xkenj1 left a comment

Choose a reason for hiding this comment

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

Amazing job, LGTM!! 💎

Just a small thing let's keep in mind that many other repositories will be introduced in the future, so the current directory structure may become a bit messy. I would suggest making a slight change, such as:

repositories/kysely/{ chaindata | pricing | metadata | whatever }/...

Comment on lines +68 to +74
export type PendingRoundRole = {
id?: number;
chainId: ChainId;
role: string;
address: Address;
createdAtBlock: bigint;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

this suggestion makes lot of sense , but since they are different tables, i would keep it as it is to about coupling them

Comment on lines +38 to +41
// In Allo V2 profile roles are emitted before a profile exists.
// The role emitted is the profile id.
// Once a profile is created we search for roles with that profile id
// and add real project roles. After that we can remove the pending project roles.
Copy link
Collaborator

Choose a reason for hiding this comment

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

💎

@0xnigir1 0xnigir1 merged commit de296b6 into dev Oct 11, 2024
6 checks passed
@0xnigir1 0xnigir1 deleted the feat/chain-data-repository branch October 11, 2024 15:45
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