perf: Workflows are taking too long to load (#25705)
* perf: workflows are too slow * Refactor eventTypeRepository for improved clarity * Reintroduce ErrorCode and ErrorWithCode imports
This commit is contained in:
@@ -305,7 +305,15 @@ export class EventTypeRepository {
|
||||
) {
|
||||
if (!upId) return [];
|
||||
const lookupTarget = ProfileRepository.getLookupTarget(upId);
|
||||
const profileId = lookupTarget.type === LookupTarget.User ? null : lookupTarget.id;
|
||||
let profileId: number | null = null;
|
||||
if (lookupTarget.type === LookupTarget.Profile) {
|
||||
if ("uid" in lookupTarget && lookupTarget.uid) {
|
||||
const profile = await ProfileRepository.findByUid(lookupTarget.uid);
|
||||
profileId = profile?.id ?? null;
|
||||
} else if ("id" in lookupTarget && lookupTarget.id !== undefined) {
|
||||
profileId = lookupTarget.id;
|
||||
}
|
||||
}
|
||||
const select = {
|
||||
...eventTypeSelect,
|
||||
hashedLink: hashedLinkSelect,
|
||||
|
||||
@@ -140,7 +140,13 @@ export class ProfileRepository {
|
||||
bufferTime: user.bufferTime,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a Universal Profile ID (upId) into a lookup target.
|
||||
* - "usr-{id}" → { type: User, id }
|
||||
* - "prof-{uuid}" → { type: Profile, uid } (no `id`)
|
||||
* - "{numericId}" → { type: Profile, id } (legacy)
|
||||
* For profiles, always check for `uid` first; `id` may be undefined.
|
||||
*/
|
||||
static getLookupTarget(upId: UpId) {
|
||||
if (upId.trim() === "") {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user