refactor: rename repository files to include Repository suffix (#22717)
* refactor: rename repository files to include Repository suffix - Rename attribute.ts -> attributeRepository.ts - Rename attributeOption.ts -> attributeOptionRepository.ts - Rename attributeToUser.ts -> attributeToUserRepository.ts - Update all import statements throughout codebase Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * refactor: rename repository files and classes with Prisma prefix - Rename attribute.ts -> PrismaAttributeRepository.ts - Rename attributeOption.ts -> PrismaAttributeOptionRepository.ts - Rename attributeToUser.ts -> PrismaAttributeToUserRepository.ts - Update class names to PrismaAttributeRepository, PrismaAttributeOptionRepository, PrismaAttributeToUserRepository - Update all import statements and references throughout codebase Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * fix: update missed AttributeRepository import to PrismaAttributeRepository in teams members page Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
This commit is contained in:
co-authored by
eunjae@cal.com <hey@eunjae.dev>
eunjae@cal.com <hey@eunjae.dev>
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Anik Dhabal Babu
parent
babd514c64
commit
4489cb8fde
+2
-2
@@ -4,7 +4,7 @@ import { unstable_cache } from "next/cache";
|
||||
|
||||
import { RoleManagementFactory } from "@calcom/features/pbac/services/role-management.factory";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { AttributeRepository } from "@calcom/lib/server/repository/attribute";
|
||||
import { PrismaAttributeRepository } from "@calcom/lib/server/repository/PrismaAttributeRepository";
|
||||
import { viewerTeamsRouter } from "@calcom/trpc/server/routers/viewer/teams/_router";
|
||||
|
||||
import { TeamMembersView } from "~/teams/team-members-view";
|
||||
@@ -37,7 +37,7 @@ const getCachedTeamAttributes = unstable_cache(
|
||||
async (organizationId?: number) => {
|
||||
if (!organizationId) return [];
|
||||
try {
|
||||
return await AttributeRepository.findAllByOrgIdWithOptions({ orgId: organizationId });
|
||||
return await PrismaAttributeRepository.findAllByOrgIdWithOptions({ orgId: organizationId });
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ import { _generateMetadata } from "app/_utils";
|
||||
import { unstable_cache } from "next/cache";
|
||||
|
||||
import { RoleManagementFactory } from "@calcom/features/pbac/services/role-management.factory";
|
||||
import { AttributeRepository } from "@calcom/lib/server/repository/attribute";
|
||||
import { PrismaAttributeRepository } from "@calcom/lib/server/repository/PrismaAttributeRepository";
|
||||
import { viewerOrganizationsRouter } from "@calcom/trpc/server/routers/viewer/organizations/_router";
|
||||
|
||||
import { MembersView } from "~/members/members-view";
|
||||
@@ -19,7 +19,7 @@ export const generateMetadata = async () =>
|
||||
|
||||
const getCachedAttributes = unstable_cache(
|
||||
async (orgId: number) => {
|
||||
return await AttributeRepository.findAllByOrgIdWithOptions({ orgId });
|
||||
return await PrismaAttributeRepository.findAllByOrgIdWithOptions({ orgId });
|
||||
},
|
||||
undefined,
|
||||
{ revalidate: 3600, tags: ["viewer.attributes.list"] } // Cache for 1 hour
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import type { Prisma } from "@prisma/client";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
export class AttributeOptionRepository {
|
||||
export class PrismaAttributeOptionRepository {
|
||||
static async findMany({ orgId }: { orgId: number }) {
|
||||
return prisma.attributeOption.findMany({
|
||||
where: {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
export class AttributeRepository {
|
||||
export class PrismaAttributeRepository {
|
||||
static async findManyByNamesAndOrgIdIncludeOptions({
|
||||
attributeNames,
|
||||
orgId,
|
||||
+1
-1
@@ -2,7 +2,7 @@ import type { Prisma } from "@prisma/client";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
export class AttributeToUserRepository {
|
||||
export class PrismaAttributeToUserRepository {
|
||||
static async createManySkipDuplicates(data: Prisma.AttributeToUserCreateManyInput[]) {
|
||||
return await prisma.attributeToUser.createMany({ data, skipDuplicates: true });
|
||||
}
|
||||
@@ -2,8 +2,8 @@ import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import { AttributeRepository } from "../../../server/repository/attribute";
|
||||
import { AttributeOptionRepository } from "../../../server/repository/attributeOption";
|
||||
import { PrismaAttributeOptionRepository } from "../../../server/repository/PrismaAttributeOptionRepository";
|
||||
import { PrismaAttributeRepository } from "../../../server/repository/PrismaAttributeRepository";
|
||||
import { MembershipRepository } from "../../../server/repository/membership";
|
||||
import type { AttributeId, AttributeName, BulkAttributeAssigner, AttributeOptionAssignment } from "../types";
|
||||
import {
|
||||
@@ -37,7 +37,7 @@ const findAttributesByName = async ({
|
||||
orgId: number;
|
||||
attributeNames: AttributeName[];
|
||||
}) => {
|
||||
const attributesFromDb = await AttributeRepository.findManyByNamesAndOrgIdIncludeOptions({
|
||||
const attributesFromDb = await PrismaAttributeRepository.findManyByNamesAndOrgIdIncludeOptions({
|
||||
attributeNames,
|
||||
orgId,
|
||||
});
|
||||
@@ -325,13 +325,13 @@ const createMissingOptionsAndReturnAlongWithExisting = async <
|
||||
),
|
||||
});
|
||||
|
||||
await AttributeOptionRepository.createMany({
|
||||
await PrismaAttributeOptionRepository.createMany({
|
||||
createManyInput: attributeOptionCreateManyInput,
|
||||
});
|
||||
|
||||
// We need fetch all the attribute options to ensure that we have the newly created options as well.
|
||||
const allAttributeOptions = (
|
||||
await AttributeOptionRepository.findMany({
|
||||
await PrismaAttributeOptionRepository.findMany({
|
||||
orgId,
|
||||
})
|
||||
).map((attributeOption) => ({
|
||||
|
||||
@@ -5,8 +5,8 @@ import prisma from "@calcom/prisma";
|
||||
import type { AttributeToUser } from "@calcom/prisma/client";
|
||||
import type { AttributeType } from "@calcom/prisma/enums";
|
||||
|
||||
import { AttributeRepository } from "../../../server/repository/attribute";
|
||||
import { AttributeToUserRepository } from "../../../server/repository/attributeToUser";
|
||||
import { PrismaAttributeRepository } from "../../../server/repository/PrismaAttributeRepository";
|
||||
import { PrismaAttributeToUserRepository } from "../../../server/repository/PrismaAttributeToUserRepository";
|
||||
import { MembershipRepository } from "../../../server/repository/membership";
|
||||
import type { AttributeId } from "../types";
|
||||
|
||||
@@ -218,13 +218,13 @@ async function _getOrgMembershipToUserIdForTeam({ orgId, teamId }: { orgId: numb
|
||||
async function _queryAllData({ orgId, teamId }: { orgId: number; teamId: number }) {
|
||||
const [orgMembershipToUserIdForTeamMembers, attributesOfTheOrg] = await Promise.all([
|
||||
_getOrgMembershipToUserIdForTeam({ orgId, teamId }),
|
||||
AttributeRepository.findManyByOrgId({ orgId }),
|
||||
PrismaAttributeRepository.findManyByOrgId({ orgId }),
|
||||
]);
|
||||
|
||||
const orgMembershipIds = Array.from(orgMembershipToUserIdForTeamMembers.keys());
|
||||
|
||||
// Get all the attributes assigned to the members of the team
|
||||
const attributesToUsersForTeam = await AttributeToUserRepository.findManyByOrgMembershipIds({
|
||||
const attributesToUsersForTeam = await PrismaAttributeToUserRepository.findManyByOrgMembershipIds({
|
||||
orgMembershipIds,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AttributeToUserRepository } from "../../../server/repository/attributeToUser";
|
||||
import { PrismaAttributeToUserRepository } from "../../../server/repository/PrismaAttributeToUserRepository";
|
||||
|
||||
export const getWhereClauseForAttributeOptionsManagedByCalcom = () => {
|
||||
// Neither created nor updated by DSync
|
||||
@@ -10,7 +10,7 @@ export const getWhereClauseForAttributeOptionsManagedByCalcom = () => {
|
||||
};
|
||||
|
||||
export const findAssignmentsForMember = async ({ memberId }: { memberId: number }) => {
|
||||
const assignments = await AttributeToUserRepository.findManyIncludeAttribute({ memberId });
|
||||
const assignments = await PrismaAttributeToUserRepository.findManyIncludeAttribute({ memberId });
|
||||
return assignments.map((assignment) => ({
|
||||
...assignment,
|
||||
attributeOption: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AttributeRepository } from "@calcom/lib/server/repository/attribute";
|
||||
import { PrismaAttributeRepository } from "@calcom/lib/server/repository/PrismaAttributeRepository";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
@@ -20,7 +20,7 @@ const listHandler = async (opts: GetOptions) => {
|
||||
});
|
||||
}
|
||||
|
||||
return await AttributeRepository.findAllByOrgIdWithOptions({ orgId: org.id });
|
||||
return await PrismaAttributeRepository.findAllByOrgIdWithOptions({ orgId: org.id });
|
||||
};
|
||||
|
||||
export default listHandler;
|
||||
|
||||
Reference in New Issue
Block a user