sort topics based on amount of tasks
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import { db } from '$lib/db';
|
import { db } from '$lib/db';
|
||||||
import { topics } from '$lib/db/schema';
|
import type { PageServerLoad } from './$types';
|
||||||
import { eq } from 'drizzle-orm';
|
|
||||||
|
|
||||||
export const load = async ({ params }) => {
|
export const load: PageServerLoad = async () => {
|
||||||
return {
|
const topics = await db.query.topics.findMany({
|
||||||
topics: await db.query.topics.findMany({
|
|
||||||
with: {
|
with: {
|
||||||
topicsToTasks: {
|
topicsToTasks: {
|
||||||
with: {
|
with: {
|
||||||
@@ -12,6 +10,11 @@ export const load = async ({ params }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
topics.sort((a, b) => b.topicsToTasks.length - a.topicsToTasks.length);
|
||||||
|
|
||||||
|
return {
|
||||||
|
topics
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user