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: fix quality criteria issues gf-557 #561

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
* gitEmailId:
* type: number
* minimum: 1
* ptojectId :
* projectId :
* type: number
* minimum: 1
* createdAt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ActivityLogRepository implements Repository {
builder.select("id", "name", "hiddenAt");
})
.whereNull("gitEmail:contributor.hiddenAt")
.whereBetween("activity_logs.date", [startDate, endDate])
.whereBetween("activityLogs.date", [startDate, endDate])
.orderBy("date");

if (contributorName) {
Expand All @@ -69,9 +69,9 @@ class ActivityLogRepository implements Repository {
permittedProjectIds && permittedProjectIds.length !== EMPTY_LENGTH;

if (projectId) {
query.where("project_id", projectId);
query.where("projectId", projectId);
} else if (hasPermissionedProjects) {
query.whereIn("project_id", permittedProjectIds);
query.whereIn("projectId", permittedProjectIds);
}

const activityLogs = await query.orderBy("date");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class ContributorController extends BaseController {
* 404:
* description: Contributor not found
* 409:
* description: Attept to self-merge or merging failed
* description: Attempt to self-merge or merging failed
*/
private async merge(
options: APIHandlerOptions<{
Expand Down
26 changes: 9 additions & 17 deletions apps/backend/src/modules/contributors/contributor.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class ContributorRepository implements Repository {
"MAX(CASE WHEN activity_logs.commits_number > 0 THEN activity_logs.date ELSE NULL END) AS last_activity_date",
),
)
.leftJoin("git_emails", "contributors.id", "git_emails.contributor_id")
.leftJoin("activity_logs", "git_emails.id", "activity_logs.git_email_id")
.leftJoin("projects", "activity_logs.project_id", "projects.id")
.leftJoin("gitEmails", "contributors.id", "gitEmails.contributorId")
.leftJoin("activityLogs", "gitEmails.id", "activityLogs.gitEmailId")
.leftJoin("projects", "activityLogs.projectId", "projects.id")
.groupBy("contributors.id")
.withGraphFetched("gitEmails");

Expand Down Expand Up @@ -174,13 +174,9 @@ class ContributorRepository implements Repository {
"COALESCE(ARRAY_AGG(DISTINCT jsonb_build_object('id', projects.id, 'name', projects.name)) FILTER (WHERE projects.id IS NOT NULL), '{}') AS projects",
),
)
.leftJoin("git_emails", "contributors.id", "git_emails.contributor_id")
.leftJoin(
"activity_logs",
"git_emails.id",
"activity_logs.git_email_id",
)
.leftJoin("projects", "activity_logs.project_id", "projects.id")
.leftJoin("gitEmails", "contributors.id", "gitEmails.contributorId")
.leftJoin("activityLogs", "gitEmails.id", "activityLogs.gitEmailId")
.leftJoin("projects", "activityLogs.projectId", "projects.id")
.groupBy("contributors.id")
.withGraphFetched("gitEmails")
.modifyGraph("gitEmails", (builder) => {
Expand Down Expand Up @@ -233,13 +229,9 @@ class ContributorRepository implements Repository {
"COALESCE(ARRAY_AGG(DISTINCT jsonb_build_object('id', projects.id, 'name', projects.name)) FILTER (WHERE projects.id IS NOT NULL), '{}') AS projects",
),
)
.leftJoin("git_emails", "contributors.id", "git_emails.contributor_id")
.leftJoin(
"activity_logs",
"git_emails.id",
"activity_logs.git_email_id",
)
.leftJoin("projects", "activity_logs.project_id", "projects.id")
.leftJoin("gitEmails", "contributors.id", "gitEmails.contributorId")
.leftJoin("activityLogs", "gitEmails.id", "activityLogs.gitEmailId")
.leftJoin("projects", "activityLogs.projectId", "projects.id")
.groupBy("contributors.id")
.withGraphFetched("gitEmails")
.modifyGraph("gitEmails", (builder) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class NotificationRepository implements Repository {
const { results, total } = await this.notificationModel
.query()
.where("receiverUserId", userId)
.orderBy("created_at", SortType.DESCENDING)
.orderBy("createdAt", SortType.DESCENDING)
.page(page, pageSize)
.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ProjectApiKeyRepository implements Repository {
const deletedRowsCount = await this.projectApiKeyModel
.query()
.delete()
.where("project_id", projectId)
.where("projectId", projectId)
.execute();

return Boolean(deletedRowsCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ class ProjectApiKeyService implements Service {
public async findByProjectId(
projectId: number,
): Promise<null | ProjectApiKeyCreateResponseDto> {
const apiKeyEnitity =
const apiKeyEntity =
await this.projectApiKeyRepository.findByProjectId(projectId);

if (!apiKeyEnitity) {
if (!apiKeyEntity) {
return null;
}

const apiKey = apiKeyEnitity.toObject();
const apiKey = apiKeyEntity.toObject();
const decryptedApiKey = this.encryption.decrypt(apiKey.encryptedKey);

return {
Expand Down
12 changes: 6 additions & 6 deletions apps/backend/src/modules/projects/project.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class ProjectRepository implements Repository {
.query()
.select(
"projects.*",
"activity_logs.date as analyticsLastSyncedAt",
"activityLogs.date as analyticsLastSyncedAt",
"users.name as analyticsLastSyncedByUser",
)
.from("projects")
.leftJoin("activity_logs", "projects.id", "activity_logs.projectId")
.leftJoin("users", "activity_logs.createdByUserId", "users.id")
.leftJoin("activityLogs", "projects.id", "activityLogs.projectId")
.leftJoin("users", "activityLogs.createdByUserId", "users.id")
.where("projects.id", id)
.orderBy("activity_logs.date", SortType.DESCENDING)
.orderBy("activityLogs.date", SortType.DESCENDING)
.first();

return item ? ProjectEntity.initialize(item) : null;
Expand All @@ -72,7 +72,7 @@ class ProjectRepository implements Repository {
> {
const query = this.projectModel
.query()
.orderBy("created_at", SortType.DESCENDING);
.orderBy("createdAt", SortType.DESCENDING);

if (name) {
query.whereILike("name", `%${name}%`);
Expand Down Expand Up @@ -102,7 +102,7 @@ class ProjectRepository implements Repository {
}

const projects = await query
.orderBy("created_at", SortType.DESCENDING)
.orderBy("createdAt", SortType.DESCENDING)
.execute();

return projects.map((project) => ProjectEntity.initialize(project));
Expand Down
20 changes: 10 additions & 10 deletions apps/backend/src/modules/users/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ class UserRepository implements Repository {
"[groups.permissions, projectGroups.[permissions, projects]]",
)
.modifyGraph("groups", (builder) => {
builder.select("user_groups.id", "name");
builder.select("userGroups.id", "name");
})
.modifyGraph("groups.permissions", (builder) => {
builder.select("permissions.id", "name", "key");
})
.modifyGraph("projectGroups", (builder) => {
builder.select("project_groups.id", "name");
builder.select("projectGroups.id", "name");
})
.modifyGraph("projectGroups.projects", (builder) => {
builder.select("projects.id");
})
.modifyGraph("projectGroups.permissions", (builder) => {
builder.select("project_permissions.id", "name", "key");
builder.select("projectPermissions.id", "name", "key");
})
.execute();

Expand Down Expand Up @@ -111,12 +111,12 @@ class UserRepository implements Repository {
.relatedQuery("projectGroups")
.joinRelated("permissions")
.join(
"projects_to_project_groups",
"project_groups.id",
"projects_to_project_groups.project_group_id",
"projectsToProjectGroups",
"projectGroups.id",
"projectsToProjectGroups.projectGroupId",
)
.whereIn("permissions.key", permissionKeys)
.where("projects_to_project_groups.project_id", projectId),
.where("projectsToProjectGroups.projectId", projectId),
)
.whereNull("deletedAt")
.execute();
Expand Down Expand Up @@ -157,19 +157,19 @@ class UserRepository implements Repository {
"[groups.permissions, projectGroups.[permissions, projects]]",
)
.modifyGraph("groups", (builder) => {
builder.select("user_groups.id", "name");
builder.select("userGroups.id", "name");
})
.modifyGraph("groups.permissions", (builder) => {
builder.select("permissions.id", "name", "key");
})
.modifyGraph("projectGroups", (builder) => {
builder.select("project_groups.id", "name");
builder.select("projectGroups.id", "name");
})
.modifyGraph("projectGroups.projects", (builder) => {
builder.select("projects.id");
})
.modifyGraph("projectGroups.permissions", (builder) => {
builder.select("project_permissions.id", "name", "key");
builder.select("projectPermissions.id", "name", "key");
});

if (!hasDeleted) {
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/clipboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions apps/frontend/src/assets/images/icons/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/ellipsis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/frontend/src/assets/images/icons/left-double-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/merge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/notifications.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/pencil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/frontend/src/assets/images/icons/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/frontend/src/assets/images/icons/split.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading