MCPcopy Create free account
hub / github.com/code100x/daily-code / getTrack

Function getTrack

apps/web/components/utils.tsx:120–157  ·  view source on GitHub ↗
(trackId: string)

Source from the content-addressed store, hash-verified

118}
119
120export async function getTrack(trackId: string) {
121 const value: Tracks = await cache.get("Track", [trackId.toString()]);
122 if (value) {
123 return {
124 ...value,
125 problems: value.problems.map((problem: { problem: Problem }) => ({ ...problem.problem })),
126 };
127 }
128 try {
129 const track = await db.track.findUnique({
130 where: {
131 id: trackId,
132 },
133 include: {
134 problems: {
135 select: {
136 problem: true,
137 },
138 orderBy: [
139 {
140 sortingOrder: "desc",
141 },
142 ],
143 },
144 },
145 });
146 if (track) {
147 await cache.set("Track", [trackId.toString()], track);
148 return {
149 ...track,
150 problems: track.problems.map((problem: any) => ({ ...problem.problem })),
151 };
152 }
153 return null;
154 } catch (err) {
155 return null;
156 }
157}
158
159export async function getAllTracks() {
160 const value = await cache.get("getAllTracks", []);

Callers 4

scrapeDataFunction · 0.90
TrackComponentFunction · 0.90
generateMetadataFunction · 0.90
TrackComponentFunction · 0.90

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected