Skip to content

Commit

Permalink
revert multiple commits
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomKnight287 committed Mar 8, 2024
1 parent 37118df commit 48be339
Show file tree
Hide file tree
Showing 18 changed files with 849 additions and 2,844 deletions.
4 changes: 2 additions & 2 deletions apps/web/app/solutions/[id]/page.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Button } from "@/components/ui/button";
import { languages } from "@/constants/languages";
import { File } from "@repo/db/types";
import {Editor as MonacoEditor} from "@repo/monaco/exports";
import MonacoEditor from "@repo/monaco";
import { useState } from "react";

function SolutionFiles({ files }: { files: File[] }) {
Expand All @@ -22,7 +22,7 @@ function SolutionFiles({ files }: { files: File[] }) {
))}
</div>
<MonacoEditor
key={activeFile}
activeFile={activeFile}
options={{ readOnly: true }}
value={
files.find((file, index) => `${file.name}-${index}` === activeFile)
Expand Down
1 change: 0 additions & 1 deletion apps/web/app/solutions/loading.ts

This file was deleted.

82 changes: 0 additions & 82 deletions apps/web/app/solutions/page.client.tsx

This file was deleted.

110 changes: 0 additions & 110 deletions apps/web/app/solutions/page.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Label } from "@/components/ui/label";
import { ChallengeFilesStructure } from "@repo/challenges/src";
import { useRef, useState } from "react";
import TextareaAutosize from "react-textarea-autosize";
import {Editor as MonacoEditor} from "@repo/monaco/exports";
import MonacoEditor from "@repo/monaco";
import { languages } from "@/constants/languages";
import { cn } from "@repo/utils";
import { useParams } from "next/navigation";
Expand Down Expand Up @@ -165,7 +165,7 @@ function CreateSolutionPage({
})}
</div>
<MonacoEditor
key={activeFile}
activeFile={activeFile}
theme="vs-dark"
height={"80vh"}
language={
Expand Down
15 changes: 0 additions & 15 deletions apps/web/cache/challenge.ts

This file was deleted.

106 changes: 35 additions & 71 deletions apps/web/cache/solutions.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,45 @@
import {prisma} from "@repo/db";
import {memoize} from "nextjs-better-unstable-cache";
import { prisma } from "@repo/db";
import { memoize } from "nextjs-better-unstable-cache";

export const getCachedSolutionsPosted = memoize(
async (username: string) =>
await prisma.solution.findMany({where: {author: {username}}}),
{
revalidateTags: (username) => [`solutions::${username}`],
log: ["verbose", "datacache", "dedupe"],
logid: "getCachedSolutionsPosted",
}
async (username: string) =>
await prisma.solution.findMany({ where: { author: { username } } }),
{
revalidateTags: (username) => [`solutions::${username}`],
log: ["verbose", "datacache", "dedupe"],
logid: "getCachedSolutionsPosted",
}
);

export const getCachedSolution = memoize(
async (id: string) =>
await prisma.solution.findFirst({
where: {
id: id,
},
include: {
author: {
select: {
username: true,
name: true,
},
},
files: true,
challenge: {
select: {
slug: true,
track: {
select: {
slug: true,
},
},
initialFiles:true,
},
},
},
}),
{
revalidateTags: (id) => [`solution::${id}`],
log: ["verbose", "datacache", "dedupe"],
logid: "getCachedSolution",
}
);


export const getCachedSolutions = memoize(async (trackSlug: string|null, challengeSlug: string|null, orderBy: "asc" | "desc" | null
) => await prisma.solution.findMany({
orderBy: [
{
createdAt: orderBy || "desc"
}
],
where: {
async (id: string) =>
await prisma.solution.findFirst({
where: {
id: id,
},
include: {
author: {
select: {
username: true,
name: true,
},
},
files: true,
challenge: {
// passing null with check if slug is null
slug: challengeSlug || undefined,
select: {
slug: true,
track: {
slug: trackSlug || undefined,
}
}
},include:{
challenge:{
select:{
label:true,slug:true,
track:{
select:{
name:true,
slug:true,
}
}
select: {
slug: true,
},
},
}
}
}), {
revalidateTags: (trackSlug: string|null, challengeSlug: string|null, orderBy: "asc" | "desc" | null) => [`solutions::${trackSlug}::${challengeSlug}::${orderBy}`],
},
},
},
}),
{
revalidateTags: (id) => [`solution::${id}`],
log: ["verbose", "datacache", "dedupe"],
logid: "getCachedSolution",
})
}
);
Loading

0 comments on commit 48be339

Please sign in to comment.