Chron script for loading database

This commit is contained in:
jmosrael@gmail.com
2024-07-17 22:50:25 -07:00
parent 6d03e450c9
commit bc3455f5d0
8 changed files with 56 additions and 10 deletions

View File

@@ -5,6 +5,7 @@
<v-btn to="/serverstats">Server Stats</v-btn> <v-btn to="/serverstats">Server Stats</v-btn>
<v-btn to="/games">Games</v-btn> <v-btn to="/games">Games</v-btn>
<v-btn to="/characters">Characters</v-btn> <v-btn to="/characters">Characters</v-btn>
<!-- <v-btn to="/gamemasters">Gamemasters</v-btn> -->
</v-app-bar> </v-app-bar>
<router-view /> <router-view />
</v-main> </v-main>

View File

@@ -5,6 +5,7 @@ import GameDetails from '../vues/GameDetails.vue'
import CharacterList from '../vues/CharacterList.vue' import CharacterList from '../vues/CharacterList.vue'
import CharacterDetails from '../vues/CharacterDetails.vue' import CharacterDetails from '../vues/CharacterDetails.vue'
import ServerStats from '../vues/ServerStats.vue' import ServerStats from '../vues/ServerStats.vue'
import DmList from '../vues/DmList.vue'
const root = { const root = {
path: '/', path: '/',
@@ -36,13 +37,19 @@ const serverStatsRoute = {
component: ServerStats component: ServerStats
} }
const gameMasterListRoute = {
path: '/gamemasters',
component: DmList
}
const routes = [ const routes = [
root, root,
gameListRoute, gameListRoute,
gameDetailsRoute, gameDetailsRoute,
characterListRoute, characterListRoute,
characterDetailsRoute, characterDetailsRoute,
serverStatsRoute serverStatsRoute,
gameMasterListRoute
] ]
export default createRouter({ export default createRouter({

View File

@@ -21,6 +21,13 @@ export interface Character {
creationDate: number creationDate: number
} }
export interface DmStats {
name: string
gameCount: string
lastGame: number
games: Game
}
export interface GameStats { export interface GameStats {
Complete: number Complete: number
Postponed: number Postponed: number

View File

@@ -1,10 +1,17 @@
<template> <template>Hello World</template>
</template>
<style> <style></style>
</style>
<script setup lang="ts"> <script setup lang="ts">
import { DmStats } from '../types'
import { onMounted, ref, watch } from 'vue'
import { VDataTable } from 'vuetify/components'
</script> 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' }
]
</script>

View File

@@ -33,9 +33,7 @@
<thead> <thead>
<tr> <tr>
<th class="text-left">Role</th> <th class="text-left">Role</th>
<th class="text-left"> <th class="text-left">Characters</th>
Characters
</th>
<th class="text-left">App Count</th> <th class="text-left">App Count</th>
<th class="text-left">Games Played</th> <th class="text-left">Games Played</th>
<th class="text-left">Pick Rate %</th> <th class="text-left">Pick Rate %</th>

16
loader/chron-script.sh Normal file
View File

@@ -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

View File

@@ -12,6 +12,10 @@ Game = namedtuple('Game',
Link = namedtuple('Link', ['gameId', 'gameTitle', 'characterId', 'characterName']) Link = namedtuple('Link', ['gameId', 'gameTitle', 'characterId', 'characterName'])
SET_WAL_PRAGMA = """
PRAGMA journal_mode=WAL;
"""
APPS_TABLE_CREATE = """ APPS_TABLE_CREATE = """
CREATE TABLE IF NOT EXISTS "Apps" ( CREATE TABLE IF NOT EXISTS "Apps" (
"gameId" INTEGER, "gameId" INTEGER,
@@ -170,6 +174,7 @@ def loadAppsAndPicks(characterNameToId, gameTitleToId, gameFileName):
def createTables(dbName): def createTables(dbName):
with sqlite3.connect(dbName) as connection: with sqlite3.connect(dbName) as connection:
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute(SET_WAL_PRAGMA)
cursor.execute(CHARACTER_TABLE_CREATE) cursor.execute(CHARACTER_TABLE_CREATE)
cursor.execute(GAMES_TABLE_CREATE) cursor.execute(GAMES_TABLE_CREATE)
cursor.execute(APPS_TABLE_CREATE) cursor.execute(APPS_TABLE_CREATE)

5
loader/requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
certifi==2024.6.2
charset-normalizer==3.3.2
idna==3.7
requests==2.32.3
urllib3==2.2.1