From bc3455f5d0b38bc18a3e4e8a3f442cc138278099 Mon Sep 17 00:00:00 2001 From: "jmosrael@gmail.com" Date: Wed, 17 Jul 2024 22:50:25 -0700 Subject: [PATCH] Chron script for loading database --- frontend/src/App.vue | 1 + frontend/src/router/index.ts | 9 ++++++++- frontend/src/types.ts | 7 +++++++ frontend/src/vues/DmList.vue | 19 +++++++++++++------ frontend/src/vues/ServerStats.vue | 4 +--- loader/chron-script.sh | 16 ++++++++++++++++ loader/databasesync.py | 5 +++++ loader/requirements.txt | 5 +++++ 8 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 loader/chron-script.sh create mode 100644 loader/requirements.txt diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 1daed69..8a9be1c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -5,6 +5,7 @@ Server Stats Games Characters + diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index f5d159d..a41d190 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -5,6 +5,7 @@ import GameDetails from '../vues/GameDetails.vue' import CharacterList from '../vues/CharacterList.vue' import CharacterDetails from '../vues/CharacterDetails.vue' import ServerStats from '../vues/ServerStats.vue' +import DmList from '../vues/DmList.vue' const root = { path: '/', @@ -36,13 +37,19 @@ const serverStatsRoute = { component: ServerStats } +const gameMasterListRoute = { + path: '/gamemasters', + component: DmList +} + const routes = [ root, gameListRoute, gameDetailsRoute, characterListRoute, characterDetailsRoute, - serverStatsRoute + serverStatsRoute, + gameMasterListRoute ] export default createRouter({ diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 814c40f..c13d050 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -21,6 +21,13 @@ export interface Character { creationDate: number } +export interface DmStats { + name: string + gameCount: string + lastGame: number + games: Game +} + export interface GameStats { Complete: number Postponed: number diff --git a/frontend/src/vues/DmList.vue b/frontend/src/vues/DmList.vue index 7401387..6a92ea0 100644 --- a/frontend/src/vues/DmList.vue +++ b/frontend/src/vues/DmList.vue @@ -1,10 +1,17 @@ - + - + \ No newline at end of file +type ReadonlyHeaders = VDataTable['$props']['headers'] + +const headers: ReadonlyHeaders = [ + { title: 'Game Master', align: 'start', sortable: true, key: 'id' }, + { title: 'Game Count', align: 'start', sortable: true, key: 'characterName' }, + { title: 'Last Game', align: 'start', sortable: true, key: 'role' } +] + diff --git a/frontend/src/vues/ServerStats.vue b/frontend/src/vues/ServerStats.vue index 3d46b68..cc4d007 100644 --- a/frontend/src/vues/ServerStats.vue +++ b/frontend/src/vues/ServerStats.vue @@ -33,9 +33,7 @@ Role - - Characters - + Characters App Count Games Played Pick Rate % diff --git a/loader/chron-script.sh b/loader/chron-script.sh new file mode 100644 index 0000000..2a88206 --- /dev/null +++ b/loader/chron-script.sh @@ -0,0 +1,16 @@ +#!/bin/bash +parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) + + +PYTHON_VEN="$parent_path"/venv/bin/python +if [ ! -f $PYTHON_VEN ]; then + echo "Setting up new VENV" + python -m venv venv + echo "Installing requirements." + source ./venv/bin/activate + pip install -r requirements.txt + deactivate +fi + +echo "Start DB Creation" +$parent_path/venv/bin/python createrushdatabase.py \ No newline at end of file diff --git a/loader/databasesync.py b/loader/databasesync.py index 41cb9a6..f5f2f61 100644 --- a/loader/databasesync.py +++ b/loader/databasesync.py @@ -12,6 +12,10 @@ Game = namedtuple('Game', Link = namedtuple('Link', ['gameId', 'gameTitle', 'characterId', 'characterName']) +SET_WAL_PRAGMA = """ +PRAGMA journal_mode=WAL; +""" + APPS_TABLE_CREATE = """ CREATE TABLE IF NOT EXISTS "Apps" ( "gameId" INTEGER, @@ -170,6 +174,7 @@ def loadAppsAndPicks(characterNameToId, gameTitleToId, gameFileName): def createTables(dbName): with sqlite3.connect(dbName) as connection: cursor = connection.cursor() + cursor.execute(SET_WAL_PRAGMA) cursor.execute(CHARACTER_TABLE_CREATE) cursor.execute(GAMES_TABLE_CREATE) cursor.execute(APPS_TABLE_CREATE) diff --git a/loader/requirements.txt b/loader/requirements.txt new file mode 100644 index 0000000..fd8654b --- /dev/null +++ b/loader/requirements.txt @@ -0,0 +1,5 @@ +certifi==2024.6.2 +charset-normalizer==3.3.2 +idna==3.7 +requests==2.32.3 +urllib3==2.2.1