Skip to content

Commit

Permalink
fix: double quote
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris committed Aug 13, 2023
1 parent acddcce commit 29bb8ab
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions packages/backend/src/dao/kv-dao.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BulkKey, BulkKeyMap } from '@backend/utils/const';
import { z } from 'zod';
import { TRPCError } from '@trpc/server';
import { BulkKey, BulkKeyMap } from "@backend/utils/const";
import { z } from "zod";
import { TRPCError } from "@trpc/server";
import {
PendingRating,
pendingRatingParser,
Expand All @@ -12,13 +12,13 @@ import {
truncatedProfessorParser,
User,
userParser,
} from '@backend/types/schema';
} from "@backend/types/schema";
import {
addRating as addRatingToProfessor,
professorToTruncatedProfessor,
removeRating,
} from '@backend/types/schemaHelpers';
import { KvWrapper } from './kv-wrapper';
} from "@backend/types/schemaHelpers";
import { KvWrapper } from "./kv-wrapper";

const KV_REQUESTS_PER_TRIGGER = 1000;
const THREE_WEEKS_SECONDS = 60 * 60 * 24 * 7 * 3;
Expand All @@ -35,12 +35,12 @@ export class KVDAO {
async getAllProfessors() {
const professorList = await this.polyratingsNamespace.safeGet(
z.array(truncatedProfessorParser),
'all',
"all",
);
if (!professorList.success) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Could not find any professors.',
code: "INTERNAL_SERVER_ERROR",
message: "Could not find any professors.",
});
}

Expand All @@ -50,7 +50,7 @@ export class KVDAO {
private async putAllProfessors(professorList: TruncatedProfessor[]) {
await this.polyratingsNamespace.put(
z.array(truncatedProfessorParser),
'all',
"all",
professorList,
);
}
Expand All @@ -62,13 +62,13 @@ export class KVDAO {
getBulkNamespace(bulkKey: BulkKey): { namespace: KvWrapper; parser: z.ZodTypeAny } {
const namespaceMap: Record<BulkKey, { namespace: KvWrapper; parser: z.ZodTypeAny }> = {
professors: { namespace: this.polyratingsNamespace, parser: professorParser },
'professor-queue': {
"professor-queue": {
namespace: this.professorApprovalQueueNamespace,
parser: professorParser,
},
users: { namespace: this.usersNamespace, parser: userParser },
reports: { namespace: this.reportsNamespace, parser: ratingReportParser },
'rating-log': {
"rating-log": {
namespace: this.ratingsLog,
parser: pendingRatingParser,
},
Expand Down Expand Up @@ -100,7 +100,7 @@ export class KVDAO {
async getBulkValues<T extends BulkKey>(bulkKey: T, keys: string[]): Promise<BulkKeyMap[T]> {
if (keys.length > KV_REQUESTS_PER_TRIGGER) {
throw new TRPCError({
code: 'BAD_REQUEST',
code: "BAD_REQUEST",
message: `Can not process more than ${KV_REQUESTS_PER_TRIGGER} keys per request`,
});
}
Expand All @@ -121,7 +121,7 @@ export class KVDAO {
existingProfessor.firstName !== professor.firstName ||
existingProfessor.lastName !== professor.lastName
) {
throw new Error('Possible professor collision detected');
throw new Error("Possible professor collision detected");
}
}

Expand Down Expand Up @@ -151,7 +151,7 @@ export class KVDAO {
const professorIndex = profList.findIndex((t) => t.id === id);

if (professorIndex === -1) {
throw new Error('Professor entity existed for removal but not in all professor list');
throw new Error("Professor entity existed for removal but not in all professor list");
}

profList.splice(professorIndex, 1);
Expand All @@ -165,8 +165,8 @@ export class KVDAO {
}

async addRating(newRating: PendingRating) {
if (newRating.status !== 'Successful') {
throw new Error('Cannot add rating to KV that has not been analyzed.');
if (newRating.status !== "Successful") {
throw new Error("Cannot add rating to KV that has not been analyzed.");
}

const professor = await this.getProfessor(newRating.professor);
Expand All @@ -190,7 +190,7 @@ export class KVDAO {
const user = await this.usersNamespace.get(userParser, username);
return user;
} catch (e) {
throw new TRPCError({ code: 'UNAUTHORIZED' });
throw new TRPCError({ code: "UNAUTHORIZED" });
}
}

Expand Down

0 comments on commit 29bb8ab

Please sign in to comment.