Compare commits
34 Commits
707ba0f156
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
7434165ab0
|
|||
|
cae1457081
|
|||
|
0afc4c2e80
|
|||
|
b58ed8e0f0
|
|||
|
9ff333f90e
|
|||
| d31c6b6735 | |||
| cb48ee68e5 | |||
| f3c75fc921 | |||
| eb0de24754 | |||
| 5adc05e1bb | |||
| f049805124 | |||
| e4be7c4830 | |||
| f0950d3241 | |||
| 454b77e778 | |||
| 35c0003159 | |||
| 5a6156adb7 | |||
| c14958e5bf | |||
| 9d6e4e1b0b | |||
| f5d8f56330 | |||
| 3ca967591e | |||
| 6e6ce020a3 | |||
| d54ee01227 | |||
| 3339ffaa5f | |||
| 78ee291795 | |||
| 77895d9057 | |||
| 0cd87c6222 | |||
| 59ece62947 | |||
| 9cabe902a0 | |||
| c8016509ea | |||
| 82941d4a2a | |||
| a9ac49f6fa | |||
| 0cd4129a6e | |||
| eeae9fea6e | |||
| 35af66c222 |
@ -20,6 +20,6 @@ jobs:
|
||||
username: ${{ secrets.CONTAINER_REGISTRY_USER }}
|
||||
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
|
||||
- name: Build Pocketbase Docker Image
|
||||
run: docker build --build-arg PB_VERSION=0.25.0 --file pocketbase.dockerfile --tag gitea.vps.chriphost.de/christoph/pocketbase:0.25.0 .
|
||||
run: docker build --build-arg PB_VERSION=0.33.0 --file pocketbase.dockerfile --tag gitea.vps.chriphost.de/christoph/pocketbase:0.33.0 .
|
||||
- name: Push Pocketbase Docker Image
|
||||
run: docker push gitea.vps.chriphost.de/christoph/pocketbase:0.25.0
|
||||
run: docker push gitea.vps.chriphost.de/christoph/pocketbase:0.33.0
|
||||
|
||||
120
flake.lock
generated
120
flake.lock
generated
@ -1,8 +1,33 @@
|
||||
{
|
||||
"nodes": {
|
||||
"clj-nix": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"nix-fetcher-data": "nix-fetcher-data",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763549559,
|
||||
"narHash": "sha256-w7qhicMuDyfm9/dJKs5+47XqhZmGXRfkZjyn8XjO+c0=",
|
||||
"owner": "jlesquembre",
|
||||
"repo": "clj-nix",
|
||||
"rev": "a55b9fbce3da4aa35c94221f76d40c79e6de4d81",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "jlesquembre",
|
||||
"repo": "clj-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": [
|
||||
"clj-nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1741473158,
|
||||
@ -18,6 +43,24 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719745305,
|
||||
"narHash": "sha256-xwgjVUpqSviudEkpQnioeez1Uo2wzrsMaJKJClh+Bls=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c3c5ecc05edc7dafba779c6c1a61cd08ac6583e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
@ -36,43 +79,80 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"nix-fetcher-data": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": [
|
||||
"clj-nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722073938,
|
||||
"narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
|
||||
"lastModified": 1728229178,
|
||||
"narHash": "sha256-p5Fx880uBYstIsbaDYN7sECJT11oHxZQKtHgMAVblWA=",
|
||||
"owner": "jlesquembre",
|
||||
"repo": "nix-fetcher-data",
|
||||
"rev": "f3a73c34d28db49ef90fd7872a142bfe93120e55",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"owner": "jlesquembre",
|
||||
"repo": "nix-fetcher-data",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1741865919,
|
||||
"narHash": "sha256-4thdbnP6dlbdq+qZWTsm4ffAwoS8Tiq1YResB+RP6WE=",
|
||||
"lastModified": 1763618868,
|
||||
"narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "573c650e8a14b2faa0041645ab18aed7e60f0c9a",
|
||||
"rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1717284937,
|
||||
"narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"clj-nix": "clj-nix",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763865987,
|
||||
"narHash": "sha256-DJpzM8Jz3B0azJcAoF+YFHr8rEbxYLJ0wy1kWZ29HOw=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "042d905c01a6eec3bcae8530dacb19cda9758a63",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
||||
395
flake.nix
395
flake.nix
@ -1,114 +1,329 @@
|
||||
{
|
||||
description = "Svelte F1 Guessgame";
|
||||
rec {
|
||||
description = "Formula11";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.devshell.url = "github:numtide/devshell";
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs"; # Use nixpkgs from system registry
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
clj-nix.url = "github:jlesquembre/clj-nix";
|
||||
clj-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
devshell,
|
||||
rust-overlay,
|
||||
clj-nix,
|
||||
}:
|
||||
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
overlays = [devshell.overlays.default];
|
||||
};
|
||||
|
||||
timple = pkgs.python312Packages.buildPythonPackage rec {
|
||||
pname = "timple";
|
||||
version = "0.1.8";
|
||||
|
||||
src = pkgs.python312Packages.fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-u8EgMA8BA6OpPlSg0ASRxLcIcv5psRIEcBpIicagXw8=";
|
||||
};
|
||||
|
||||
doCheck = false;
|
||||
pyproject = true;
|
||||
|
||||
# Build time deps
|
||||
nativeBuildInputs = with pkgs.python312Packages; [
|
||||
setuptools
|
||||
];
|
||||
|
||||
# Run time deps
|
||||
dependencies = with pkgs.python312Packages; [
|
||||
matplotlib
|
||||
numpy
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
];
|
||||
};
|
||||
inherit (pkgs) lib stdenv;
|
||||
|
||||
fastf1 = pkgs.python312Packages.buildPythonPackage rec {
|
||||
pname = "fastf1";
|
||||
version = "3.4.4";
|
||||
# ===========================================================================================
|
||||
# Define custom dependencies
|
||||
# ===========================================================================================
|
||||
|
||||
src = pkgs.python312Packages.fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-nELQtvzlLsUYyVaPe1KqvMmzHy5l5W7u1I6m8r8md/4=";
|
||||
};
|
||||
# Python package example
|
||||
# typed-ffmpeg = pkgs.python313Packages.buildPythonPackage rec {
|
||||
# pname = "typed_ffmpeg";
|
||||
# version = "3.6";
|
||||
#
|
||||
# src = pkgs.python313Packages.fetchPypi {
|
||||
# inherit pname version;
|
||||
# hash = "sha256-YPspq/lqI/jx/9FCQntmQPw4lrPIsdxtHTUg0F0QbrM=";
|
||||
# };
|
||||
#
|
||||
# pyproject = true;
|
||||
# build-system = [
|
||||
# pkgs.python313Packages.setuptools
|
||||
# pkgs.python313Packages.setuptools-scm
|
||||
# ];
|
||||
# };
|
||||
|
||||
doCheck = false;
|
||||
pyproject = true;
|
||||
# python = pkgs.python313.withPackages (p:
|
||||
# with p; [
|
||||
# # numpy
|
||||
# # matplotlib
|
||||
# # typed-ffmpeg
|
||||
# # pyside6
|
||||
# ]);
|
||||
|
||||
# Build time deps
|
||||
nativeBuildInputs = with pkgs.python312Packages; [
|
||||
hatchling
|
||||
hatch-vcs
|
||||
];
|
||||
# rust = pkgs.rust-bin.stable.latest.default.override {
|
||||
# extensions = ["rust-src"]; # Include the Rust stdlib source (for IntelliJ)
|
||||
# };
|
||||
|
||||
# Run time deps
|
||||
dependencies = with pkgs.python312Packages; [
|
||||
matplotlib
|
||||
numpy
|
||||
pandas
|
||||
python-dateutil
|
||||
requests
|
||||
requests-cache
|
||||
scipy
|
||||
rapidfuzz
|
||||
websockets
|
||||
timple
|
||||
];
|
||||
};
|
||||
in {
|
||||
devShell = pkgs.devshell.mkShell {
|
||||
name = "Formula11";
|
||||
# 64 bit C/C++ compilers that don't collide (use the same libc)
|
||||
# bintools = pkgs.wrapBintoolsWith {
|
||||
# bintools = pkgs.bintools.bintools; # Unwrapped bintools
|
||||
# libc = pkgs.glibc;
|
||||
# };
|
||||
# gcc = pkgs.hiPrio (pkgs.wrapCCWith {
|
||||
# cc = pkgs.gcc.cc; # Unwrapped gcc
|
||||
# libc = pkgs.glibc;
|
||||
# bintools = bintools;
|
||||
# });
|
||||
# clang = pkgs.wrapCCWith {
|
||||
# cc = pkgs.clang.cc; # Unwrapped clang
|
||||
# libc = pkgs.glibc;
|
||||
# bintools = bintools;
|
||||
# };
|
||||
|
||||
packages = with pkgs; [
|
||||
nodejs_23
|
||||
pocketbase
|
||||
# Multilib C/C++ compilers that don't collide (use the same libc)
|
||||
# bintools_multilib = pkgs.wrapBintoolsWith {
|
||||
# bintools = pkgs.bintools.bintools; # Unwrapped bintools
|
||||
# libc = pkgs.glibc_multi;
|
||||
# };
|
||||
# gcc_multilib = pkgs.hiPrio (pkgs.wrapCCWith {
|
||||
# cc = pkgs.gcc.cc; # Unwrapped gcc
|
||||
# libc = pkgs.glibc_multi;
|
||||
# bintools = bintools_multilib;
|
||||
# });
|
||||
# clang_multilib = pkgs.wrapCCWith {
|
||||
# cc = pkgs.clang.cc; # Unwrapped clang
|
||||
# libc = pkgs.glibc_multi;
|
||||
# bintools = bintools_multilib;
|
||||
# };
|
||||
|
||||
sqlite # For sqlite console
|
||||
sqlitebrowser # To check low-level pocketbase data
|
||||
];
|
||||
# ===========================================================================================
|
||||
# Specify dependencies
|
||||
# https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview
|
||||
# Just for a "nix develop" shell, buildInputs can be used for everything.
|
||||
# ===========================================================================================
|
||||
|
||||
# Use $1 for positional args
|
||||
commands = [
|
||||
{
|
||||
name = "pb";
|
||||
help = "Serve PocketBase";
|
||||
command = "pocketbase serve --http 192.168.86.50:8090 --dev";
|
||||
}
|
||||
{
|
||||
name = "dev";
|
||||
help = "Serve Formula 11 (Dev)";
|
||||
command = "npm run dev -- --host --port 5173";
|
||||
}
|
||||
{
|
||||
name = "prod";
|
||||
help = "Serve Formula 11 (Prod)";
|
||||
command = "npm run build && npm run preview -- --host --port 5173";
|
||||
}
|
||||
{
|
||||
name = "check";
|
||||
help = "Continuously monitor for SvelteKit issues";
|
||||
command = "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch";
|
||||
}
|
||||
];
|
||||
# Add dependencies to nativeBuildInputs if they are executed during the build:
|
||||
# - Those which are needed on $PATH during the build, for example cmake and pkg-config
|
||||
# - Setup hooks, for example makeWrapper
|
||||
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs_24
|
||||
pocketbase
|
||||
|
||||
sqlite # For sqlite console
|
||||
sqlitebrowser # To check low-level pocketbase data
|
||||
|
||||
# Languages:
|
||||
# python
|
||||
# rust
|
||||
# bintools
|
||||
# gcc
|
||||
# clang
|
||||
# bintools_multilib
|
||||
# gcc_multilib
|
||||
# clang_multilib
|
||||
# clojure
|
||||
# jdk
|
||||
|
||||
# C/C++:
|
||||
# gdb
|
||||
# valgrind
|
||||
# gnumake
|
||||
# cmake
|
||||
# pkg-config
|
||||
|
||||
# Clojure:
|
||||
# leiningen
|
||||
# clj-nix.packages.${system}.deps-lock
|
||||
|
||||
# Java:
|
||||
# gradle
|
||||
|
||||
# Python:
|
||||
# hatch
|
||||
# py-spy
|
||||
|
||||
# Qt:
|
||||
# qt6.wrapQtAppsHook # For the shellHook
|
||||
];
|
||||
|
||||
# Add dependencies to buildInputs if they will end up copied or linked into the final output or otherwise used at runtime:
|
||||
# - Libraries used by compilers, for example zlib
|
||||
# - Interpreters needed by patchShebangs for scripts which are installed, which can be the case for e.g. perl
|
||||
buildInputs = with pkgs; [
|
||||
# C/C++:
|
||||
# boost
|
||||
# sfml
|
||||
|
||||
# Qt:
|
||||
# qt6.qtbase
|
||||
# qt6.full
|
||||
];
|
||||
# ===========================================================================================
|
||||
# Define buildable + installable packages
|
||||
# ===========================================================================================
|
||||
# package = stdenv.mkDerivation {
|
||||
# inherit nativeBuildInputs buildInputs;
|
||||
# pname = "";
|
||||
# version = "1.0.0";
|
||||
# src = ./.;
|
||||
#
|
||||
# installPhase = ''
|
||||
# mkdir -p $out/bin
|
||||
# mv ./BINARY $out/bin
|
||||
# '';
|
||||
# };
|
||||
# package = clj-nix.lib.mkCljApp {
|
||||
# inherit pkgs;
|
||||
# modules = [
|
||||
# # Option list: https://jlesquembre.github.io/clj-nix/options/
|
||||
# {
|
||||
# name = "";
|
||||
# version = "1.0.0";
|
||||
# main-ns = "";
|
||||
# projectSrc = ./.;
|
||||
# withLeiningen = true;
|
||||
# buildCommand = "lein uberjar"; # Requires "withLeiningen = true;"
|
||||
# jdk = pkgs.jdk; # Default is pkgs.jdk_headless
|
||||
# # customJdk.enable = true;
|
||||
# # nativeImage.enable = true;
|
||||
# }
|
||||
# ];
|
||||
# };
|
||||
in rec {
|
||||
# Provide package for "nix build"
|
||||
# defaultPackage = package;
|
||||
# defaultApp = flake-utils.lib.mkApp {
|
||||
# drv = defaultPackage;
|
||||
# };
|
||||
|
||||
# Provide environment for "nix develop"
|
||||
devShell = pkgs.mkShell {
|
||||
inherit nativeBuildInputs buildInputs;
|
||||
name = description;
|
||||
|
||||
# =========================================================================================
|
||||
# Define environment variables
|
||||
# =========================================================================================
|
||||
|
||||
# Rust stdlib source:
|
||||
# RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
||||
|
||||
# Custom dynamic libraries:
|
||||
# LD_LIBRARY_PATH = builtins.concatStringsSep ":" [
|
||||
# # Rust Bevy GUI app:
|
||||
# # "${pkgs.xorg.libX11}/lib"
|
||||
# # "${pkgs.xorg.libXcursor}/lib"
|
||||
# # "${pkgs.xorg.libXrandr}/lib"
|
||||
# # "${pkgs.xorg.libXi}/lib"
|
||||
# # "${pkgs.libGL}/lib"
|
||||
#
|
||||
# # JavaFX app:
|
||||
# # "${pkgs.libGL}/lib"
|
||||
# # "${pkgs.gtk3}/lib"
|
||||
# # "${pkgs.glib.out}/lib"
|
||||
# # "${pkgs.xorg.libXtst}/lib"
|
||||
# ];
|
||||
|
||||
# Dynamic libraries from buildinputs:
|
||||
# LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
||||
|
||||
# QT imports to use with "qmlls -E"
|
||||
# QML_IMPORT_PATH = "${pkgs.qt6.full}/lib/qt-6/qml";
|
||||
|
||||
# Set PYTHONPATH
|
||||
# PYTHONPATH = ".";
|
||||
|
||||
# Set matplotlib backend
|
||||
# MPLBACKEND = "TkAgg";
|
||||
|
||||
# =========================================================================================
|
||||
# Define shell environment
|
||||
# =========================================================================================
|
||||
|
||||
# Setup the shell when entering the "nix develop" environment (bash script).
|
||||
shellHook = let
|
||||
mkCmakeScript = type: let
|
||||
typeLower = lib.toLower type;
|
||||
in
|
||||
pkgs.writers.writeFish "cmake-${typeLower}.fish" ''
|
||||
cd $FLAKE_PROJECT_ROOT
|
||||
|
||||
echo "Removing build directory ./cmake-build-${typeLower}/"
|
||||
rm -rf ./cmake-build-${typeLower}
|
||||
|
||||
echo "Creating build directory"
|
||||
mkdir cmake-build-${typeLower}
|
||||
cd cmake-build-${typeLower}
|
||||
|
||||
echo "Running cmake"
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="${type}" -DCMAKE_EXPORT_COMPILE_COMMANDS="On" ..
|
||||
|
||||
echo "Linking compile_commands.json"
|
||||
cd ..
|
||||
ln -sf ./cmake-build-${typeLower}/compile_commands.json ./compile_commands.json
|
||||
'';
|
||||
|
||||
cmakeDebug = mkCmakeScript "Debug";
|
||||
cmakeRelease = mkCmakeScript "Release";
|
||||
|
||||
mkBuildScript = type: let
|
||||
typeLower = lib.toLower type;
|
||||
in
|
||||
pkgs.writers.writeFish "cmake-build.fish" ''
|
||||
cd $FLAKE_PROJECT_ROOT/cmake-build-${typeLower}
|
||||
|
||||
echo "Running cmake"
|
||||
cmake --build .
|
||||
'';
|
||||
|
||||
buildDebug = mkBuildScript "Debug";
|
||||
buildRelease = mkBuildScript "Release";
|
||||
|
||||
# Use this to specify commands that should be ran after entering fish shell
|
||||
initProjectShell = pkgs.writers.writeFish "init-shell.fish" ''
|
||||
echo "Entering \"${description}\" environment..."
|
||||
|
||||
# Determine the project root, used e.g. in cmake scripts
|
||||
set -g -x FLAKE_PROJECT_ROOT (git rev-parse --show-toplevel)
|
||||
|
||||
# Rust Bevy:
|
||||
# abbr -a build-release-windows "CARGO_FEATURE_PURE=1 cargo xwin build --release --target x86_64-pc-windows-msvc"
|
||||
|
||||
# C/C++:
|
||||
# abbr -a cmake-debug "${cmakeDebug}"
|
||||
# abbr -a cmake-release "${cmakeRelease}"
|
||||
# abbr -a build-debug "${buildDebug}"
|
||||
# abbr -a build-release "${buildRelease}"
|
||||
|
||||
# Clojure:
|
||||
# abbr -a clojure-deps "deps-lock --lein"
|
||||
|
||||
# Python:
|
||||
# abbr -a run "python ./app/main.py"
|
||||
# abbr -a profile "py-spy record -o profile.svg -- python ./app/main.py && firefox profile.svg"
|
||||
# abbr -a ptop "py-spy top -- python ./app/main.py"
|
||||
|
||||
# Formula11:
|
||||
abbr -a pb "pocketbase serve --http 192.168.86.50:8090 --dev"
|
||||
abbr -a dev "npm run dev -- --host --port 5173"
|
||||
abbr -a prod "npm run build && npm run preview -- --host --port 5173"
|
||||
abbr -a check "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
'';
|
||||
in
|
||||
builtins.concatStringsSep "\n" [
|
||||
# Launch into pure fish shell
|
||||
''
|
||||
exec "$(type -p fish)" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
||||
''
|
||||
|
||||
# Qt: Launch into wrapped fish shell
|
||||
# https://nixos.org/manual/nixpkgs/stable/#sec-language-qt
|
||||
# ''
|
||||
# fishdir=$(mktemp -d)
|
||||
# makeWrapper "$(type -p fish)" "$fishdir/fish" "''${qtWrapperArgs[@]}"
|
||||
# exec "$fishdir/fish" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
||||
# ''
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
1036
package-lock.json
generated
1036
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@carbon/charts-svelte": "^1.22.18",
|
||||
"@floating-ui/dom": "^1.6.13",
|
||||
"@fsouza/prettierd": "^0.26.1",
|
||||
"@skeletonlabs/skeleton": "^2.10.4",
|
||||
|
||||
650
pb_schema.json
650
pb_schema.json
@ -165,7 +165,7 @@
|
||||
"enabled": false,
|
||||
"emailTemplate": {
|
||||
"subject": "Login from a new location",
|
||||
"body": "<p>Hello,</p>\n<p>We noticed a login to your {APP_NAME} account from a new location.</p>\n<p>If this was you, you may disregard this email.</p>\n<p><strong>If this wasn't you, you should immediately change your {APP_NAME} account password to revoke access from all other locations.</strong></p>\n<p>\n Thanks,<br/>\n {APP_NAME} team\n</p>"
|
||||
"body": "<p>Hello,</p>\n<p>We noticed a login to your {APP_NAME} account from a new location:</p>\n<p><em>{ALERT_INFO}</em></p>\n<p><strong>If this wasn't you, you should immediately change your {APP_NAME} account password to revoke access from all other locations.</strong></p>\n<p>If this was you, you may disregard this email.</p>\n<p>\n Thanks,<br/>\n {APP_NAME} team\n</p>"
|
||||
}
|
||||
},
|
||||
"oauth2": {
|
||||
@ -725,6 +725,15 @@
|
||||
"system": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "bool3136797097",
|
||||
"name": "started_active",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"hidden": true,
|
||||
"id": "autodate2990389176",
|
||||
@ -747,7 +756,7 @@
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE UNIQUE INDEX `idx_AK9arhApMx` ON `drivers` (`code`)"
|
||||
"CREATE UNIQUE INDEX `idx_ChY3iWmGqf` ON `drivers` (\n `code`,\n `team`\n)"
|
||||
],
|
||||
"system": false
|
||||
},
|
||||
@ -976,10 +985,10 @@
|
||||
"hidden": false,
|
||||
"id": "relation1047762192",
|
||||
"maxSelect": 7,
|
||||
"minSelect": 7,
|
||||
"minSelect": 0,
|
||||
"name": "pxxs",
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
@ -1171,6 +1180,396 @@
|
||||
],
|
||||
"system": false
|
||||
},
|
||||
{
|
||||
"id": "pbc_3023263128",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "scraped_driverstandings",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2428491277",
|
||||
"max": 3,
|
||||
"min": 3,
|
||||
"name": "driver_code",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number1177347317",
|
||||
"max": null,
|
||||
"min": 1,
|
||||
"name": "position",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number666537513",
|
||||
"max": null,
|
||||
"min": 0,
|
||||
"name": "points",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"system": false
|
||||
},
|
||||
{
|
||||
"id": "pbc_2182053151",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "scraped_raceresults",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number516222579",
|
||||
"max": 24,
|
||||
"min": 1,
|
||||
"name": "race_step",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3112802451",
|
||||
"max": 3,
|
||||
"min": 3,
|
||||
"name": "driver_code",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number1177347317",
|
||||
"max": null,
|
||||
"min": 1,
|
||||
"name": "position",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2063623452",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "status",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number666537513",
|
||||
"max": null,
|
||||
"min": 0,
|
||||
"name": "points",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE UNIQUE INDEX `idx_JT8bhbV2YG` ON `scraped_raceresults` (\n `race_step`,\n `driver_code`\n)",
|
||||
"CREATE UNIQUE INDEX `idx_hFngwBjU8j` ON `scraped_raceresults` (\n `race_step`,\n `position`\n)"
|
||||
],
|
||||
"system": false
|
||||
},
|
||||
{
|
||||
"id": "pbc_2435909571",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "scraped_startinggrids",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number516222579",
|
||||
"max": 24,
|
||||
"min": 1,
|
||||
"name": "race_step",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2428491277",
|
||||
"max": 3,
|
||||
"min": 3,
|
||||
"name": "driver_code",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number1177347317",
|
||||
"max": 20,
|
||||
"min": 1,
|
||||
"name": "position",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1872009285",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "time",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": true,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": true,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE UNIQUE INDEX `idx_QPaZOui4P1` ON `scraped_startinggrids` (\n `race_step`,\n `driver_code`\n)",
|
||||
"CREATE UNIQUE INDEX `idx_1bfQwZkKBX` ON `scraped_startinggrids` (\n `race_step`,\n `position`\n)"
|
||||
],
|
||||
"system": false
|
||||
},
|
||||
{
|
||||
"id": "pbc_286850423",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "scraped_teamstandings",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text690463184",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "team_fullname",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number1177347317",
|
||||
"max": 10,
|
||||
"min": 1,
|
||||
"name": "position",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number666537513",
|
||||
"max": null,
|
||||
"min": 0,
|
||||
"name": "points",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"system": false
|
||||
},
|
||||
{
|
||||
"id": "pbc_1473742649",
|
||||
"listRule": "@request.auth.id != \"\" // If you know what you're doing you can easily request all picks here. But If I restrict this to the current user, the subscription events are blocked...",
|
||||
@ -1565,7 +1964,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_E3yC",
|
||||
"id": "_clone_8Abk",
|
||||
"max": 10,
|
||||
"min": 3,
|
||||
"name": "username",
|
||||
@ -1579,7 +1978,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_wfxT",
|
||||
"id": "_clone_s6Vb",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "firstname",
|
||||
@ -1592,7 +1991,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_bgsF",
|
||||
"id": "_clone_3shc",
|
||||
"maxSelect": 1,
|
||||
"maxSize": 0,
|
||||
"mimeTypes": [
|
||||
@ -1608,7 +2007,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_r1JL",
|
||||
"id": "_clone_Phc6",
|
||||
"name": "admin",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
@ -1657,7 +2056,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_wBWE",
|
||||
"id": "_clone_Lqek",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "name",
|
||||
@ -1670,7 +2069,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_GAG5",
|
||||
"id": "_clone_74gl",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "step",
|
||||
@ -1682,7 +2081,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_jqcN",
|
||||
"id": "_clone_XSiN",
|
||||
"maxSelect": 1,
|
||||
"maxSize": 0,
|
||||
"mimeTypes": [
|
||||
@ -1698,7 +2097,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_BRqQ",
|
||||
"id": "_clone_Dt5c",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "pxx",
|
||||
@ -1710,7 +2109,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_PftQ",
|
||||
"id": "_clone_DjBN",
|
||||
"max": "",
|
||||
"min": "",
|
||||
"name": "sprintqualidate",
|
||||
@ -1721,7 +2120,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_wSrB",
|
||||
"id": "_clone_9JoH",
|
||||
"max": "",
|
||||
"min": "",
|
||||
"name": "sprintdate",
|
||||
@ -1732,7 +2131,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_NFx9",
|
||||
"id": "_clone_3g96",
|
||||
"max": "",
|
||||
"min": "",
|
||||
"name": "qualidate",
|
||||
@ -1743,7 +2142,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_YYyB",
|
||||
"id": "_clone_ikdE",
|
||||
"max": "",
|
||||
"min": "",
|
||||
"name": "racedate",
|
||||
@ -1785,7 +2184,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1736455494",
|
||||
"hidden": false,
|
||||
"id": "_clone_US3n",
|
||||
"id": "_clone_m714",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user",
|
||||
@ -1797,7 +2196,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_5Ma5",
|
||||
"id": "_clone_kDMs",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "hottake",
|
||||
@ -1841,7 +2240,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1736455494",
|
||||
"hidden": false,
|
||||
"id": "_clone_KXD4",
|
||||
"id": "_clone_jTU8",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user",
|
||||
@ -1852,7 +2251,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_pUep",
|
||||
"id": "_clone_VwLb",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "step",
|
||||
@ -1885,10 +2284,10 @@
|
||||
],
|
||||
"indexes": [],
|
||||
"system": false,
|
||||
"viewQuery": "SELECT\n rp.id,\n rp.user,\n -- rp.race,\n r.step,\n \n -- rp.pxx,\n -- rr.pxxs,\n (CASE\n -- Correct pxx pick\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[3]') THEN 10\n \n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[2]') THEN 6\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[4]') THEN 6\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[1]') THEN 3\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[5]') THEN 3\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[0]') THEN 1\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[6]') THEN 1\n \n ELSE 0 \n END) AS pxx_points,\n \n -- rp.dnf,\n -- rr.dnfs,\n (CASE\n -- Correct dnf pick with a single DNF\n WHEN rr.dnfs LIKE '[\"' || rp.dnf || '\"]' THEN 10\n \n -- Correct dnf pick with multiple DNFs\n WHEN rr.dnfs LIKE '[%,\"' || rp.dnf || '\",%]' THEN 10\n \n ELSE 0 \n END) AS dnf_points\nFROM racepicks rp\nJOIN races r ON rp.race = r.id\nJOIN raceresults rr ON rp.race = rr.race\nWHERE pxx_points > 0 OR dnf_points > 0\nORDER BY r.step ASC;"
|
||||
"viewQuery": "SELECT\n rp.id,\n rp.user,\n -- rp.race,\n r.step,\n \n -- rp.pxx,\n -- rr.pxxs,\n (CASE\n -- Correct pxx pick\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[3]') THEN 10\n \n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[2]') THEN 6\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[4]') THEN 6\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[1]') THEN 3\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[5]') THEN 3\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[0]') THEN 1\n WHEN rp.pxx = JSON_EXTRACT(rr.pxxs, '$[6]') THEN 1\n \n ELSE 0 \n END) AS pxx_points,\n \n -- rp.dnf,\n -- rr.dnfs,\n (CASE\n -- Correct dnf pick with a single DNF\n -- WHEN rr.dnfs LIKE '[\"' || rp.dnf || '\"]' THEN 10\n \n -- Correct dnf pick with single or multiple DNFs\n WHEN rr.dnfs LIKE '[%\"' || rp.dnf || '\"%]' THEN 10\n \n ELSE 0 \n END) AS dnf_points\nFROM racepicks rp\nJOIN races r ON rp.race = r.id\nJOIN raceresults rr ON rp.race = rr.race\n-- WHERE pxx_points > 0 OR dnf_points > 0\nORDER BY r.step ASC;"
|
||||
},
|
||||
{
|
||||
"id": "pbc_3585110310",
|
||||
"id": "pbc_4223880558",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
@ -1915,7 +2314,91 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1736455494",
|
||||
"hidden": false,
|
||||
"id": "_clone_khyC",
|
||||
"id": "_clone_fDe7",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user",
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_dFLq",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "step",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json1186524854",
|
||||
"maxSize": 1,
|
||||
"name": "acc_pxx_points",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json3726038982",
|
||||
"maxSize": 1,
|
||||
"name": "acc_dnf_points",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json2780867541",
|
||||
"maxSize": 1,
|
||||
"name": "acc_points",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"system": false,
|
||||
"viewQuery": "SELECT\n p.id,\n p.user,\n p.step,\n (SUM(p.pxx_points) OVER(PARTITION BY p.user ORDER BY p.step ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS acc_pxx_points,\n (SUM(p.dnf_points) OVER(PARTITION BY p.user ORDER BY p.step ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS acc_dnf_points,\n (SUM(p.pxx_points + p.dnf_points) OVER(PARTITION BY p.user ORDER BY p.step ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS acc_points\nFROM racepickpoints p\nORDER BY step ASC;"
|
||||
},
|
||||
{
|
||||
"id": "pbc_3585110310",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"name": "racepickpointstotal",
|
||||
"type": "view",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1736455494",
|
||||
"hidden": false,
|
||||
"id": "_clone_M37B",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user",
|
||||
@ -1953,11 +2436,21 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json1247457462",
|
||||
"maxSize": 1,
|
||||
"name": "total_points_per_pick",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"system": false,
|
||||
"viewQuery": "SELECT\n p.id,\n p.user,\n SUM(p.pxx_points) AS total_pxx_points,\n SUM(p.dnf_points) AS total_dnf_points,\n SUM(p.pxx_points + p.dnf_points) AS total_points\nFROM racepickpoints p\nGROUP BY user\nORDER BY total_points DESC;"
|
||||
"viewQuery": "SELECT\n p.id,\n p.user,\n SUM(p.pxx_points) AS total_pxx_points,\n SUM(p.dnf_points) AS total_dnf_points,\n SUM(p.pxx_points + p.dnf_points) AS total_points,\n (CAST(SUM(p.pxx_points + p.dnf_points) AS REAL) / COUNT(*)) AS total_points_per_pick\nFROM racepickpoints p\nGROUP BY user\nORDER BY total_points DESC;"
|
||||
},
|
||||
{
|
||||
"id": "pbc_2823555101",
|
||||
@ -1987,7 +2480,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_2533072930",
|
||||
"hidden": false,
|
||||
"id": "_clone_NX00",
|
||||
"id": "_clone_Lw6s",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "race",
|
||||
@ -2000,12 +2493,12 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_RMyl",
|
||||
"id": "_clone_dlrx",
|
||||
"maxSelect": 7,
|
||||
"minSelect": 7,
|
||||
"minSelect": 0,
|
||||
"name": "pxxs",
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
@ -2013,7 +2506,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_tWkO",
|
||||
"id": "_clone_YWtq",
|
||||
"maxSelect": 20,
|
||||
"minSelect": 0,
|
||||
"name": "dnfs",
|
||||
@ -2027,6 +2520,71 @@
|
||||
"system": false,
|
||||
"viewQuery": "-- This query simply returns the raceresults sorted by their race steps (descending).\nSELECT result.id, result.race, result.pxxs, result.dnfs\nFROM raceresults result\nJOIN races race ON result.race = race.id\nORDER BY race.step DESC;"
|
||||
},
|
||||
{
|
||||
"id": "pbc_3189024959",
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"name": "scraped_raceresultsacc",
|
||||
"type": "view",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_YEQY",
|
||||
"max": 24,
|
||||
"min": 1,
|
||||
"name": "race_step",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_lePz",
|
||||
"max": 3,
|
||||
"min": 3,
|
||||
"name": "driver_code",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json2780867541",
|
||||
"maxSize": 1,
|
||||
"name": "acc_points",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"system": false,
|
||||
"viewQuery": "SELECT\n r.id,\n r.race_step,\n r.driver_code,\n (SUM(r.points) OVER(PARTITION BY r.driver_code ORDER BY r.race_step ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS acc_points\nFROM scraped_raceresults r\nORDER BY race_step ASC;"
|
||||
},
|
||||
{
|
||||
"id": "pbc_1743016826",
|
||||
"listRule": "",
|
||||
@ -2054,7 +2612,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_ds2o",
|
||||
"id": "_clone_u2Xp",
|
||||
"max": 10,
|
||||
"min": 3,
|
||||
"name": "username",
|
||||
@ -2068,7 +2626,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_r41d",
|
||||
"id": "_clone_IGYL",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "firstname",
|
||||
@ -2081,7 +2639,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_lfEH",
|
||||
"id": "_clone_sEZH",
|
||||
"maxSelect": 1,
|
||||
"maxSize": 0,
|
||||
"mimeTypes": [
|
||||
@ -2097,7 +2655,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_2VGz",
|
||||
"id": "_clone_Aev1",
|
||||
"name": "admin",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
@ -2147,7 +2705,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1736455494",
|
||||
"hidden": false,
|
||||
"id": "_clone_7f09",
|
||||
"id": "_clone_a4Gn",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user",
|
||||
@ -2160,7 +2718,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_2533072930",
|
||||
"hidden": false,
|
||||
"id": "_clone_3gFx",
|
||||
"id": "_clone_scFa",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "race",
|
||||
@ -2173,7 +2731,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_6rnW",
|
||||
"id": "_clone_Z5l5",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "pxx",
|
||||
@ -2186,7 +2744,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_SlAh",
|
||||
"id": "_clone_0ry6",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "dnf",
|
||||
@ -2228,7 +2786,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1736455494",
|
||||
"hidden": false,
|
||||
"id": "_clone_m9pK",
|
||||
"id": "_clone_Z44W",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user",
|
||||
@ -2240,7 +2798,7 @@
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "_clone_u2R4",
|
||||
"id": "_clone_ivB8",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "hottake",
|
||||
@ -2255,7 +2813,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_g7n6",
|
||||
"id": "_clone_RgzD",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "wdcwinner",
|
||||
@ -2268,7 +2826,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1568971955",
|
||||
"hidden": false,
|
||||
"id": "_clone_i5Fn",
|
||||
"id": "_clone_nnZX",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "wccwinner",
|
||||
@ -2281,7 +2839,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_MfxF",
|
||||
"id": "_clone_wNY4",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "mostovertakes",
|
||||
@ -2294,7 +2852,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_7Y5f",
|
||||
"id": "_clone_okPh",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "mostdnfs",
|
||||
@ -2305,7 +2863,7 @@
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "_clone_09pS",
|
||||
"id": "_clone_9rOH",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "doohanstarts",
|
||||
@ -2319,7 +2877,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_MWpR",
|
||||
"id": "_clone_WZjB",
|
||||
"maxSelect": 10,
|
||||
"minSelect": 10,
|
||||
"name": "teamwinners",
|
||||
@ -2332,7 +2890,7 @@
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1967373549",
|
||||
"hidden": false,
|
||||
"id": "_clone_OOoD",
|
||||
"id": "_clone_870o",
|
||||
"maxSelect": 20,
|
||||
"minSelect": 3,
|
||||
"name": "podiums",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# because fucking Docker thinks "toomanyrequests". Fuckers
|
||||
FROM docker.io/library/alpine:3.21.2
|
||||
|
||||
ARG PB_VERSION=0.25.0
|
||||
ARG PB_VERSION=0.33.0
|
||||
|
||||
RUN apk add --no-cache \
|
||||
unzip \
|
||||
|
||||
60
src/lib/chart.ts
Normal file
60
src/lib/chart.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { type LineChartOptions, ScaleTypes } from "@carbon/charts-svelte";
|
||||
|
||||
export const make_chart_options = (
|
||||
title: string,
|
||||
bottom: string,
|
||||
left: string,
|
||||
group: string = "group",
|
||||
width: string = "100%",
|
||||
height: string = "400px",
|
||||
): LineChartOptions => {
|
||||
return {
|
||||
title: title,
|
||||
axes: {
|
||||
bottom: {
|
||||
mapsTo: bottom,
|
||||
scaleType: ScaleTypes.LABELS,
|
||||
},
|
||||
left: {
|
||||
mapsTo: left,
|
||||
scaleType: ScaleTypes.LINEAR,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
groupMapsTo: group,
|
||||
},
|
||||
curve: "curveMonotoneX",
|
||||
// toolbar: {
|
||||
// enabled: false,
|
||||
// },
|
||||
animations: true,
|
||||
// canvasZoom: {
|
||||
// enabled: false,
|
||||
// },
|
||||
grid: {
|
||||
x: {
|
||||
enabled: true,
|
||||
alignWithAxisTicks: true,
|
||||
},
|
||||
y: {
|
||||
enabled: true,
|
||||
alignWithAxisTicks: true,
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
enabled: true,
|
||||
clickable: true,
|
||||
position: "top",
|
||||
},
|
||||
points: {
|
||||
enabled: true,
|
||||
radius: 5,
|
||||
},
|
||||
tooltip: {
|
||||
showTotal: false,
|
||||
},
|
||||
resizable: true,
|
||||
width: width,
|
||||
height: height,
|
||||
};
|
||||
};
|
||||
@ -144,7 +144,7 @@
|
||||
pxxs_input = "";
|
||||
|
||||
// Manage ids that are submitted via form
|
||||
const id: string = get_by_value(drivers, "code", event.detail.value)?.id ?? "Invalid";
|
||||
const id: string = get_by_value(drivers.filter((driver: Driver) => driver.active), "code", event.detail.value)?.id ?? "Invalid";
|
||||
if (!pxxs_ids.includes(id)) {
|
||||
pxxs_ids.push(id);
|
||||
}
|
||||
@ -165,7 +165,7 @@
|
||||
dnfs_input = "";
|
||||
|
||||
// Manage ids that are submitted via form
|
||||
const id: string = get_by_value(drivers, "code", event.detail.value)?.id ?? "Invalid";
|
||||
const id: string = get_by_value(drivers.filter((driver: Driver) => driver.active), "code", event.detail.value)?.id ?? "Invalid";
|
||||
if (!dnfs_ids.includes(id)) {
|
||||
dnfs_ids.push(id);
|
||||
}
|
||||
|
||||
@ -82,6 +82,7 @@
|
||||
headshot: headshot_blob, // NOTE: Duplicates the image, but no issue for low volume
|
||||
team: team_value,
|
||||
active: true,
|
||||
started_active: false,
|
||||
};
|
||||
try {
|
||||
await pb.collection("drivers").create(new_driver_data);
|
||||
|
||||
@ -9,9 +9,12 @@ import type {
|
||||
RacePick,
|
||||
RacePickPoints,
|
||||
RacePickPointsAcc,
|
||||
RacePickPointsTotal,
|
||||
RaceResult,
|
||||
ScrapedDriverStanding,
|
||||
ScrapedRaceResult,
|
||||
ScrapedRaceResultAcc,
|
||||
ScrapedStartingGrid,
|
||||
ScrapedTeamStanding,
|
||||
SeasonPick,
|
||||
SeasonPickedUser,
|
||||
@ -281,7 +284,7 @@ export const fetch_racepickpoints = async (
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all [RacePickPointsAcc] from the database, ordered descendingly by total points.
|
||||
* Fetch all [RacePickPointsAcc] from the database, ordered ascendingly by step.
|
||||
*/
|
||||
export const fetch_racepickpointsacc = async (
|
||||
fetch: (_: any) => Promise<Response>,
|
||||
@ -293,6 +296,19 @@ export const fetch_racepickpointsacc = async (
|
||||
return racepickpointsacc;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all [RacePickPointsTotal] from the database, ordered descendingly by total points.
|
||||
*/
|
||||
export const fetch_racepickpointstotal = async (
|
||||
fetch: (_: any) => Promise<Response>,
|
||||
): Promise<RacePickPointsTotal[]> => {
|
||||
const racepickpointstotal: RacePickPointsTotal[] = await pb
|
||||
.collection("racepickpointstotal")
|
||||
.getFullList({ fetch: fetch });
|
||||
|
||||
return racepickpointstotal;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all [ScrapedDriverStandings] from the database, ordered ascendingly by position.
|
||||
*/
|
||||
@ -319,6 +335,19 @@ export const fetch_scraped_teamstandings = async (
|
||||
return scraped_teamstandings;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all [ScrapedStartingGrids] from the database, ordered descendingly by race step.
|
||||
*/
|
||||
export const fetch_scraped_startinggrids = async (
|
||||
fetch: (_: any) => Promise<Response>,
|
||||
): Promise<ScrapedStartingGrid[]> => {
|
||||
const scraped_startinggrids: ScrapedStartingGrid[] = await pb
|
||||
.collection("scraped_startinggrids")
|
||||
.getFullList({ fetch: fetch, sort: "-race_step,+position" });
|
||||
|
||||
return scraped_startinggrids;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all [ScrapedRaceResults] from the database, ordered descendingly by race step.
|
||||
*/
|
||||
@ -331,3 +360,16 @@ export const fetch_scraped_raceresults = async (
|
||||
|
||||
return scraped_raceresults;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all [ScrapedRaceResultsAcc] from the database, ordered ascendingly by race step.
|
||||
*/
|
||||
export const fetch_scraped_raceresultsacc = async (
|
||||
fetch: (_: any) => Promise<Response>,
|
||||
): Promise<ScrapedRaceResultAcc[]> => {
|
||||
const scraped_raceresultsacc: ScrapedRaceResultAcc[] = await pb
|
||||
.collection("scraped_raceresultsacc")
|
||||
.getFullList({ fetch: fetch, sort: "+race_step" });
|
||||
|
||||
return scraped_raceresultsacc;
|
||||
};
|
||||
|
||||
@ -41,6 +41,7 @@ export interface Driver {
|
||||
headshot_url?: string;
|
||||
team: string;
|
||||
active: boolean;
|
||||
started_active: boolean;
|
||||
}
|
||||
|
||||
export interface Race {
|
||||
@ -139,15 +140,33 @@ export interface RacePickPoints {
|
||||
}
|
||||
|
||||
export interface RacePickPointsAcc {
|
||||
id: string;
|
||||
user: string;
|
||||
step: number;
|
||||
acc_pxx_points: number;
|
||||
acc_dnf_points: number;
|
||||
acc_points: number;
|
||||
}
|
||||
|
||||
export interface RacePickPointsTotal {
|
||||
id: string;
|
||||
user: string;
|
||||
total_pxx_points: number;
|
||||
total_dnf_points: number;
|
||||
total_points: number;
|
||||
total_points_per_pick: number;
|
||||
}
|
||||
|
||||
// Scraped Data
|
||||
|
||||
export interface ScrapedStartingGrid {
|
||||
id: string;
|
||||
race_step: number; // This maps to races
|
||||
driver_code: string; // This maps to drivers
|
||||
position: number;
|
||||
time: string;
|
||||
}
|
||||
|
||||
export interface ScrapedRaceResult {
|
||||
id: string;
|
||||
race_step: number; // This maps to races
|
||||
@ -157,6 +176,13 @@ export interface ScrapedRaceResult {
|
||||
points: number;
|
||||
}
|
||||
|
||||
export interface ScrapedRaceResultAcc {
|
||||
id: string;
|
||||
race_step: number; // This maps to races
|
||||
driver_code: string; // This maps to drivers
|
||||
acc_points: number;
|
||||
}
|
||||
|
||||
export interface ScrapedDriverStanding {
|
||||
id: string;
|
||||
driver_code: string; // This maps to drivers
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
import type { ScrapedDriverStanding, ScrapedRaceResult, ScrapedTeamStanding } from "$lib/schema";
|
||||
import type {
|
||||
ScrapedDriverStanding,
|
||||
ScrapedStartingGrid,
|
||||
ScrapedRaceResult,
|
||||
ScrapedTeamStanding,
|
||||
} from "$lib/schema";
|
||||
import * as cheerio from "cheerio";
|
||||
|
||||
// TODO: Validate the generated stuff
|
||||
@ -16,16 +21,65 @@ export const scrape_race_links = async (): Promise<string[]> => {
|
||||
const $ = cheerio.load(races_text);
|
||||
|
||||
const race_links: string[] = [];
|
||||
$("tbody > tr > td:first-child > p > a[href]", "div.f1-inner-wrapper table.f1-table").each(
|
||||
(_, element) => {
|
||||
race_links.push(element.attribs["href"]);
|
||||
},
|
||||
);
|
||||
$("tbody > tr > td:first-child > p > a[href]", "table.f1-table").each((_, element) => {
|
||||
const href: string = element.attribs["href"];
|
||||
|
||||
// Keks changed the link format, cut off the start
|
||||
const substring: string = href.replace("/../../en/results/2025/", "");
|
||||
|
||||
race_links.push(substring);
|
||||
});
|
||||
console.log(`Found ${race_links.length} races...`);
|
||||
console.log(race_links);
|
||||
|
||||
return race_links;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of [ScrapedStartingGrids] for all races contained in [race_links],
|
||||
* based on official f1.com data.
|
||||
*/
|
||||
export const scrape_starting_grids = async (
|
||||
race_links: string[],
|
||||
): Promise<ScrapedStartingGrid[]> => {
|
||||
// Update the race_links to point to the qualifications
|
||||
const starting_grid_links: string[] = race_links.map((link: string) =>
|
||||
link.replace("/race-result", "/starting-grid"),
|
||||
);
|
||||
|
||||
const starting_grids: ScrapedStartingGrid[] = [];
|
||||
await Promise.all(
|
||||
starting_grid_links.map(async (link: string, index: number) => {
|
||||
console.log(`Fetching qualifying results from ${base_url}/${link}...`);
|
||||
const starting_grids_response = await fetch(`${base_url}/${link}`);
|
||||
const starting_grids_text = await starting_grids_response.text();
|
||||
|
||||
const $ = cheerio.load(starting_grids_text);
|
||||
|
||||
// Obtain the positions for this starting grid for each driver
|
||||
$("tbody > tr", "table.f1-table").each((driver_index, element) => {
|
||||
const $$ = cheerio.load(element);
|
||||
|
||||
let result: ScrapedStartingGrid = {
|
||||
id: "",
|
||||
race_step: index + 1,
|
||||
driver_code: $$(
|
||||
"td:nth-child(3) > p > span:first-child > span:last-child > span:last-child",
|
||||
).text(),
|
||||
position: driver_index + 1, // parseInt($$("td:nth-child(1) > p").text()),
|
||||
time: $$("td:nth-child(5) > p").text(),
|
||||
};
|
||||
|
||||
starting_grids.push(result);
|
||||
});
|
||||
}),
|
||||
);
|
||||
console.log(`Scraped ${starting_grids.length} starting grids...`);
|
||||
// console.log(starting_grids);
|
||||
|
||||
return starting_grids;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of [ScrapedRaceResults] for all races contained in [race_links],
|
||||
* based on official f1.com data.
|
||||
@ -41,13 +95,15 @@ export const scrape_race_results = async (race_links: string[]): Promise<Scraped
|
||||
const $ = cheerio.load(race_text);
|
||||
|
||||
// Obtain the results for this race for each driver
|
||||
$("tbody > tr", "div.f1-inner-wrapper table.f1-table").each((driver_index, element) => {
|
||||
$("tbody > tr", "table.f1-table").each((driver_index, element) => {
|
||||
const $$ = cheerio.load(element);
|
||||
|
||||
let result: ScrapedRaceResult = {
|
||||
id: "",
|
||||
race_step: index + 1,
|
||||
driver_code: $$("td:nth-child(3) > p > span:last-child").text(),
|
||||
driver_code: $$(
|
||||
"td:nth-child(3) > p > span:first-child > span:last-child > span:last-child",
|
||||
).text(),
|
||||
position: driver_index + 1, // parseInt($$("td:nth-child(1) > p").text()),
|
||||
status: $$("td:nth-child(6) > p").text(),
|
||||
points: parseInt($$("td:nth-child(7) > p").text()),
|
||||
@ -63,6 +119,7 @@ export const scrape_race_results = async (race_links: string[]): Promise<Scraped
|
||||
}),
|
||||
);
|
||||
console.log(`Scraped ${race_results.length} race results...`);
|
||||
// console.log(race_results);
|
||||
|
||||
return race_results;
|
||||
};
|
||||
@ -77,12 +134,12 @@ export const scrape_driver_standings = async (): Promise<ScrapedDriverStanding[]
|
||||
const $ = cheerio.load(standings_text);
|
||||
|
||||
const driver_standings: ScrapedDriverStanding[] = [];
|
||||
$("tbody > tr", "div.f1-inner-wrapper table.f1-table").each((driver_index, element) => {
|
||||
$("tbody > tr", "table.f1-table").each((driver_index, element) => {
|
||||
const $$ = cheerio.load(element);
|
||||
|
||||
let standing: ScrapedDriverStanding = {
|
||||
id: "",
|
||||
driver_code: $$("td:nth-child(2) > p > a > span:last-child").text(),
|
||||
driver_code: $$("td:nth-child(2) > p > a > span:last-child > span:last-child").text(),
|
||||
position: driver_index + 1,
|
||||
points: parseInt($$("td:nth-child(5) > p").text()),
|
||||
};
|
||||
@ -90,6 +147,7 @@ export const scrape_driver_standings = async (): Promise<ScrapedDriverStanding[]
|
||||
driver_standings.push(standing);
|
||||
});
|
||||
console.log(`Scraped ${driver_standings.length} driver standings...`);
|
||||
// console.log(driver_standings);
|
||||
|
||||
return driver_standings;
|
||||
};
|
||||
@ -104,7 +162,7 @@ export const scrape_team_standings = async (): Promise<ScrapedTeamStanding[]> =>
|
||||
const $ = cheerio.load(standings_text);
|
||||
|
||||
const team_standings: ScrapedTeamStanding[] = [];
|
||||
$("tbody > tr", "div.f1-inner-wrapper table.f1-table").each((team_index, element) => {
|
||||
$("tbody > tr", "table.f1-table").each((team_index, element) => {
|
||||
const $$ = cheerio.load(element);
|
||||
|
||||
let standing: ScrapedTeamStanding = {
|
||||
@ -117,6 +175,7 @@ export const scrape_team_standings = async (): Promise<ScrapedTeamStanding[]> =>
|
||||
team_standings.push(standing);
|
||||
});
|
||||
console.log(`Scraped ${team_standings.length} team standings...`);
|
||||
// console.log(team_standings);
|
||||
|
||||
return team_standings;
|
||||
};
|
||||
|
||||
@ -1,28 +1,63 @@
|
||||
import type { ToastSettings } from "@skeletonlabs/skeleton";
|
||||
|
||||
export const get_info_toast = (message: string, timeout: number = 2000): ToastSettings => {
|
||||
return {
|
||||
message,
|
||||
hideDismiss: true,
|
||||
timeout,
|
||||
background: "variant-filled-tertiary",
|
||||
};
|
||||
};
|
||||
export const get_info_toast = (
|
||||
message: string,
|
||||
timeout: number | null = 2000,
|
||||
action_label: string | undefined = undefined,
|
||||
action_response: (() => void) | undefined = undefined,
|
||||
): ToastSettings =>
|
||||
get_toast(message, "variant-filled-tertiary", timeout, action_label, action_response);
|
||||
|
||||
export const get_warning_toast = (message: string, timeout: number = 2000): ToastSettings => {
|
||||
return {
|
||||
message,
|
||||
hideDismiss: true,
|
||||
timeout,
|
||||
background: "variant-filled-secondary",
|
||||
};
|
||||
};
|
||||
export const get_warning_toast = (
|
||||
message: string,
|
||||
timeout: number | null = 2000,
|
||||
action_label: string | undefined = undefined,
|
||||
action_response: (() => void) | undefined = undefined,
|
||||
): ToastSettings =>
|
||||
get_toast(message, "variant-filled-secondary", timeout, action_label, action_response);
|
||||
|
||||
export const get_error_toast = (message: string, timeout: number = 2000): ToastSettings => {
|
||||
export const get_error_toast = (
|
||||
message: string,
|
||||
timeout: number | null = 2000,
|
||||
action_label: string | undefined = undefined,
|
||||
action_response: (() => void) | undefined = undefined,
|
||||
): ToastSettings =>
|
||||
get_toast(message, "variant-filled-primary", timeout, action_label, action_response);
|
||||
|
||||
/**
|
||||
* Utility function to create [ToastSettings].
|
||||
* If [timeout] is defined, the toast will disappear automatically and the dismiss-button will be hidden.
|
||||
* If [timeout] is undefined, the toast will stay until dismissed from the dismiss-button.
|
||||
* If [action_label] and [action_response] are defined, a callback function will be executed after accepting.
|
||||
* In this case, [timeout] behaves as if undefined.
|
||||
*/
|
||||
const get_toast = (
|
||||
message: string,
|
||||
background: string,
|
||||
timeout: number | null = 2000,
|
||||
action_label: string | undefined = undefined,
|
||||
action_response: (() => void) | undefined = undefined,
|
||||
): ToastSettings => {
|
||||
return {
|
||||
message,
|
||||
hideDismiss: true,
|
||||
timeout,
|
||||
background: "variant-filled-primary",
|
||||
background,
|
||||
|
||||
// If we have a timeout and no action, dismiss is hidden
|
||||
hideDismiss: !!timeout && (!action_label || !action_response),
|
||||
|
||||
// If we have a timeout and no action, the timeout is used
|
||||
timeout: !!timeout && (!action_label || !action_response) ? timeout : undefined,
|
||||
|
||||
// If we have a timeout and no action, autohide is true
|
||||
autohide: !!timeout && (!action_label || !action_response),
|
||||
|
||||
// If we have a label and a response, use the action
|
||||
action:
|
||||
!!action_label && !!action_response
|
||||
? {
|
||||
label: action_label,
|
||||
response: action_response,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
@ -329,6 +329,7 @@
|
||||
"seasonpicks",
|
||||
"substitutions",
|
||||
"teams",
|
||||
"scraped_startinggrids",
|
||||
"scraped_raceresults",
|
||||
"scraped_driverstandings",
|
||||
"scraped_teamstandings",
|
||||
@ -347,6 +348,7 @@
|
||||
"seasonpicks",
|
||||
"substitutions",
|
||||
"teams",
|
||||
"scraped_startinggrids",
|
||||
"scraped_raceresults",
|
||||
"scraped_driverstandings",
|
||||
"scraped_teamstandings",
|
||||
|
||||
@ -1,14 +1,21 @@
|
||||
import {
|
||||
fetch_scraped_driverstandings,
|
||||
fetch_scraped_raceresults,
|
||||
fetch_scraped_startinggrids,
|
||||
fetch_scraped_teamstandings,
|
||||
} from "$lib/fetch";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import type { ScrapedDriverStanding, ScrapedRaceResult, ScrapedTeamStanding } from "$lib/schema";
|
||||
import type {
|
||||
ScrapedDriverStanding,
|
||||
ScrapedRaceResult,
|
||||
ScrapedStartingGrid,
|
||||
ScrapedTeamStanding,
|
||||
} from "$lib/schema";
|
||||
import {
|
||||
scrape_driver_standings,
|
||||
scrape_race_links,
|
||||
scrape_race_results,
|
||||
scrape_starting_grids,
|
||||
scrape_team_standings,
|
||||
} from "$lib/server/scrape";
|
||||
import type { RequestHandler } from "./$types";
|
||||
@ -24,12 +31,27 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
|
||||
// Obtain the results for each race
|
||||
const racelinks: string[] = await scrape_race_links();
|
||||
const startinggrids: ScrapedStartingGrid[] = await scrape_starting_grids(racelinks);
|
||||
const raceresults: ScrapedRaceResult[] = await scrape_race_results(racelinks);
|
||||
const driverstandings: ScrapedDriverStanding[] = await scrape_driver_standings();
|
||||
const teamstandings: ScrapedTeamStanding[] = await scrape_team_standings();
|
||||
|
||||
// Clear existing PocketBase data
|
||||
// TODO: Do I really have to fetch everything just to delete it???
|
||||
let deleted: number = 0;
|
||||
const scraped_startinggrids: ScrapedStartingGrid[] = await fetch_scraped_startinggrids(fetch);
|
||||
for (const grid of scraped_startinggrids) {
|
||||
try {
|
||||
await pb.collection("scraped_startinggrids").delete(grid.id);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return new Response(); // TODO: Return error
|
||||
}
|
||||
deleted++;
|
||||
}
|
||||
console.log(`Deleted ${deleted}/${scraped_startinggrids.length} starting grids`);
|
||||
|
||||
deleted = 0;
|
||||
const scraped_raceresults: ScrapedRaceResult[] = await fetch_scraped_raceresults(fetch);
|
||||
for (const result of scraped_raceresults) {
|
||||
try {
|
||||
@ -71,6 +93,23 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
|
||||
// Submit new data to PocketBase
|
||||
let submissions: number = 0;
|
||||
for (const grid of startinggrids) {
|
||||
try {
|
||||
// TODO: Authenticate this
|
||||
await pb.collection("scraped_startinggrids").create(grid);
|
||||
} catch (e) {
|
||||
console.log("Error occured while submitting scraped data to PocketBase:");
|
||||
console.log(e);
|
||||
console.log("Error occured for this starting grid:");
|
||||
console.log(grid);
|
||||
console.log("Aborting submissions...");
|
||||
return new Response(); // TODO: Return error
|
||||
}
|
||||
submissions++;
|
||||
}
|
||||
console.log(`Submitted ${submissions}/${startinggrids.length} starting grids.`);
|
||||
|
||||
submissions = 0;
|
||||
for (const result of raceresults) {
|
||||
try {
|
||||
// TODO: Authenticate this
|
||||
|
||||
@ -1,12 +1,32 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from "$app/navigation";
|
||||
import { Button } from "$lib/components";
|
||||
import { pbUser } from "$lib/pocketbase";
|
||||
import { get_error_toast, get_warning_toast } from "$lib/toast";
|
||||
import { getToastStore, type ToastStore } from "@skeletonlabs/skeleton";
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
let { children }: { children: Snippet } = $props();
|
||||
|
||||
const scrape_official_data = async () => {
|
||||
// TODO: Success/error toast
|
||||
const toastStore: ToastStore = getToastStore();
|
||||
|
||||
const scrape_message: string =
|
||||
"This will clear and redownload all data from f1.com. Please don't refresh the page during the process.";
|
||||
|
||||
// This callback will be executed once the admin presses the "Proceed"-button in the warning toast
|
||||
const scrape_callback = async () => {
|
||||
const response: Response = await fetch("/api/scrape", { method: "POST" });
|
||||
invalidate("data:official");
|
||||
};
|
||||
|
||||
const scrape_official_data = async () => {
|
||||
if (!$pbUser || !$pbUser.admin) {
|
||||
toastStore.trigger(get_error_toast("Only admins may perform this action!"));
|
||||
return;
|
||||
}
|
||||
|
||||
// No timeout + action toast
|
||||
toastStore.trigger(get_warning_toast(scrape_message, null, "Proceed", scrape_callback));
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -16,6 +36,7 @@
|
||||
>
|
||||
<Button href="driverstandings" color="primary" activate_href>Drivers</Button>
|
||||
<Button href="teamstandings" color="primary" activate_href>Teams</Button>
|
||||
<Button href="startinggrids" color="primary" activate_href>Grids</Button>
|
||||
<Button href="raceresults" color="primary" activate_href>Race Results</Button>
|
||||
</div>
|
||||
</div>
|
||||
@ -23,7 +44,13 @@
|
||||
<!-- Each child's contents will be inserted here -->
|
||||
<div style="margin-top: 56px;">
|
||||
<div class="pb-2">
|
||||
<Button width="w-full" color="tertiary" onclick={scrape_official_data} shadow>
|
||||
<Button
|
||||
width="w-full"
|
||||
color="tertiary"
|
||||
onclick={scrape_official_data}
|
||||
shadow
|
||||
disabled={!$pbUser?.admin}
|
||||
>
|
||||
<span class="font-bold">Refresh All Data</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -2,7 +2,7 @@ import { fetch_drivers, fetch_scraped_driverstandings } from "$lib/fetch";
|
||||
import type { PageLoad } from "../../../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
depends("data:scraped_driverstandings", "data:drivers");
|
||||
depends("data:official", "data:drivers");
|
||||
|
||||
return {
|
||||
scraped_driverstandings: fetch_scraped_driverstandings(fetch),
|
||||
|
||||
@ -2,7 +2,7 @@ import { fetch_drivers, fetch_races, fetch_scraped_raceresults } from "$lib/fetc
|
||||
import type { PageLoad } from "../../../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
depends("data:scraped_raceresults", "data:races", "data:drivers");
|
||||
depends("data:official", "data:races", "data:drivers");
|
||||
|
||||
return {
|
||||
scraped_raceresults: fetch_scraped_raceresults(fetch),
|
||||
|
||||
49
src/routes/data/official/startinggrids/+page.svelte
Normal file
49
src/routes/data/official/startinggrids/+page.svelte
Normal file
@ -0,0 +1,49 @@
|
||||
<script lang="ts">
|
||||
import { Table, type TableColumn } from "$lib/components";
|
||||
import type { PageData } from "./$types";
|
||||
import { get_by_value } from "$lib/database";
|
||||
import type { Race } from "$lib/schema";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
const grids_columns: TableColumn[] = $derived([
|
||||
{
|
||||
data_value_name: "race_step",
|
||||
label: "Race",
|
||||
valuefun: async (value: string): Promise<string> => {
|
||||
const racename: string = get_by_value(await data.races, "step", value)?.name ?? "Invalid";
|
||||
return `<span class='badge variant-filled-surface'>${racename}</span>`;
|
||||
},
|
||||
},
|
||||
{
|
||||
data_value_name: "race_step",
|
||||
label: "Step",
|
||||
},
|
||||
{
|
||||
data_value_name: "driver_code",
|
||||
label: "Driver",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge variant-filled-surface'>${value}</span>`,
|
||||
},
|
||||
{
|
||||
data_value_name: "position",
|
||||
label: "Position",
|
||||
},
|
||||
{
|
||||
data_value_name: "time",
|
||||
label: "Time",
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Formula 11 - Official Starting Grids</title>
|
||||
</svelte:head>
|
||||
|
||||
{#await data.scraped_startinggrids then grids}
|
||||
<Table
|
||||
data={grids}
|
||||
columns={grids_columns}
|
||||
height="h-[calc(100vh-260px)] lg:h-[calc(100vh-180px)]"
|
||||
/>
|
||||
{/await}
|
||||
12
src/routes/data/official/startinggrids/+page.ts
Normal file
12
src/routes/data/official/startinggrids/+page.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { fetch_drivers, fetch_races, fetch_scraped_startinggrids } from "$lib/fetch";
|
||||
import type { PageLoad } from "../../../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
depends("data:official", "data:races", "data:drivers");
|
||||
|
||||
return {
|
||||
scraped_startinggrids: fetch_scraped_startinggrids(fetch),
|
||||
races: fetch_races(fetch),
|
||||
drivers: fetch_drivers(fetch),
|
||||
};
|
||||
};
|
||||
@ -2,7 +2,7 @@ import { fetch_scraped_teamstandings, fetch_teams } from "$lib/fetch";
|
||||
import type { PageLoad } from "../../../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
depends("data:scraped_teamstandings", "data:teams");
|
||||
depends("data:official", "data:teams");
|
||||
|
||||
return {
|
||||
scraped_teamstandings: fetch_scraped_teamstandings(fetch),
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
label: "Team",
|
||||
valuefun: async (value: string): Promise<string> => {
|
||||
const team: Team | undefined = get_by_value(await data.teams, "id", value);
|
||||
return `<span class='badge border mr-2' style='color: ${team?.color ?? "#FFFFFF"}; background: ${team?.color ?? "#FFFFFF"};'>C</span>${team?.name ?? "Invalid"}`;
|
||||
return `<span class='badge mr-2' style='color: ${team?.color ?? "#FFFFFF"}; background: ${team?.color ?? "#FFFFFF"};'>C</span>${team?.name ?? "Invalid"}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -59,6 +59,12 @@
|
||||
valuefun: async (value: boolean): Promise<string> =>
|
||||
`<span class='badge variant-filled-${value ? "tertiary" : "primary"} text-center' style='width: 36px;'>${value ? "Yes" : "No"}</span>`,
|
||||
},
|
||||
{
|
||||
data_value_name: "started_active",
|
||||
label: "Started Active",
|
||||
valuefun: async (value: boolean): Promise<string> =>
|
||||
`<span class='badge variant-filled-${value ? "tertiary" : "primary"} text-center' style='width: 36px;'>${value ? "Yes" : "No"}</span>`,
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
data_value_name: "color",
|
||||
label: "Color",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge border mr-2' style='color: ${value}; background: ${value};'>C</span>`,
|
||||
`<span class='badge mr-2' style='color: ${value}; background: ${value};'>C</span>`,
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
@ -1,28 +1,96 @@
|
||||
<script lang="ts">
|
||||
import { make_chart_options } from "$lib/chart";
|
||||
import { Table, type TableColumn } from "$lib/components";
|
||||
import { get_by_value } from "$lib/database";
|
||||
import type { RacePickPoints, RacePickPointsAcc, User } from "$lib/schema";
|
||||
import type { PageData } from "./$types";
|
||||
import {
|
||||
LineChart,
|
||||
ScaleTypes,
|
||||
type ChartTabularData,
|
||||
type LineChartOptions,
|
||||
} from "@carbon/charts-svelte";
|
||||
import "@carbon/charts-svelte/styles.css";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
// Await promises
|
||||
let users: User[] | undefined = $state(undefined);
|
||||
data.users.then((u: User[]) => (users = u));
|
||||
|
||||
let racepickpoints: RacePickPoints[] | undefined = $state(undefined);
|
||||
data.racepickpoints.then((r: RacePickPoints[]) => (racepickpoints = r));
|
||||
|
||||
let racepickpointsacc: RacePickPointsAcc[] | undefined = $state(undefined);
|
||||
data.racepickpointsacc.then((r: RacePickPointsAcc[]) => (racepickpointsacc = r));
|
||||
|
||||
const leaderboard_columns: TableColumn[] = $derived([
|
||||
{
|
||||
data_value_name: "user",
|
||||
label: "User",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
get_by_value(await data.users, "id", value)?.firstname ?? "Invalid",
|
||||
`<span class='badge variant-filled-surface'>${get_by_value(await data.users, "id", value)?.firstname ?? "Invalid"}</span>`,
|
||||
},
|
||||
{
|
||||
data_value_name: "total_points",
|
||||
label: "Points",
|
||||
label: "Total",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge variant-filled-surface'>${value}</span>`,
|
||||
},
|
||||
{
|
||||
data_value_name: "total_pxx_points",
|
||||
label: "PXX",
|
||||
},
|
||||
{
|
||||
data_value_name: "total_dnf_points",
|
||||
label: "DNF",
|
||||
},
|
||||
{
|
||||
data_value_name: "total_points_per_pick",
|
||||
label: "Per Pick",
|
||||
valuefun: async (value: string): Promise<string> => Number.parseFloat(value).toFixed(2),
|
||||
},
|
||||
]);
|
||||
|
||||
const points_chart_data: ChartTabularData = $derived.by(() => {
|
||||
if (!users || !racepickpointsacc) return [];
|
||||
|
||||
return users
|
||||
.map((user: User) => {
|
||||
return {
|
||||
group: user.firstname,
|
||||
step: "0",
|
||||
points: 0,
|
||||
};
|
||||
})
|
||||
.concat(
|
||||
racepickpointsacc.map((points: RacePickPointsAcc) => {
|
||||
return {
|
||||
group: get_by_value(users ?? [], "id", points.user)?.firstname || "INVALID",
|
||||
step: points.step.toString(),
|
||||
points: points.acc_points,
|
||||
};
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
const points_chart_options: LineChartOptions = make_chart_options(
|
||||
"I ❤️ CumSum",
|
||||
"step",
|
||||
"points",
|
||||
);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Formula 11 - Leaderboard</title>
|
||||
</svelte:head>
|
||||
|
||||
{#await Promise.all( [data.users, data.racepickpoints, data.racepickpointsacc], ) then [users, racepickpoints, racepickpointsacc]}
|
||||
<Table data={racepickpointsacc} columns={leaderboard_columns} />
|
||||
{/await}
|
||||
<div class="card w-full bg-surface-100 p-2 shadow">
|
||||
<LineChart data={points_chart_data} options={points_chart_options} />
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
{#await data.racepickpointstotal then racepickpointstotal}
|
||||
<Table data={racepickpointstotal} columns={leaderboard_columns} />
|
||||
{/await}
|
||||
</div>
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
import { fetch_users, fetch_racepickpoints, fetch_racepickpointsacc } from "$lib/fetch";
|
||||
import {
|
||||
fetch_users,
|
||||
fetch_racepickpoints,
|
||||
fetch_racepickpointsacc,
|
||||
fetch_racepickpointstotal,
|
||||
} from "$lib/fetch";
|
||||
import type { PageLoad } from "../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
@ -8,5 +13,6 @@ export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
users: fetch_users(fetch),
|
||||
racepickpoints: fetch_racepickpoints(fetch),
|
||||
racepickpointsacc: fetch_racepickpointsacc(fetch),
|
||||
racepickpointstotal: fetch_racepickpointstotal(fetch),
|
||||
};
|
||||
};
|
||||
|
||||
@ -256,8 +256,8 @@
|
||||
{#await data.currentpickedusers then currentpicked}
|
||||
{#each currentpicked as user}
|
||||
<div
|
||||
class="card ml-1 mt-2 w-full min-w-14 rounded-b-none py-2 lg:ml-2
|
||||
{$pbUser && $pbUser.username === user.username ? 'bg-primary-300' : ''}"
|
||||
class="card ml-1 mt-2 w-full min-w-14 rounded-b-none bg-surface-400 py-2
|
||||
{$pbUser && $pbUser.username === user.username ? '!bg-primary-400' : ''}"
|
||||
>
|
||||
<!-- Avatar + name display at the top -->
|
||||
<div class="m-auto flex h-10 w-fit">
|
||||
@ -293,7 +293,7 @@
|
||||
|
||||
<div
|
||||
use:popup={race_popupsettings(race?.id ?? "Invalid")}
|
||||
class="card mt-1 flex h-20 w-7 cursor-pointer flex-col !rounded-r-none lg:mt-2 lg:w-36 lg:p-2"
|
||||
class="card mt-1 flex h-16 w-7 cursor-pointer flex-col !rounded-r-none bg-surface-400 lg:h-20 lg:w-36 lg:p-2"
|
||||
>
|
||||
<!-- For large screens -->
|
||||
<span class="hidden text-sm font-bold lg:block">
|
||||
@ -306,13 +306,13 @@
|
||||
|
||||
<!-- For small screens -->
|
||||
<!-- TODO: This requires the race name to end with an emoji, but this is never enforced -->
|
||||
<div class="mx-[2px] my-[25px] block text-lg font-bold lg:hidden">
|
||||
<div class="mx-[2px] my-[18px] block text-lg font-bold lg:hidden">
|
||||
{runes(race?.name ?? "Invalid").at(-1)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- The race result popup is triggered on click on the race -->
|
||||
<div data-popup={race?.id ?? "Invalid"} class="card z-50 p-2 shadow">
|
||||
<div data-popup={race?.id ?? "Invalid"} class="card z-50 bg-surface-400 p-2 shadow">
|
||||
<span class="font-bold">Result:</span>
|
||||
<div class="mt-2 flex flex-col gap-1">
|
||||
{#each result.pxxs as pxx, index}
|
||||
@ -351,7 +351,7 @@
|
||||
{#each currentpicked as user}
|
||||
{@const picks = racepicks.filter((pick: RacePick) => pick.user === user.id)}
|
||||
|
||||
<div class="ml-1 w-full min-w-14 lg:ml-2">
|
||||
<div class="ml-1 w-full min-w-14">
|
||||
{#each raceresults as result}
|
||||
{@const race = get_by_value(races, "id", result.race)}
|
||||
{@const pick = picks.filter((pick: RacePick) => pick.race === race?.id)[0]}
|
||||
@ -360,7 +360,7 @@
|
||||
result.dnfs.indexOf(pick?.dnf ?? "Invalid") >= 0 ? PXX_COLORS[3] : PXX_COLORS[-1]}
|
||||
|
||||
{#if pick}
|
||||
<div class="mt-1 h-20 w-full border bg-surface-300 px-1 py-2 lg:mt-2 lg:px-2">
|
||||
<div class="mt-1 h-16 w-full border bg-surface-200 px-1 py-2 lg:h-20 lg:px-2">
|
||||
<div class="mx-auto flex h-full w-fit flex-col justify-evenly">
|
||||
<span
|
||||
class="w-10 p-1 text-center text-xs rounded-container-token lg:text-sm"
|
||||
@ -377,7 +377,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="mt-1 h-20 w-full px-1 py-2 lg:mt-2 lg:px-2"></div>
|
||||
<div class="mt-1 h-16 w-full px-1 py-2 lg:h-20 lg:px-2"></div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@ -264,8 +264,8 @@
|
||||
{#await data.seasonpickedusers then seasonpicked}
|
||||
{#each seasonpicked as user}
|
||||
<div
|
||||
class="card ml-1 mt-2 w-full min-w-36 rounded-b-none py-2 lg:ml-2
|
||||
{$pbUser && $pbUser.username === user.username ? 'bg-primary-300' : ''}"
|
||||
class="card ml-1 mt-2 w-full min-w-36 rounded-b-none bg-surface-400 py-2
|
||||
{$pbUser && $pbUser.username === user.username ? '!bg-primary-400' : ''}"
|
||||
>
|
||||
<!-- Avatar + name display at the top -->
|
||||
<div class="m-auto flex h-10 w-fit">
|
||||
@ -296,7 +296,7 @@
|
||||
class="sticky left-0 z-10 w-7 min-w-7 max-w-7 bg-surface-50 lg:w-36 lg:min-w-36 lg:max-w-36"
|
||||
>
|
||||
<!-- Hottake -->
|
||||
<div class="card mt-1 flex h-32 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-32 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">Hottake</span>
|
||||
<span class="block rotate-90 text-nowrap text-xs font-bold lg:hidden">Hottake</span>
|
||||
</div>
|
||||
@ -304,13 +304,13 @@
|
||||
{#await data.seasonpicks then seasonpicks}
|
||||
{#if seasonpicks.length > 0}
|
||||
<!-- Drivers Champion -->
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">Drivers<br />Champion</span>
|
||||
<span class="block rotate-90 text-nowrap text-xs font-bold lg:hidden">WDC</span>
|
||||
</div>
|
||||
|
||||
<!-- Constructors Champion -->
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">
|
||||
Constructors<br />Champion
|
||||
</span>
|
||||
@ -318,25 +318,25 @@
|
||||
</div>
|
||||
|
||||
<!-- Overtakes -->
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">Most Overtakes</span>
|
||||
<span class="block rotate-90 text-nowrap text-xs font-bold lg:hidden">Overtakes</span>
|
||||
</div>
|
||||
|
||||
<!-- DNFs -->
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">Most DNFs</span>
|
||||
<span class="block rotate-90 text-nowrap text-xs font-bold lg:hidden">DNFs</span>
|
||||
</div>
|
||||
|
||||
<!-- Doohan Starts -->
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-20 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">Doohan Starts</span>
|
||||
<span class="block rotate-90 text-nowrap text-xs font-bold lg:hidden">Doohan</span>
|
||||
</div>
|
||||
|
||||
<!-- Teamwinners -->
|
||||
<div class="card mt-1 flex h-64 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-64 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block"
|
||||
>Team-Battle<br />Winners</span
|
||||
>
|
||||
@ -344,7 +344,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Podiums -->
|
||||
<div class="card mt-1 flex h-64 w-7 flex-col !rounded-r-none p-2 lg:mt-2 lg:w-36">
|
||||
<div class="card mt-1 flex h-64 w-7 flex-col !rounded-r-none bg-surface-400 p-2 lg:w-36">
|
||||
<span class="hidden text-nowrap text-sm font-bold lg:block">Podiums</span>
|
||||
<span class="block rotate-90 text-nowrap text-xs font-bold lg:hidden">Podiums</span>
|
||||
</div>
|
||||
@ -366,15 +366,15 @@
|
||||
? get_by_value(drivers, "id", pick.mostovertakes)
|
||||
: undefined}
|
||||
{@const mostdnfs = pick ? get_by_value(drivers, "id", pick.mostdnfs) : undefined}
|
||||
{@const drivers_sorted = drivers
|
||||
.filter((driver: Driver) => driver.active)
|
||||
{@const drivers_startedactive = drivers
|
||||
.filter((driver: Driver) => driver.started_active)
|
||||
.sort((a: Driver, b: Driver) => a.code.localeCompare(b.code))
|
||||
.sort((a: Driver, b: Driver) => a.team.localeCompare(b.team))}
|
||||
|
||||
<div class="ml-1 w-full min-w-36 lg:ml-2">
|
||||
<div class="ml-1 w-full min-w-36">
|
||||
<!-- Hottake -->
|
||||
<div
|
||||
class="mt-1 h-32 w-full overflow-y-scroll border bg-surface-300 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
class="mt-1 h-32 w-full overflow-y-scroll border bg-surface-200 px-1 py-2 leading-3 lg:px-2"
|
||||
>
|
||||
<div class="mx-auto w-fit text-xs font-bold lg:text-sm">
|
||||
{hottake?.hottake ?? "?"}
|
||||
@ -383,9 +383,7 @@
|
||||
|
||||
{#if seasonpicks.length > 0}
|
||||
<!-- Drivers Champion -->
|
||||
<div
|
||||
class="mt-1 h-20 w-full border bg-surface-300 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
>
|
||||
<div class="mt-1 h-20 w-full border bg-surface-200 px-1 py-2 leading-3 lg:px-2">
|
||||
<div class="mx-auto w-fit">
|
||||
<!-- NOTE: The containerstyle should be 64x64, don't know why that doesn't fit... (also below) -->
|
||||
<LazyImage
|
||||
@ -400,9 +398,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Constructors Champion -->
|
||||
<div
|
||||
class="mt-1 h-20 w-full border bg-surface-300 p-1 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
>
|
||||
<div class="mt-1 h-20 w-full border bg-surface-200 p-1 px-1 py-2 leading-3 lg:px-2">
|
||||
<div class="mx-auto w-fit">
|
||||
<LazyImage
|
||||
src={wccwinner?.banner_url ?? get_team_banner_template(data.graphics)}
|
||||
@ -416,9 +412,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Most Overtakes -->
|
||||
<div
|
||||
class="mt-1 h-20 w-full border bg-surface-300 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
>
|
||||
<div class="mt-1 h-20 w-full border bg-surface-200 px-1 py-2 leading-3 lg:px-2">
|
||||
<div class="mx-auto w-fit">
|
||||
<LazyImage
|
||||
src={mostovertakes?.headshot_url ?? get_driver_headshot_template(data.graphics)}
|
||||
@ -434,9 +428,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Most DNFs -->
|
||||
<div
|
||||
class="mt-1 h-20 w-full border bg-surface-300 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
>
|
||||
<div class="mt-1 h-20 w-full border bg-surface-200 px-1 py-2 leading-3 lg:px-2">
|
||||
<div class="mx-auto w-fit">
|
||||
<LazyImage
|
||||
src={mostdnfs?.headshot_url ?? get_driver_headshot_template(data.graphics)}
|
||||
@ -450,9 +442,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Doohan Starts -->
|
||||
<div
|
||||
class="mt-1 h-20 w-full border bg-surface-300 p-1 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
>
|
||||
<div class="mt-1 h-20 w-full border bg-surface-200 p-1 px-1 py-2 leading-3 lg:px-2">
|
||||
<div class="mx-auto w-fit text-xs lg:text-sm">
|
||||
Jack Doohan startet <span class="font-bold">{pick?.doohanstarts ?? "?"}</span> mal.
|
||||
</div>
|
||||
@ -460,11 +450,11 @@
|
||||
|
||||
<!-- Teamwinners -->
|
||||
<div
|
||||
class="mt-1 h-64 w-full overflow-y-scroll border bg-surface-300 p-1 px-1 py-2 leading-3 lg:mt-2 lg:px-2"
|
||||
class="mt-1 h-64 w-full overflow-y-scroll border bg-surface-200 p-1 px-1 py-2 leading-3 lg:px-2"
|
||||
>
|
||||
{#if pick && pick.teamwinners}
|
||||
<div class="grid grid-cols-2 gap-1">
|
||||
{#each drivers_sorted as driver}
|
||||
{#each drivers_startedactive as driver}
|
||||
{@const color: string = get_by_value(teams, "id", driver?.team ?? "")?.color ?? ""}
|
||||
<div class="mx-auto w-fit text-xs lg:text-sm">
|
||||
<div
|
||||
@ -489,11 +479,11 @@
|
||||
<!-- Podiums -->
|
||||
<!-- TODO: Replace all style tags throughout the page with custom classes like height here -->
|
||||
<div
|
||||
class="mt-1 h-64 w-full overflow-y-scroll border bg-surface-300 p-1 px-1 py-2 leading-3 shadow lg:mt-2 lg:px-2"
|
||||
class="mt-1 h-64 w-full overflow-y-scroll border bg-surface-200 p-1 px-1 py-2 leading-3 shadow lg:px-2"
|
||||
>
|
||||
{#if pick && pick.podiums}
|
||||
<div class="grid grid-cols-2 gap-1">
|
||||
{#each drivers_sorted as driver}
|
||||
{#each drivers_startedactive as driver}
|
||||
{@const color: string = get_by_value(teams, "id", driver?.team ?? "")?.color ?? ""}
|
||||
<div class="mx-auto w-fit text-xs lg:text-sm">
|
||||
<div
|
||||
|
||||
@ -1,3 +1,113 @@
|
||||
<script lang="ts">
|
||||
import { Table, type TableColumn } from "$lib/components";
|
||||
import type { Driver, ScrapedRaceResultAcc } from "$lib/schema";
|
||||
import {
|
||||
LineChart,
|
||||
ScaleTypes,
|
||||
type ChartTabularData,
|
||||
type LineChartOptions,
|
||||
} from "@carbon/charts-svelte";
|
||||
import "@carbon/charts-svelte/styles.css";
|
||||
import type { PageData } from "./$types";
|
||||
import { get_by_value } from "$lib/database";
|
||||
import { make_chart_options } from "$lib/chart";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
// Await promises
|
||||
let drivers: Driver[] | undefined = $state(undefined);
|
||||
data.drivers.then((d: Driver[]) => (drivers = d));
|
||||
|
||||
let scraped_raceresultsacc: ScrapedRaceResultAcc[] | undefined = $state(undefined);
|
||||
data.scraped_raceresultsacc.then((s: ScrapedRaceResultAcc[]) => (scraped_raceresultsacc = s));
|
||||
|
||||
const drivers_columns: TableColumn[] = $derived([
|
||||
{
|
||||
data_value_name: "position",
|
||||
label: "Position",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge variant-filled-surface'>${value}</span>`,
|
||||
},
|
||||
{
|
||||
data_value_name: "driver_code",
|
||||
label: "Driver",
|
||||
},
|
||||
{
|
||||
data_value_name: "points",
|
||||
label: "Points",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge variant-filled-surface'>${value}</span>`,
|
||||
},
|
||||
]);
|
||||
|
||||
const teams_columns: TableColumn[] = $derived([
|
||||
{
|
||||
data_value_name: "position",
|
||||
label: "Position",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge variant-filled-surface'>${value}</span>`,
|
||||
},
|
||||
{
|
||||
data_value_name: "team_fullname",
|
||||
label: "team",
|
||||
},
|
||||
{
|
||||
data_value_name: "points",
|
||||
label: "Points",
|
||||
valuefun: async (value: string): Promise<string> =>
|
||||
`<span class='badge variant-filled-surface'>${value}</span>`,
|
||||
},
|
||||
]);
|
||||
|
||||
const drivers_chart_data: ChartTabularData = $derived.by(() => {
|
||||
if (!drivers || !scraped_raceresultsacc) return [];
|
||||
|
||||
const active_drivers: Driver[] = drivers.filter((driver: Driver) => driver.active);
|
||||
const active_results: ScrapedRaceResultAcc[] = scraped_raceresultsacc.filter(
|
||||
(result: ScrapedRaceResultAcc) =>
|
||||
get_by_value(drivers ?? [], "code", result.driver_code)?.active,
|
||||
);
|
||||
|
||||
return active_drivers
|
||||
.map((driver: Driver) => {
|
||||
return {
|
||||
group: driver.code,
|
||||
step: "0",
|
||||
points: 0,
|
||||
};
|
||||
})
|
||||
.concat(
|
||||
active_results.map((result: ScrapedRaceResultAcc) => {
|
||||
return {
|
||||
group: result.driver_code,
|
||||
step: result.race_step.toString(),
|
||||
points: result.acc_points,
|
||||
};
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
const drivers_chart_options: LineChartOptions = make_chart_options("Drivers", "step", "points");
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Formula 11 - Statistics</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="card w-full bg-surface-100 p-2 shadow">
|
||||
<LineChart data={drivers_chart_data} options={drivers_chart_options} />
|
||||
</div>
|
||||
|
||||
<div class="mt-2 grid w-full grid-cols-1 gap-2 lg:grid-cols-2">
|
||||
<div class="w-full">
|
||||
{#await data.scraped_driverstandings then driverstandings}
|
||||
<Table data={driverstandings} columns={drivers_columns} />
|
||||
{/await}
|
||||
</div>
|
||||
|
||||
<div class="w-full">
|
||||
{#await data.scraped_teamstandings then teamstandings}
|
||||
<Table data={teamstandings} columns={teams_columns} />
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
23
src/routes/statistics/+page.ts
Normal file
23
src/routes/statistics/+page.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import {
|
||||
fetch_drivers,
|
||||
fetch_scraped_driverstandings,
|
||||
fetch_scraped_raceresults,
|
||||
fetch_scraped_raceresultsacc,
|
||||
fetch_scraped_startinggrids,
|
||||
fetch_scraped_teamstandings,
|
||||
} from "$lib/fetch";
|
||||
import type { PageLoad } from "../$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch, depends }) => {
|
||||
depends("data:drivers", "data:official");
|
||||
|
||||
return {
|
||||
drivers: fetch_drivers(fetch),
|
||||
|
||||
scraped_driverstandings: fetch_scraped_driverstandings(fetch),
|
||||
scraped_teamstandings: fetch_scraped_teamstandings(fetch),
|
||||
scraped_startinggrids: fetch_scraped_startinggrids(fetch),
|
||||
scraped_raceresults: fetch_scraped_raceresults(fetch),
|
||||
scraped_raceresultsacc: fetch_scraped_raceresultsacc(fetch),
|
||||
};
|
||||
};
|
||||
@ -3,6 +3,9 @@ import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()],
|
||||
ssr: {
|
||||
noExternal: process.env.NODE_ENV === "production" ? ["@carbon/charts"] : [],
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: ["sharp"],
|
||||
|
||||
Reference in New Issue
Block a user