From f75f2b539f901bc5a26dd487ede6d48c6069b05a Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:04:42 -0500 Subject: [PATCH 01/15] Update dependencies to latest versions (bar mongodb) --- package-lock.json | 177 +++++++++++++++++++++++----------------------- package.json | 15 ++-- 2 files changed, 98 insertions(+), 94 deletions(-) diff --git a/package-lock.json b/package-lock.json index e92c58f..e71133c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,16 +8,17 @@ "name": "Stat-'n'-Track", "version": "0.0.1", "dependencies": { - "@alpinejs/collapse": "^3.13.3", - "@astrojs/db": "^0.9.1", + "@alpinejs/collapse": "^3.13.8", + "@astrojs/alpinejs": "^0.4.0", + "@astrojs/db": "^0.10.4", "@astrojs/prefetch": "^0.4.1", - "@astrojs/sitemap": "^3.1.1", + "@astrojs/sitemap": "^3.1.3", "@astrojs/tailwind": "^5.1.0", - "@types/alpinejs": "^3.13.5", - "alpinejs": "^3.13.3", - "astro": "^4.5.8", + "@types/alpinejs": "^3.13.10", + "alpinejs": "^3.13.8", + "astro": "^4.6.2", "mongodb": "^6.3.0", - "tailwindcss": "^3.3.5" + "tailwindcss": "^3.4.3" } }, "node_modules/@alloc/quick-lru": { @@ -32,9 +33,9 @@ } }, "node_modules/@alpinejs/collapse": { - "version": "3.13.3", - "resolved": "https://registry.npmjs.org/@alpinejs/collapse/-/collapse-3.13.3.tgz", - "integrity": "sha512-iGO6IzqBwVNxAaoS4XCCJIIg9U/mH7v4vk6wlzxXKFWMXt2yynw93TkdELyjwxQqeNTEGimZRR+2wNf9yhJn0A==" + "version": "3.13.8", + "resolved": "https://registry.npmjs.org/@alpinejs/collapse/-/collapse-3.13.8.tgz", + "integrity": "sha512-NsYiidTJ/AOFE8xUMxnXIe5LbRYcfw3UjxI6VUlDw3st4XwzaeCNyqBbZVRt9Ac7wfdrODy0qTHA+iCHSF0atQ==" }, "node_modules/@ampproject/remapping": { "version": "2.2.1", @@ -48,20 +49,29 @@ "node": ">=6.0.0" } }, + "node_modules/@astrojs/alpinejs": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@astrojs/alpinejs/-/alpinejs-0.4.0.tgz", + "integrity": "sha512-68BY1CA0XuielLW3WdX2sfh9F4sSTnFqQ//IE9AditbiYJ77HJDb4uZx07pTFDtr1jOMU7lCvH+iS9gmNafM1g==", + "peerDependencies": { + "@types/alpinejs": "^3.0.0", + "alpinejs": "^3.0.0" + } + }, "node_modules/@astrojs/compiler": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.7.0.tgz", - "integrity": "sha512-XpC8MAaWjD1ff6/IfkRq/5k1EFj6zhCNqXRd5J43SVJEBj/Bsmizkm8N0xOYscGcDFQkRgEw6/eKnI5x/1l6aA==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.7.1.tgz", + "integrity": "sha512-/POejAYuj8WEw7ZI0J8JBvevjfp9jQ9Wmu/Bg52RiNwGXkMV7JnYpsenVfHvvf1G7R5sXHGKlTcxlQWhoUTiGQ==" }, "node_modules/@astrojs/db": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@astrojs/db/-/db-0.9.1.tgz", - "integrity": "sha512-o8NRz420vIK6ouOAgCuhcoiLtN1l9I6G5Rs7Wsc2hpPNj2vpqPNIFNxAMtauY9mvLZdakq7F8GRMehSGBLX/+w==", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@astrojs/db/-/db-0.10.4.tgz", + "integrity": "sha512-6A7UQPZZ4wQuA7JuhZ5N2/aqOECLj62+mjLC1iRFVkUTXpU251hKrZubAt0BqOdvNTuei8DNxSWuK+krFkngzA==", "dependencies": { "@libsql/client": "^0.5.5", "async-listen": "^3.0.1", "deep-diff": "^1.0.2", - "drizzle-orm": "^0.30.2", + "drizzle-orm": "^0.30.4", "github-slugger": "^2.0.0", "kleur": "^4.1.5", "nanoid": "^5.0.1", @@ -91,16 +101,16 @@ } }, "node_modules/@astrojs/internal-helpers": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.3.0.tgz", - "integrity": "sha512-tGmHvrhpzuz0JBHaJX8GywN9g4rldVNHtkoVDC3m/DdzBO70jGoVuc0uuNVglRYnsdwkbG0K02Iw3nOOR3/Y4g==" + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.4.0.tgz", + "integrity": "sha512-6B13lz5n6BrbTqCTwhXjJXuR1sqiX/H6rTxzlXx+lN1NnV4jgnq/KJldCQaUWJzPL5SiWahQyinxAbxQtwgPHA==" }, "node_modules/@astrojs/markdown-remark": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-4.3.1.tgz", - "integrity": "sha512-eJFi600tkRjTFiwzY9oD8AgCgB7gFqyWCKWuZ33dATVBgLiROD+zlMZ8STZzU7+ZALvmiUAun/K7umTmP5YfVQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-5.1.0.tgz", + "integrity": "sha512-S6Z3K2hOB7MfjeDoHsotnP/q2UsnEDB8NlNAaCjMDsGBZfTUbWxyLW3CaphEWw08f6KLZi2ibK9yC3BaMhh2NQ==", "dependencies": { - "@astrojs/prism": "^3.0.0", + "@astrojs/prism": "^3.1.0", "github-slugger": "^2.0.0", "hast-util-from-html": "^2.0.0", "hast-util-to-text": "^4.0.0", @@ -130,20 +140,20 @@ } }, "node_modules/@astrojs/prism": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-3.0.0.tgz", - "integrity": "sha512-g61lZupWq1bYbcBnYZqdjndShr/J3l/oFobBKPA3+qMat146zce3nz2kdO4giGbhYDt4gYdhmoBz0vZJ4sIurQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-3.1.0.tgz", + "integrity": "sha512-Z9IYjuXSArkAUx3N6xj6+Bnvx8OdUSHA8YoOgyepp3+zJmtVYJIl/I18GozdJVW1p5u/CNpl3Km7/gwTJK85cw==", "dependencies": { "prismjs": "^1.29.0" }, "engines": { - "node": ">=18.14.1" + "node": "^18.17.1 || ^20.3.0 || >=21.0.0" } }, "node_modules/@astrojs/sitemap": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.1.1.tgz", - "integrity": "sha512-qPgdBIcDUaea98mTtLfi5z9oXZpzSjEn/kes70/Ex8FOZZ+DIHVKRYOLOtvy8p+FTXr/9oc7BjmIbTYmYLLJVg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.1.3.tgz", + "integrity": "sha512-9WB5c071L+FNbs/0727lcqbHvS17TxnDRdfXXiAMustBRFlqkCrziHy+MsfeghxtyXp0pFTFO3NjGRfOppbFzQ==", "dependencies": { "sitemap": "^7.1.1", "zod": "^3.22.4" @@ -164,20 +174,20 @@ } }, "node_modules/@astrojs/telemetry": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.0.4.tgz", - "integrity": "sha512-A+0c7k/Xy293xx6odsYZuXiaHO0PL+bnDoXOc47sGDF5ffIKdKQGRPFl2NMlCF4L0NqN4Ynbgnaip+pPF0s7pQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.1.0.tgz", + "integrity": "sha512-/ca/+D8MIKEC8/A9cSaPUqQNZm+Es/ZinRv0ZAzvu2ios7POQSsVD+VOj7/hypWNsNM3T7RpfgNq7H2TU1KEHA==", "dependencies": { - "ci-info": "^3.8.0", + "ci-info": "^4.0.0", "debug": "^4.3.4", "dlv": "^1.1.3", - "dset": "^3.1.2", + "dset": "^3.1.3", "is-docker": "^3.0.0", "is-wsl": "^3.0.0", "which-pm-runs": "^1.1.0" }, "engines": { - "node": ">=18.14.1" + "node": "^18.17.1 || ^20.3.0 || >=21.0.0" } }, "node_modules/@babel/code-frame": { @@ -1299,14 +1309,14 @@ ] }, "node_modules/@shikijs/core": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.0.tgz", - "integrity": "sha512-OlFvx+nyr5C8zpcMBnSGir0YPD6K11uYhouqhNmm1qLiis4GA7SsGtu07r9gKS9omks8RtQqHrJL4S+lqWK01A==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.3.0.tgz", + "integrity": "sha512-7fedsBfuILDTBmrYZNFI8B6ATTxhQAasUHllHmjvSZPnoq4bULWoTpHwmuQvZ8Aq03/tAa2IGo6RXqWtHdWaCA==" }, "node_modules/@types/alpinejs": { - "version": "3.13.5", - "resolved": "https://registry.npmjs.org/@types/alpinejs/-/alpinejs-3.13.5.tgz", - "integrity": "sha512-BSNTroRhmBkNiyd7ELK/5Boja92hnQMST6H4z1BqXKeMVzHjp9o1j5poqd5Tyhjd8oMFwxYC4I00eghfg2xrTA==" + "version": "3.13.10", + "resolved": "https://registry.npmjs.org/@types/alpinejs/-/alpinejs-3.13.10.tgz", + "integrity": "sha512-ah53tF6mWuuwerpDE7EHwbZErNDJQlsLISPqJhYj2RZ9nuTYbRknSkqebUd3igkhLIZKkPa7IiXjSn9qsU9O2w==" }, "node_modules/@types/babel__core": { "version": "7.20.5", @@ -1345,6 +1355,11 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/cookie": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.5.4.tgz", + "integrity": "sha512-7z/eR6O859gyWIAjuvBWFzNURmf2oPBmJlfVWkwehU5nzIyjwBsTh7WMmEEV4JFnHuQ3ex4oyTvfKzcyJVDBNA==" + }, "node_modules/@types/debug": { "version": "4.1.12", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", @@ -1473,9 +1488,9 @@ } }, "node_modules/alpinejs": { - "version": "3.13.3", - "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.3.tgz", - "integrity": "sha512-WZ6WQjkAOl+WdW/jukzNHq9zHFDNKmkk/x6WF7WdyNDD6woinrfXCVsZXm0galjbco+pEpYmJLtwlZwcOfIVdg==", + "version": "3.13.8", + "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.8.tgz", + "integrity": "sha512-XolbBJryCndomtaHd/KHQjQeD/L72FJxy/YhLLFD4Lr7zzGcpcbg+UgXteMR2pYg1KhRUr6V4O3GfN1zJAmRWw==", "dependencies": { "@vue/reactivity": "~3.1.1" } @@ -1579,14 +1594,14 @@ } }, "node_modules/astro": { - "version": "4.5.8", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.5.8.tgz", - "integrity": "sha512-bhKsoZQWT6LW8aYMvTGglZTPa3rYRbcdc2buiJyFPCvSWOOyZmxqpp6vtQ+x6fXxD8P1NecM/c4g5GaPi+MokQ==", - "dependencies": { - "@astrojs/compiler": "^2.7.0", - "@astrojs/internal-helpers": "0.3.0", - "@astrojs/markdown-remark": "4.3.1", - "@astrojs/telemetry": "3.0.4", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.6.2.tgz", + "integrity": "sha512-Kl+Wd7MJMQFnI3+V0JxF4HPbs8M67eltqQgtztReOwDLSl0VnOd39rM61W/3LEh10FZ0F13xrDgtdgfXzuLVbg==", + "dependencies": { + "@astrojs/compiler": "^2.7.1", + "@astrojs/internal-helpers": "0.4.0", + "@astrojs/markdown-remark": "5.1.0", + "@astrojs/telemetry": "3.1.0", "@babel/core": "^7.24.3", "@babel/generator": "^7.23.3", "@babel/parser": "^7.23.3", @@ -1594,6 +1609,7 @@ "@babel/traverse": "^7.23.3", "@babel/types": "^7.23.3", "@types/babel__core": "^7.20.4", + "@types/cookie": "^0.5.4", "acorn": "^8.11.2", "aria-query": "^5.3.0", "axobject-query": "^4.0.0", @@ -1650,27 +1666,14 @@ "astro": "astro.js" }, "engines": { - "node": ">=18.14.1", - "npm": ">=6.14.0" + "node": "^18.17.1 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0" }, "optionalDependencies": { "sharp": "^0.32.6" } }, - "node_modules/astro/node_modules/ci-info": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", - "integrity": "sha512-TdHqgGf9odd8SXNuxtUBVx8Nv+qZOejE6qyqiy5NtbYYQOeFa6zmHkxlPzmaLxWWHsU6nJmB7AETdVPi+2NBUg==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "engines": { - "node": ">=8" - } - }, "node_modules/astro/node_modules/emoji-regex": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.3.0.tgz", @@ -2103,9 +2106,9 @@ "optional": true }, "node_modules/ci-info": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", - "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", + "integrity": "sha512-TdHqgGf9odd8SXNuxtUBVx8Nv+qZOejE6qyqiy5NtbYYQOeFa6zmHkxlPzmaLxWWHsU6nJmB7AETdVPi+2NBUg==", "funding": [ { "type": "github", @@ -3155,9 +3158,9 @@ } }, "node_modules/hast-util-to-text": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.0.tgz", - "integrity": "sha512-EWiE1FSArNBPUo1cKWtzqgnuRQwEeQbQtnFJRYV1hb1BWDgrAlBU0ExptvZMM/KSA82cDpm2sFGf3Dmc5Mza3w==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz", + "integrity": "sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==", "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", @@ -4399,9 +4402,9 @@ } }, "node_modules/micromark-util-subtokenize": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.0.tgz", - "integrity": "sha512-vc93L1t+gpR3p8jxeVdaYlbV2jTYteDje19rNSS/H5dlhxUYll5Fy6vJ2cDwP8RnsXi818yGty1ayP55y3W6fg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.1.tgz", + "integrity": "sha512-jZNtiFl/1aY73yS3UGQkutD0UbhTt68qnRpw2Pifmz5wV9h8gOVsN70v+Lq/f1rKaU/W8pxRe8y8Q9FX1AOe1Q==", "funding": [ { "type": "GitHub Sponsors", @@ -6098,11 +6101,11 @@ } }, "node_modules/shiki": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.2.0.tgz", - "integrity": "sha512-xLhiTMOIUXCv5DqJ4I70GgQCtdlzsTqFLZWcMHHG3TAieBUbvEGthdrlPDlX4mL/Wszx9C6rEcxU6kMlg4YlxA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.3.0.tgz", + "integrity": "sha512-9aNdQy/etMXctnPzsje1h1XIGm9YfRcSksKOGqZWXA/qP9G18/8fpz5Bjpma8bOgz3tqIpjERAd6/lLjFyzoww==", "dependencies": { - "@shikijs/core": "1.2.0" + "@shikijs/core": "1.3.0" } }, "node_modules/signal-exit": { @@ -6399,9 +6402,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.5.tgz", - "integrity": "sha512-5SEZU4J7pxZgSkv7FP1zY8i2TIAOooNZ1e/OGtxIEv6GltpoiXUqWvLy89+a10qYTB1N5Ifkuw9lqQkN9sscvA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz", + "integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==", "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -6411,7 +6414,7 @@ "fast-glob": "^3.3.0", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", - "jiti": "^1.19.1", + "jiti": "^1.21.0", "lilconfig": "^2.1.0", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", diff --git a/package.json b/package.json index 128de7c..582d97b 100644 --- a/package.json +++ b/package.json @@ -10,15 +10,16 @@ "astro": "astro" }, "dependencies": { - "@alpinejs/collapse": "^3.13.3", - "@astrojs/db": "^0.9.1", + "@alpinejs/collapse": "^3.13.8", + "@astrojs/alpinejs": "^0.4.0", + "@astrojs/db": "^0.10.4", "@astrojs/prefetch": "^0.4.1", - "@astrojs/sitemap": "^3.1.1", + "@astrojs/sitemap": "^3.1.3", "@astrojs/tailwind": "^5.1.0", - "@types/alpinejs": "^3.13.5", - "alpinejs": "^3.13.3", - "astro": "^4.5.8", + "@types/alpinejs": "^3.13.10", + "alpinejs": "^3.13.8", + "astro": "^4.6.2", "mongodb": "^6.3.0", - "tailwindcss": "^3.3.5" + "tailwindcss": "^3.4.3" } } From 99cc2c44bfb64dda6feae31a4d28e2965a37f6ab Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:05:16 -0500 Subject: [PATCH 02/15] Add Alpine to Window interface --- src/env.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/env.d.ts b/src/env.d.ts index 0751073..7dbf370 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -9,3 +9,7 @@ interface ImportMetaEnv { interface ImportMeta { readonly env: ImportMetaEnv; } + +interface Window { + Alpine: import('alpinejs').Alpine; +} From 4c1048c40f2a88aeeb1321ce1dcd53937e6fe158 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:05:29 -0500 Subject: [PATCH 03/15] Correct typing of table component --- src/lib/components/table/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/table/index.ts b/src/lib/components/table/index.ts index fab98b1..f4180d8 100644 --- a/src/lib/components/table/index.ts +++ b/src/lib/components/table/index.ts @@ -26,7 +26,7 @@ const stringSort = ({ return array.sort().reverse(); }; -export default (): AlpineComponent => ({ +export default (): AlpineComponent<{ sort: () => void }> => ({ sort() { const [tableName, columnName, rowCount, direction] = this.$el.id.split(" "); const rows = new Map(); From 1849ed5935f7e2d79f9435cea6e0b4d3a5609084 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:05:40 -0500 Subject: [PATCH 04/15] Create entrypoint for Alpine --- src/lib/alpine.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/lib/alpine.ts diff --git a/src/lib/alpine.ts b/src/lib/alpine.ts new file mode 100644 index 0000000..6deef08 --- /dev/null +++ b/src/lib/alpine.ts @@ -0,0 +1,36 @@ +import type { Alpine } from "alpinejs"; +// @ts-expect-error +import collapse from "@alpinejs/collapse"; +import Table from "$lib/components/table"; + +export default (Alpine: Alpine) => { + Alpine.plugin(collapse); + Alpine.data("table", Table); + Alpine.data("PRACTICE", Table); + Alpine.data("QUALIFY", Table); + Alpine.data("HEAT", Table); + Alpine.data("RACE", Table); + Alpine.data("tables", () => ({ + PRACTICE: false, + QUALIFY: false, + HEAT: false, + RACE: false, + toggle() { + this.$el.id.split(" ").forEach((id, index) => { + if (index) { + // @ts-expect-error + this[id] = false; + } else { + // @ts-expect-error + this[id] = !this[id]; + } + }); + }, + })); + Alpine.data("dropdown", () => ({ + opened: false, + toggle() { + this.opened = !this.opened; + }, + })); +}; From c4be5197ef6e2525fd26d52c7fa83a6dcfa800d5 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:05:54 -0500 Subject: [PATCH 05/15] Utilize @astrojs/alpinejs integration using local entrypoint --- astro.config.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/astro.config.mjs b/astro.config.mjs index 3477551..af1fd0b 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,6 +1,7 @@ import { defineConfig } from "astro/config"; import tailwind from "@astrojs/tailwind"; import prefetch from "@astrojs/prefetch"; +import alpinejs from "@astrojs/alpinejs"; import sitemap from "@astrojs/sitemap"; import db from "@astrojs/db"; @@ -8,5 +9,11 @@ import db from "@astrojs/db"; export default defineConfig({ site: "https://shinsina.github.io", base: "/Stat-N-Track", - integrations: [tailwind(), prefetch(), sitemap(), db()], + integrations: [ + tailwind(), + prefetch(), + alpinejs({ entrypoint: "/src/lib/alpine" }), + sitemap(), + db(), + ], }); From 8b951e087fe70e1b50f369f13da1d8087b85dce0 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:06:09 -0500 Subject: [PATCH 06/15] Place trailing slashes on navigation hrefs --- src/lib/layouts/default.astro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/layouts/default.astro b/src/lib/layouts/default.astro index 125ce0c..42fa9c8 100644 --- a/src/lib/layouts/default.astro +++ b/src/lib/layouts/default.astro @@ -28,17 +28,17 @@ const seoDescription = Home Jacob Collins Jack Glenzinski Shared Subsessions From 2edeb862a42ef0521c8c191af1c48f6ffae79728 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Wed, 17 Apr 2024 16:06:51 -0500 Subject: [PATCH 07/15] Remove inline script tags for setting up Alpine components --- src/lib/layouts/standings.astro | 6 ----- src/lib/layouts/subsessions.astro | 6 ----- src/pages/shared-subsessions.astro | 7 ----- src/pages/subsession/[id].astro | 26 ------------------- .../[id]/scheduling/by-week/[timestamp].astro | 6 ----- src/pages/user/[id]/scheduling/index.astro | 13 ---------- .../car-class/[carClassId]/index.astro | 6 ----- 7 files changed, 70 deletions(-) diff --git a/src/lib/layouts/standings.astro b/src/lib/layouts/standings.astro index fb055d3..410ab2d 100644 --- a/src/lib/layouts/standings.astro +++ b/src/lib/layouts/standings.astro @@ -129,10 +129,4 @@ const generateLinkForKey = ({ } - diff --git a/src/lib/layouts/subsessions.astro b/src/lib/layouts/subsessions.astro index 59a2a3a..ef8af59 100644 --- a/src/lib/layouts/subsessions.astro +++ b/src/lib/layouts/subsessions.astro @@ -115,10 +115,4 @@ const { keysArray, handledResults } = handleResults({ keysToDisplay, results }); } - diff --git a/src/pages/shared-subsessions.astro b/src/pages/shared-subsessions.astro index 80ee110..fccd217 100644 --- a/src/pages/shared-subsessions.astro +++ b/src/pages/shared-subsessions.astro @@ -253,11 +253,4 @@ const description = "Shared subsessions for all Stat 'n' Track users"; - diff --git a/src/pages/subsession/[id].astro b/src/pages/subsession/[id].astro index 59934ae..278475e 100644 --- a/src/pages/subsession/[id].astro +++ b/src/pages/subsession/[id].astro @@ -132,30 +132,4 @@ const description = `Subsession information for subsession - ${id}`; - diff --git a/src/pages/user/[id]/scheduling/by-week/[timestamp].astro b/src/pages/user/[id]/scheduling/by-week/[timestamp].astro index bfe3873..c1b6d3e 100644 --- a/src/pages/user/[id]/scheduling/by-week/[timestamp].astro +++ b/src/pages/user/[id]/scheduling/by-week/[timestamp].astro @@ -185,10 +185,4 @@ const description = title; } - diff --git a/src/pages/user/[id]/scheduling/index.astro b/src/pages/user/[id]/scheduling/index.astro index ef03ee6..2cbe283 100644 --- a/src/pages/user/[id]/scheduling/index.astro +++ b/src/pages/user/[id]/scheduling/index.astro @@ -174,17 +174,4 @@ const description = `Scheduling page for user ID: ${id}`; )) } - diff --git a/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/index.astro b/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/index.astro index 0ec5f41..4cc15bf 100644 --- a/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/index.astro +++ b/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/index.astro @@ -173,10 +173,4 @@ const description = title; } - From 4b1c1f25b0b6f481f51623c443fccb58392761c7 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 08:45:34 -0500 Subject: [PATCH 08/15] Trim the string and also match if year is at start of season_name --- src/lib/layouts/standings.astro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/layouts/standings.astro b/src/lib/layouts/standings.astro index 410ab2d..b67cb59 100644 --- a/src/lib/layouts/standings.astro +++ b/src/lib/layouts/standings.astro @@ -25,8 +25,9 @@ const finalData: Array> = standingsResults.map( incidents, points, } = result; - const [, year] = season_name.match(/([0-9]{4}) Season/) || - season_name.match(/([0-9]{4})$/) || [0, 0]; + const [, year] = season_name.trim().match(/([0-9]{4}) Season/) || + season_name.trim().match(/([0-9]{4})$/) || + season_name.trim().match(/^([0-9]{4})/) || [0, 0]; const [, season_number_of_year] = season_name.match( /Season ([0-9]{1})/ ) || [0, 0]; From 1c2f663e34fe122ec22aa18e964d6a4c9dec930a Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 09:43:41 -0500 Subject: [PATCH 09/15] Various styling and data adjustments for Subsession pages --- src/lib/components/subsession/licenseInfo.astro | 7 ++++--- src/lib/components/subsession/raceSummary.astro | 12 +++++++++--- src/lib/components/subsession/relevantIds.astro | 2 +- src/lib/components/track/info.astro | 4 ++-- src/pages/subsession/[id].astro | 12 ++++-------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/lib/components/subsession/licenseInfo.astro b/src/lib/components/subsession/licenseInfo.astro index 18dc527..fb0435f 100644 --- a/src/lib/components/subsession/licenseInfo.astro +++ b/src/lib/components/subsession/licenseInfo.astro @@ -5,9 +5,10 @@ const [allowedLicenseOne, allowLicenseTwo] = licenses || []; const allowedLicenses = [allowedLicenseOne, allowLicenseTwo]; --- -
-

