Skip to content

Commit e51b94d

Browse files
committed
Add vote caching, sorting, ranking, etc to resources
1 parent 2e00946 commit e51b94d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2677
-211
lines changed

apps/nextjs/next.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ const nextConfig = {
153153
type: "webassembly/async",
154154
});
155155

156-
config.externals = config.externals || [];
157-
if (Array.isArray(config.externals)) {
158-
config.externals.push("@node-rs/argon2");
159-
config.externals.push("re2");
160-
} else {
161-
config.externals = ["@node-rs/argon2", "re2"];
162-
}
156+
config.externals = [
157+
...(Array.isArray(config.externals) ? config.externals : []),
158+
"@node-rs/argon2",
159+
"re2",
160+
"keyv",
161+
"metascraper-youtube",
162+
];
163163

164164
// Explicitly mark WASM as external
165165
// config.externals = [
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use client";
2+
3+
import { EditResourceScreen } from "@homefront/app/features/resources/EditResourceScreen";
4+
5+
export default function EditResourcePage() {
6+
return <EditResourceScreen />;
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { FilteredResourcesScreen } from "@homefront/app/features/resources/FilteredResourcesScreen";
2+
3+
export default function SavedResourcesPage() {
4+
return <FilteredResourcesScreen filter="downvoted" />;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { FilteredResourcesScreen } from "@homefront/app/features/resources/FilteredResourcesScreen";
2+
3+
export default function SavedResourcesPage() {
4+
return <FilteredResourcesScreen filter="saved" />;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { FilteredResourcesScreen } from "@homefront/app/features/resources/FilteredResourcesScreen";
2+
3+
export default function SavedResourcesPage() {
4+
return <FilteredResourcesScreen filter="upvoted" />;
5+
}

infra/cron.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path="./.sst/platform/config.d.ts" />
2+
3+
import { databaseUrl } from "./secrets";
4+
5+
export const resourceScoresCron = new sst.aws.Cron("ResourceScores", {
6+
schedule: "rate(5 minutes)",
7+
function: {
8+
handler: "packages/lambdas/src/resources-scores.handler",
9+
environment: {
10+
DATABASE_URL: databaseUrl.value,
11+
},
12+
},
13+
});
14+
15+
export const resourceVotesCron = new sst.aws.Cron("ResourceVotes", {
16+
schedule: "rate(5 minutes)",
17+
function: {
18+
handler: "packages/lambdas/src/resources-votes.handler",
19+
environment: {
20+
DATABASE_URL: databaseUrl.value,
21+
},
22+
},
23+
});

infra/nextjs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NextjsArgs } from "../.sst/platform/src/components/aws";
2+
import { resourceScoresCron, resourceVotesCron } from "./cron";
23
import { redis } from "./redis";
34
import {
45
authChallengeEncryptionKey,
@@ -99,6 +100,10 @@ export const nextjs = new sst.aws.Nextjs("Web", {
99100
cdn,
100101
redis,
101102

103+
// Crons
104+
resourceScoresCron,
105+
resourceVotesCron,
106+
102107
// Secrets
103108
authMiniSessionEncryptionKey,
104109
authChallengeEncryptionKey,

packages/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"h3-js": "^4.1.0",
3232
"lexorank": "^1.0.5",
3333
"nanoid": "^5.0.9",
34+
"normalize-url": "catalog:",
3435
"superjson": "catalog:",
3536
"zod": "catalog:"
3637
},

packages/api/src/root.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { invitesRouter } from "./router/invites";
77
import { mappingRouter } from "./router/mapping";
88
import { occupationsRouter } from "./router/occupations";
99
import { relationshipsRouter } from "./router/relationships";
10+
import { reportsRouter } from "./router/reports";
1011
import { resourcesRouter } from "./router/resources";
1112
import { rolesRouter } from "./router/roles";
1213
import { skillsRouter } from "./router/skills";
@@ -24,6 +25,7 @@ export const appRouter = createTRPCRouter({
2425
mapping: mappingRouter,
2526
occupations: occupationsRouter,
2627
relationships: relationshipsRouter,
28+
reports: reportsRouter,
2729
resources: resourcesRouter,
2830
roles: rolesRouter,
2931
skills: skillsRouter,

packages/api/src/router/domainAreas.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ import type { TRPCRouterRecord } from "@trpc/server";
22
import { sql } from "kysely";
33
import { z } from "zod";
44

5-
import { protectedProcedure } from "../trpc";
5+
import { protectedProcedure, publicProcedure } from "../trpc";
66

77
export const domainAreasRouter = {
8+
getDomainAreas: publicProcedure.query(async ({ ctx }) => {
9+
const domainAreas = await ctx.db
10+
.selectFrom("domainAreas")
11+
.selectAll()
12+
.orderBy("title")
13+
.execute();
14+
15+
return domainAreas;
16+
}),
17+
818
getAllDomainAreas: protectedProcedure.query(async ({ ctx }) => {
919
const userId = ctx.session.user.id;
1020

0 commit comments

Comments
 (0)