From 97625dd4e02884fa235692e017949f964847dab1 Mon Sep 17 00:00:00 2001 From: Denis Urban Date: Thu, 24 Oct 2024 12:01:57 +0300 Subject: [PATCH] sort workshops --- package.json | 2 +- src/fetch-workshops.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9d451cd..c5ac2e3 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@focus-reactive/graphql-content-layer", - "version": "3.1.28", + "version": "3.1.29", "private": false, "main": "dist/index.js", "scripts": { diff --git a/src/fetch-workshops.js b/src/fetch-workshops.js index d0e598c..4315e29 100644 --- a/src/fetch-workshops.js +++ b/src/fetch-workshops.js @@ -182,6 +182,8 @@ const fetchData = async (client, vars) => { additionalInfo: await markdownToHtml(wrp.additionalInfo), prerequisites: await markdownToHtml(wrp.prerequisites), finishingTime: '', + startDate: + wrp.startDate || dayjs(wrp.location, 'MMMM D, HH').toISOString(), })), ); @@ -220,10 +222,17 @@ const fetchData = async (client, vars) => { ), ); + const sortedWorkshops = allWorkshops.sort((a, b) => { + return ( + Number(a.includedToPackage) - Number(b.includedToPackage) || + new Date(a.startDate).getTime() - new Date(b.startDate).getTime() + ); + }); + return { trainers, workshopDays: data.length, - workshops: allWorkshops, + workshops: sortedWorkshops, speakers: { workshops: trainers, },