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: add contributors page gf-250 #334

Merged
merged 33 commits into from
Sep 17, 2024
Merged

Conversation

Vitaliistf
Copy link
Collaborator

  • Added contributors item to the sidebar.
  • Added contributors table with all the contributors. It contains Name, Git Emails and Projects columns.
  • Projects - are all projects associated with the contributor through git emails and activity logs

(Branched from #181)

Screenshot 2024-09-16 at 16 58 43

@@ -75,6 +75,22 @@ class ProjectRepository implements Repository {
return item ? ProjectEntity.initialize(item) : null;
}

public async findProjectsByContributorId(
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
public async findProjectsByContributorId(
public async findByContributorId(

contributors.items.map(async (item) => {
const contributor = item.toObject();

const projects = await this.projectService.findProjectsByContributorId(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can join projects inside contributors repository findAll method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I thought that such logic should be through services. You mean that I should remove it completely from projectRepository, and create such method in contributorRepository, or make contributorRepository dependent of projectRepository?

Copy link
Collaborator

@liza-veis liza-veis Sep 16, 2024

Choose a reason for hiding this comment

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

No, I was thinking about calculating it as a custom field somehow inside the query in contributors repository, but looks like it will be complicated

Copy link
Collaborator

Choose a reason for hiding this comment

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

so the problem is that it's not really good to make a separate query for each item. Also, we need to use for of, instead of Promise all, because this may make too many simultaneous db requests, which is bad. And the concern here is that with for of it will work slow

Copy link
Collaborator

@liza-veis liza-veis Sep 16, 2024

Choose a reason for hiding this comment

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

and if there is a possibility to compute or somehow join this inside the contributors query, this would be better, otherwise, we need to use for of here, which can be slow

Copy link
Collaborator Author

@Vitaliistf Vitaliistf Sep 16, 2024

Choose a reason for hiding this comment

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

Oh, alright, I'll try to figure out what we could do with it tomorrow. Resolving a lot of conflicts today got me feeling fried😂

Copy link
Contributor

@what1s1ove what1s1ove left a comment

Choose a reason for hiding this comment

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

lgtm after Lisa's comments

this.contributorRepository = contributorRepository;
this.projectService = projectService;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we no longer need this

Suggested change
this.projectService = projectService;

Comment on lines 52 to 56
.select(
raw(
"COALESCE(ARRAY_AGG(DISTINCT jsonb_build_object('id', git_emails.id, 'email', git_emails.email)) FILTER (WHERE git_emails.id IS NOT NULL), '{}') AS git_emails",
),
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can join git emails the usual way, with relation mapping, because we will probably need this in another place

.execute();

return ContributorEntity.initialize(contributor);
return ContributorEntity.initialize({ ...contributor, projects: [] });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we leave return ContributorEntity.initialize(contributor); ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, now that we have one query for that, we can, I forgot to change it. Thanks!

@liza-veis liza-veis merged commit 35c0e09 into main Sep 17, 2024
6 checks passed
@github-actions github-actions bot mentioned this pull request Sep 17, 2024
@github-actions github-actions bot mentioned this pull request Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

5 participants