remove broken pwa feature and fix weekly analytics counter

This commit is contained in:
2026-04-20 15:34:04 +02:00
parent c14a86b190
commit 0cd500e9f2
7 changed files with 7 additions and 48 deletions

View File

@@ -1,21 +0,0 @@
import streamlit as st
init = st.components.v2.component(
name="pwa",
isolate_styles=False,
js = """
export default function() {
// Manifest
const link = document.createElement("link");
link.rel = "manifest";
link.href = "./app/static/manifest.json";
document.head.appendChild(link);
// Service Worker
navigator.serviceWorker.register('./app/static/service-worker.js')
.then(reg => console.log('SW registered', reg))
.catch(err => console.log('SW registration failed', err));
}
""",
)

View File

@@ -1,8 +1,5 @@
import logging import logging
import sys
def init_logger() -> None: def init_logger() -> None:
logging.basicConfig( level = logging.INFO
level=logging.INFO, logging.basicConfig(level=level, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
stream=sys.stdout)

View File

@@ -57,8 +57,8 @@ with st.container(key="counter-table"):
case CounterType.WEEKLY.value: case CounterType.WEEKLY.value:
stats = sql.get_weekly_analytics(counter_id) stats = sql.get_weekly_analytics(counter_id)
stats_current = stats.iloc[-1]["count"] stats_current = stats.iloc[0]["count"]
stats_prev = stats.iloc[-2]["count"] stats_prev = stats.iloc[1]["count"]
case CounterType.MONTHLY.value: case CounterType.MONTHLY.value:
stats = sql.get_monthly_analytics(counter_id) stats = sql.get_monthly_analytics(counter_id)

View File

@@ -11,8 +11,8 @@ connection = st.connection("sqlite")
with connection.session as configure_session: with connection.session as configure_session:
configure_session.execute(text('PRAGMA foreign_keys=ON')) configure_session.execute(text('PRAGMA foreign_keys=ON'))
def create_counter(title:str, counter_type:CounterType, counter_color) -> None: def create_counter(title:str, counter_type:CounterType, counter_color) -> None:
logger.info("Adding counter %s", counter_type)
with connection.session as session: with connection.session as session:
try: try:
query = text('INSERT INTO counters (name, type, color) VALUES (:title, :type, :color)') query = text('INSERT INTO counters (name, type, color) VALUES (:title, :type, :color)')
@@ -22,7 +22,6 @@ def create_counter(title:str, counter_type:CounterType, counter_color) -> None:
logger.error(e) logger.error(e)
session.rollback() session.rollback()
def get_counters(): def get_counters():
try: try:
return connection.query('SELECT id, name, type, color FROM counters', ttl=0) return connection.query('SELECT id, name, type, color FROM counters', ttl=0)
@@ -31,6 +30,7 @@ def get_counters():
return st.dataframe() return st.dataframe()
def increment_counter(counter_id:int) -> None: def increment_counter(counter_id:int) -> None:
logger.info("Incrementing counter %s", counter_id)
with connection.session as session: with connection.session as session:
try: try:
query = text('INSERT INTO entries (counter_id) VALUES (:id)') query = text('INSERT INTO entries (counter_id) VALUES (:id)')
@@ -42,6 +42,7 @@ def increment_counter(counter_id:int) -> None:
def remove_counter(counter_id:int) -> None: def remove_counter(counter_id:int) -> None:
logger.info("Removing counter %s", counter_id)
with connection.session as session: with connection.session as session:
try: try:
query = text('DELETE FROM counters WHERE id = :id') query = text('DELETE FROM counters WHERE id = :id')

View File

@@ -1,8 +0,0 @@
{
"short_name": "Daily Counter",
"name": "Daily Counter",
"start_url": ".",
"display": "standalone",
"theme_color": "white",
"background_color": "white"
}

View File

@@ -1,7 +0,0 @@
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});

View File

@@ -2,9 +2,6 @@ import streamlit as st
from logger import init_logger from logger import init_logger
from styles import init_styles from styles import init_styles
from components import pwa
pwa.init()
init_logger() init_logger()
init_styles() init_styles()