License Category: {licenseCategory}

-
+
+

License Information:

+

License Category: {licenseCategory}

+
Allowed Licenses: { allowedLicenses.map((license: License, index: number) => ( diff --git a/src/lib/components/subsession/raceSummary.astro b/src/lib/components/subsession/raceSummary.astro index b8b2b4b..0ea9ffb 100644 --- a/src/lib/components/subsession/raceSummary.astro +++ b/src/lib/components/subsession/raceSummary.astro @@ -11,15 +11,21 @@ const { start_time, end_time, } = subsession; +const started = new Date(start_time).toLocaleString("en-US", { + timeZone: "America/Chicago", +}); +const ended = new Date(end_time).toLocaleString("en-US", { + timeZone: "America/Chicago", +}); ---
- Race Summary: +

Race Summary:

Average Lap Time: {parseLapTime(event_average_lap)}

Laps Complete: {event_laps_complete}

Number of Cautions: {num_cautions} for {num_caution_laps} laps

Lead Changes: {num_lead_changes}

Strength of Field: {event_strength_of_field}

-

Started: {new Date(start_time)}

-

Ended: {new Date(end_time)}

+

Started: {started}

+

Ended: {ended}

diff --git a/src/lib/components/subsession/relevantIds.astro b/src/lib/components/subsession/relevantIds.astro index 9096006..ac07d37 100644 --- a/src/lib/components/subsession/relevantIds.astro +++ b/src/lib/components/subsession/relevantIds.astro @@ -35,7 +35,7 @@ const otherRelevantIdsList = Object.keys(relevantIdMap) ---
- Relevant IDs +

Relevant IDs:

{relevantIds.map((id) =>

{id}

)} {otherRelevantIdsList.map((value) =>

{value}

)}
diff --git a/src/lib/components/track/info.astro b/src/lib/components/track/info.astro index 812a239..ceb8c2d 100644 --- a/src/lib/components/track/info.astro +++ b/src/lib/components/track/info.astro @@ -3,8 +3,8 @@ const { cornersPerLap, track } = Astro.props; const { track_name, config_name, category } = track; --- -
- Track Facts: +
+

Track Facts:

Name: {track_name}

Configuration: {config_name}

Category: {category}

diff --git a/src/pages/subsession/[id].astro b/src/pages/subsession/[id].astro index 278475e..43cf724 100644 --- a/src/pages/subsession/[id].astro +++ b/src/pages/subsession/[id].astro @@ -117,17 +117,13 @@ const description = `Subsession information for subsession - ${id}`;
-
-
- - -
-
+
-
-
+
+ +
From 9202dedc273984d4918b812ee418f983af3a0ad1 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 10:15:14 -0500 Subject: [PATCH 10/15] Bump mongodb to latest version, fix astro to 4.5.8 --- package-lock.json | 93 +++++++++++++++++++++++++---------------------- package.json | 4 +- 2 files changed, 52 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index e71133c..cb2d12b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,8 +16,8 @@ "@astrojs/tailwind": "^5.1.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.13.8", - "astro": "^4.6.2", - "mongodb": "^6.3.0", + "astro": "4.5.8", + "mongodb": "^6.5.0", "tailwindcss": "^3.4.3" } }, @@ -101,16 +101,16 @@ } }, "node_modules/@astrojs/internal-helpers": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.4.0.tgz", - "integrity": "sha512-6B13lz5n6BrbTqCTwhXjJXuR1sqiX/H6rTxzlXx+lN1NnV4jgnq/KJldCQaUWJzPL5SiWahQyinxAbxQtwgPHA==" + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.3.0.tgz", + "integrity": "sha512-tGmHvrhpzuz0JBHaJX8GywN9g4rldVNHtkoVDC3m/DdzBO70jGoVuc0uuNVglRYnsdwkbG0K02Iw3nOOR3/Y4g==" }, "node_modules/@astrojs/markdown-remark": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-5.1.0.tgz", - "integrity": "sha512-S6Z3K2hOB7MfjeDoHsotnP/q2UsnEDB8NlNAaCjMDsGBZfTUbWxyLW3CaphEWw08f6KLZi2ibK9yC3BaMhh2NQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-4.3.1.tgz", + "integrity": "sha512-eJFi600tkRjTFiwzY9oD8AgCgB7gFqyWCKWuZ33dATVBgLiROD+zlMZ8STZzU7+ZALvmiUAun/K7umTmP5YfVQ==", "dependencies": { - "@astrojs/prism": "^3.1.0", + "@astrojs/prism": "^3.0.0", "github-slugger": "^2.0.0", "hast-util-from-html": "^2.0.0", "hast-util-to-text": "^4.0.0", @@ -174,20 +174,34 @@ } }, "node_modules/@astrojs/telemetry": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.1.0.tgz", - "integrity": "sha512-/ca/+D8MIKEC8/A9cSaPUqQNZm+Es/ZinRv0ZAzvu2ios7POQSsVD+VOj7/hypWNsNM3T7RpfgNq7H2TU1KEHA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.0.4.tgz", + "integrity": "sha512-A+0c7k/Xy293xx6odsYZuXiaHO0PL+bnDoXOc47sGDF5ffIKdKQGRPFl2NMlCF4L0NqN4Ynbgnaip+pPF0s7pQ==", "dependencies": { - "ci-info": "^4.0.0", + "ci-info": "^3.8.0", "debug": "^4.3.4", "dlv": "^1.1.3", - "dset": "^3.1.3", + "dset": "^3.1.2", "is-docker": "^3.0.0", "is-wsl": "^3.0.0", "which-pm-runs": "^1.1.0" }, "engines": { - "node": "^18.17.1 || ^20.3.0 || >=21.0.0" + "node": ">=18.14.1" + } + }, + "node_modules/@astrojs/telemetry/node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" } }, "node_modules/@babel/code-frame": { @@ -1084,9 +1098,9 @@ ] }, "node_modules/@mongodb-js/saslprep": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz", - "integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.5.tgz", + "integrity": "sha512-XLNOMH66KhJzUJNwT/qlMnS4WsNDWD5ASdyaSH3EtK+F4r/CFGa3jT4GNi4mfOitGvWXtdLgQJkQjxSVrio+jA==", "dependencies": { "sparse-bitfield": "^3.0.3" } @@ -1355,11 +1369,6 @@ "@babel/types": "^7.20.7" } }, - "node_modules/@types/cookie": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.5.4.tgz", - "integrity": "sha512-7z/eR6O859gyWIAjuvBWFzNURmf2oPBmJlfVWkwehU5nzIyjwBsTh7WMmEEV4JFnHuQ3ex4oyTvfKzcyJVDBNA==" - }, "node_modules/@types/debug": { "version": "4.1.12", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", @@ -1594,14 +1603,14 @@ } }, "node_modules/astro": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.6.2.tgz", - "integrity": "sha512-Kl+Wd7MJMQFnI3+V0JxF4HPbs8M67eltqQgtztReOwDLSl0VnOd39rM61W/3LEh10FZ0F13xrDgtdgfXzuLVbg==", - "dependencies": { - "@astrojs/compiler": "^2.7.1", - "@astrojs/internal-helpers": "0.4.0", - "@astrojs/markdown-remark": "5.1.0", - "@astrojs/telemetry": "3.1.0", + "version": "4.5.8", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.5.8.tgz", + "integrity": "sha512-bhKsoZQWT6LW8aYMvTGglZTPa3rYRbcdc2buiJyFPCvSWOOyZmxqpp6vtQ+x6fXxD8P1NecM/c4g5GaPi+MokQ==", + "dependencies": { + "@astrojs/compiler": "^2.7.0", + "@astrojs/internal-helpers": "0.3.0", + "@astrojs/markdown-remark": "4.3.1", + "@astrojs/telemetry": "3.0.4", "@babel/core": "^7.24.3", "@babel/generator": "^7.23.3", "@babel/parser": "^7.23.3", @@ -1609,7 +1618,6 @@ "@babel/traverse": "^7.23.3", "@babel/types": "^7.23.3", "@types/babel__core": "^7.20.4", - "@types/cookie": "^0.5.4", "acorn": "^8.11.2", "aria-query": "^5.3.0", "axobject-query": "^4.0.0", @@ -1666,9 +1674,8 @@ "astro": "astro.js" }, "engines": { - "node": "^18.17.1 || ^20.3.0 || >=21.0.0", - "npm": ">=9.6.5", - "pnpm": ">=7.1.0" + "node": ">=18.14.1", + "npm": ">=6.14.0" }, "optionalDependencies": { "sharp": "^0.32.6" @@ -1942,9 +1949,9 @@ } }, "node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.6.0.tgz", + "integrity": "sha512-BVINv2SgcMjL4oYbBuCQTpE3/VKOSxrOA8Cj/wQP7izSzlBGVomdm+TcUd0Pzy0ytLSSDweCKQ6X3f5veM5LQA==", "engines": { "node": ">=16.20.1" } @@ -4544,12 +4551,12 @@ "optional": true }, "node_modules/mongodb": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.3.0.tgz", - "integrity": "sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.5.0.tgz", + "integrity": "sha512-Fozq68InT+JKABGLqctgtb8P56pRrJFkbhW0ux+x1mdHeyinor8oNzJqwLjV/t5X5nJGfTlluxfyMnOXNggIUA==", "dependencies": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", + "@mongodb-js/saslprep": "^1.1.5", + "bson": "^6.4.0", "mongodb-connection-string-url": "^3.0.0" }, "engines": { diff --git a/package.json b/package.json index 582d97b..c0d9be1 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "@astrojs/tailwind": "^5.1.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.13.8", - "astro": "^4.6.2", - "mongodb": "^6.3.0", + "astro": "4.5.8", + "mongodb": "^6.5.0", "tailwindcss": "^3.4.3" } } From cf699d72d7c216a0625d895c3339c35e829ad75a Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 10:40:01 -0500 Subject: [PATCH 11/15] Correct , to ; on userResult field definition on Subsession type --- src/lib/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts index 89d0d2e..58d24a2 100644 --- a/src/lib/types/index.ts +++ b/src/lib/types/index.ts @@ -186,7 +186,7 @@ export type Subsession = { series_short_name: string; session_id: number; session_results: Array; - userResult: SessionResult, + userResult: SessionResult; special_event_type: number; start_time: string; subsession_id: number; From c409bc13a4f538d79b2eef6084780f8b76f97250 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 10:40:40 -0500 Subject: [PATCH 12/15] Correct sorting logic to be "typesafe" --- .../[seasonId]/car-class/[carClassId]/season-summary.astro | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro b/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro index fc44625..69d7a8d 100644 --- a/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro +++ b/src/pages/user/[id]/season/[seasonId]/car-class/[carClassId]/season-summary.astro @@ -86,10 +86,8 @@ trackScheduleMap.forEach((value) => { const bestUserResult = userResults .sort( (a, b) => - // @ts-expect-error - a.userResult.aggregate_champ_points - - // @ts-expect-error - b.userResult.aggregate_champ_points + (a.userResult?.aggregate_champ_points || 0) - + (b.userResult?.aggregate_champ_points || 0) ) .pop(); if (bestUserResult) { From 7ad58f67b46d9f4ff02b239bb855c4fd3548f7e1 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 10:41:03 -0500 Subject: [PATCH 13/15] Correct type errors within Subsession pages --- src/pages/subsession/[id].astro | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pages/subsession/[id].astro b/src/pages/subsession/[id].astro index 43cf724..a441df5 100644 --- a/src/pages/subsession/[id].astro +++ b/src/pages/subsession/[id].astro @@ -47,13 +47,11 @@ const splitRaceResults = raceResults.find((result) => result.simsession_name.match(/HEAT/i) ) ? raceResults.reduce( - (object, raceResult) => { + (object: Record>, raceResult) => { const { simsession_name } = raceResult; if (simsession_name.match(/HEAT/i)) { - // @ts-ignore object.heatResults.push(raceResult); } else { - // @ts-ignore object.mainResults.push(raceResult); } return object; @@ -82,16 +80,12 @@ if (heatResults.length && mainResults.length) { session_results.push( ...[ { - // @ts-ignore simsession_type_name: heatResultOne?.simsession_type_name || "Race", - // @ts-ignore simsession_name: heatResultOne?.simsession_name || "HEAT", results: heatResults, }, { - // @ts-ignore simsession_type_name: mainResultOne?.simsession_type_name || "Race", - // @ts-ignore simsession_name: mainResultOne?.simsession_name || "RACE", results: mainResults, }, From 45110b511066c989a188cd5805d5bfb2490e775b Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 10:41:28 -0500 Subject: [PATCH 14/15] Format file and correct type errors db/seed.ts --- db/seed.ts | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/db/seed.ts b/db/seed.ts index c352fe0..3a8bcc5 100644 --- a/db/seed.ts +++ b/db/seed.ts @@ -22,17 +22,22 @@ async function paginatedQuery( const size = 100; const count = await collection.countDocuments({}); const batches = Math.ceil(count / size); - const results = await Promise.all(Array(batches) - .fill({}) - .map((_, index) => { - console.log(`Processing batch ${index + 1} of ${batches} for ${collection.collectionName}...`) - return collection - .find({}) - .skip(index * size) - .limit(size) - .toArray() - } - )); + const results = await Promise.all( + Array(batches) + .fill({}) + .map((_, index) => { + console.log( + `Processing batch ${index + 1} of ${batches} for ${ + collection.collectionName + }...` + ); + return collection + .find({}) + .skip(index * size) + .limit(size) + .toArray(); + }) + ); return results.flat(); } @@ -122,7 +127,9 @@ export default async function seed() { console.log("Past Seasons Seeded!"); const subsessionsCollection = mongoDb.collection("subsessions"); // @ts-ignore - const subsessions: Array = await paginatedQuery(subsessionsCollection); + const subsessions: Array = await paginatedQuery( + subsessionsCollection + ); console.log("Seeding Subsessions..."); const { allPracticeResults, @@ -130,7 +137,8 @@ export default async function seed() { allRaceResults, allSubsessions, } = subsessions.reduce( - (object, subsession) => { + // @todo Provide an accurate type for the unknown here + (object: Record>, subsession) => { const { _id, session_results, end_time, start_time, ...rest } = subsession; session_results.forEach((sessionResult) => { @@ -142,18 +150,14 @@ export default async function seed() { ...rest, }; if (rest.simsession_type_name.match("Practice")) { - // @ts-ignore object.allPracticeResults.push(resultWithSession); } else if (rest.simsession_type_name.match("Qualifying")) { - // @ts-ignore object.allQualifyingResults.push(resultWithSession); } else if (rest.simsession_type_name.match("Race")) { - // @ts-ignore object.allRaceResults.push(resultWithSession); } }); }); - // @ts-ignore object.allSubsessions.push({ ...rest, end_time: new Date(end_time), From c4d99824b040156590a56974c1ad0e396d661a0c Mon Sep 17 00:00:00 2001 From: Shinsina Date: Thu, 18 Apr 2024 10:43:52 -0500 Subject: [PATCH 15/15] Correct reduce type inference to appropriate type --- src/pages/shared-subsessions.astro | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/shared-subsessions.astro b/src/pages/shared-subsessions.astro index fccd217..ab65b00 100644 --- a/src/pages/shared-subsessions.astro +++ b/src/pages/shared-subsessions.astro @@ -173,10 +173,8 @@ const description = "Shared subsessions for all Stat 'n' Track users";
{ - //@ts-expect-error + results.reduce((object: Record, result) => { object.previouslyToggled = ""; - //@ts-expect-error object[`toggle${result.subsessionInfo.subsession_id}`] = false; return object; }, {})