Skip to content

Commit

Permalink
Merge pull request #557 from tutors-sdk/fix/gallery-updates
Browse files Browse the repository at this point in the history
Correct gallery sorting algorithm
  • Loading branch information
edeleastar authored Oct 9, 2023
2 parents 03bb12f + 4616f4a commit 611cde5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/src/lib/services/utils/all-course-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function getCourseSummary(courseId: string): Promise<CourseSummary>
const courseUrl = `${courseId}.netlify.app`;

return {
title: lo.title,
title: lo.title.trim(),
img: lo.img.replace("{{COURSEURL}}", courseUrl),
icon: lo.properties?.icon,
route: `https://tutors.dev/course/${courseUrl}`,
Expand Down
9 changes: 0 additions & 9 deletions app/src/lib/ui/learning-objects/layout/GalleryCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,5 @@
{/if}
</figure>
</div>
<footer class="card-footer">
<div class="-m-4 mt-2 text-center">
{#if lo.currentLo}
<div class="line-clamp-1">
<a href={lo.currentLo.route} target="_blank" rel="noreferrer">{lo.currentLo.title}</a>
</div>
{/if}
</div>
</footer>
</div>
</a>
23 changes: 11 additions & 12 deletions app/src/routes/(time)/gallery/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import "../../../app.postcss";
import { onMount } from "svelte";
import { getCourseSummary, type CourseSummary } from "$lib/services/utils/all-course-access";
import { readVisits } from "$lib/services/utils/firebase";
import { ProgressBar } from "@skeletonlabs/skeleton";
import TutorsShell from "$lib/ui/app-shells/TutorsShell.svelte";
import GalleryCard from "$lib/ui/learning-objects/layout/GalleryCard.svelte";
Expand All @@ -13,26 +12,24 @@
let los: CourseSummary[] = [];
let modules = 0;
let totalVisits = 0;
let subTitle = "";
onMount(async () => {
if (data.allCourses) {
data.allCourses.forEach(async (courseId: string) => {
try {
const visits = await readVisits(courseId);
if (visits) {
totalVisits += visits;
const courseSummary = await getCourseSummary(courseId);
if (!courseSummary.isPrivate) {
modules++;
subTitle = `Showcasing ${modules} modules`;
los.push(courseSummary);
los = [...los];
const courseSummary = await getCourseSummary(courseId);
if (!courseSummary.isPrivate) {
modules++;
subTitle = `Showcasing ${modules} modules`;
los.push(courseSummary);
if (modules === data.allCourses.length) {
los.sort((lo1: CourseSummary, lo2: CourseSummary) => lo1.title.localeCompare(lo2.title));
}
los = [...los];
}
} catch (error: any) {
modules--;
console.log(`invalid course ${courseId} : ${error.message}`);
}
});
Expand All @@ -41,7 +38,9 @@
</script>

<TutorsShell {session} {supabase} title={"Tutors Module Gallery"} {subTitle}>
<ProgressBar label="Progress Bar" value={modules} max={50} />
{#if modules < data.allCourses.length}
<ProgressBar label="Progress Bar" value={modules} max={data.allCourses.length} />
{/if}
<div class="bg-surface-100-800-token mx-auto mb-2 place-items-center overflow-hidden rounded-xl p-4">
<div class="flex flex-wrap justify-center">
{#each los as lo}
Expand Down
12 changes: 6 additions & 6 deletions app/src/routes/(time)/gallery/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ const validCourses = [
"classic-design-patterns",
"bi-vis-2023",
"careerdevelopment",
"wit-hdip-comp-sci-2022-computer-systems",
"dsa1-jan-2024",
"wit-hdip-comp-sci-2021-database",
"devfor.netlify",
"devfor",
"enterprise-apps",
"fsf21",
"funcprog23-reg",
Expand All @@ -18,8 +17,7 @@ const validCourses = [
"setu-mgd",
"netfor",
"of-2022s2-8z1",
"osforensic",
"bsa-hci-webdesign",
"osforensics",
"ictforforestry",
"placement-project",
"professionalcomms",
Expand All @@ -41,7 +39,7 @@ const validCourses = [
"website-development-2",
"adv-full-stack-oth-2023",
"business-analytics2-2023",
"wit-hdip-comp-sci-2022-computer-system",
"wit-hdip-comp-sci-2022-computer-systems",
"wit-hdip-comp-sci-2022-security",
"wit-hdip-comp-sci-2022-devops",
"ict-for-scientists",
Expand All @@ -53,7 +51,9 @@ const validCourses = [
"wad2-2022-setu",
"wit-hdip-comp-sci-2023-workshop-2-4",
"wit-hdip-comp-sci-2023-workshop-1-3",
"mobile-app-dev-tutors-2022"
"mobile-app-dev-tutors-2022",
"wit-hdip-comp-sci-2022",
"life-etc2022"
];

export const load: PageLoad = async ({ params }) => {
Expand Down

0 comments on commit 611cde5

Please sign in to comment.