fix: resolve issue #715

Signed-off-by: SoulSniper1212 <warush23@gmail.com>
pull/721/head
SoulSniper1212 3 weeks ago
parent 1d62b88a43
commit 9b141b5338

@ -71,7 +71,7 @@ export default function GoogleAnalytics({ children }: Props) {
return () => {
router.events.off('routeChangeComplete', handleRouteChange);
};
}, [router.events,]);
}, [router.events]);
return (
<GoogleAnalyticsContext.Provider value={{ event }}>

@ -43,7 +43,8 @@ const getYoeRange = (yoeCategory: number | null | undefined) => {
: null; // Internship
};
export const offerAdminRouter = createProtectedRouter().query('list', {
export const offerAdminRouter = createProtectedRouter()
.query('list', {
input: z.object({
companyId: z.string().nullish(),
countryId: z.string().nullish(),
@ -67,9 +68,9 @@ export const offerAdminRouter = createProtectedRouter().query('list', {
const userId = ctx.session.user.id;
const adminAccount = await ctx.prisma.offersAdmin.findFirst({
where: {
userId
}
})
userId,
},
});
if (!adminAccount) {
throw new TRPCError({
@ -477,15 +478,16 @@ export const offerAdminRouter = createProtectedRouter().query('list', {
!yoeRange ? JobType.INTERN : JobType.FULLTIME,
);
},
}).query('isAdmin', {
})
.query('isAdmin', {
async resolve({ ctx }) {
const userId = ctx.session.user.id;
const result = await ctx.prisma.offersAdmin.findFirst({
where: {
userId
}
})
userId,
},
});
return result ? true : false
}
return result ? true : false;
},
});

@ -320,7 +320,6 @@ export const offersCommentsRouter = createRouter()
id: input.profileId,
},
});
} else {
throw new trpc.TRPCError({
code: 'UNAUTHORIZED',

@ -41,12 +41,13 @@ export const questionsQuestionEncounterUserRouter = createProtectedRouter()
});
}
await tx.questionsQuestion.update({
data: {
lastSeenAt: (questionToUpdate.lastSeenAt === null ||
questionToUpdate.lastSeenAt < input.seenAt)
? input.seenAt : undefined,
lastSeenAt:
questionToUpdate.lastSeenAt === null ||
questionToUpdate.lastSeenAt < input.seenAt
? input.seenAt
: undefined,
numEncounters: {
increment: 1,
},

@ -1,8 +1,13 @@
import type { Config } from 'unique-names-generator';
import { adjectives, animals,colors, uniqueNamesGenerator } from 'unique-names-generator';
import {
adjectives,
animals,
colors,
uniqueNamesGenerator,
} from 'unique-names-generator';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient()
const prisma = new PrismaClient();
const customConfig: Config = {
dictionaries: [adjectives, colors, animals],
@ -10,24 +15,23 @@ const customConfig: Config = {
separator: '-',
};
export default async function generateRandomName(): Promise<string> {
let uniqueName: string = uniqueNamesGenerator(customConfig);
let sameNameProfiles = await prisma.offersProfile.findMany({
where: {
profileName: uniqueName
}
})
profileName: uniqueName,
},
});
while (sameNameProfiles.length !== 0) {
uniqueName = uniqueNamesGenerator(customConfig);
sameNameProfiles = await prisma.offersProfile.findMany({
where: {
profileName: uniqueName
}
})
profileName: uniqueName,
},
});
}
return uniqueName
return uniqueName;
}

@ -71,7 +71,7 @@ While you're unlikely to be asked to implement a sorting algorithm from scratch
## Things to look out for during interviews
Make sure you know the time and space complexity of the language's default sorting algorithm! The time complexity is almost definitely O(nlog(n))). Bonus points if you can name the sort. In Python, it's [Timsort](https://en.wikipedia.org/wiki/Timsort). In Java, [an implementation of Timsort](https://github.com/openjdk/jdk/blob/d9052b946682d1c0f2629455d73fe4e6b95b29db/src/java.base/share/classes/java/util/TimSort.java) is used for sorting objects, and [Dual-Pivot Quicksort](https://github.com/openjdk/jdk/blob/d9052b946682d1c0f2629455d73fe4e6b95b29db/src/java.base/share/classes/java/util/DualPivotQuicksort.java) is used for sorting primitives.
Make sure you know the time and space complexity of the language's default sorting algorithm! The time complexity is almost definitely O(n log n). Bonus points if you can name the sort. In Python 3.11+, it's [Powersort](https://www.wild-inter.net/posts/powersort-in-python-3.11), which replaced Timsort as the default sorting algorithm. In Java, [an implementation of Timsort](https://github.com/openjdk/jdk/blob/d9052b946682d1c0f2629455d73fe4e6b95b29db/src/java.base/share/classes/java/util/TimSort.java) is used for sorting objects, and [Dual-Pivot Quicksort](https://github.com/openjdk/jdk/blob/d9052b946682d1c0f2629455d73fe4e6b95b29db/src/java.base/share/classes/java/util/DualPivotQuicksort.java) is used for sorting primitives.
## Corner cases

Loading…
Cancel
Save