remove broken pwa feature and fix weekly analytics counter
This commit is contained in:
@@ -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));
|
||||
}
|
||||
""",
|
||||
)
|
||||
@@ -1,8 +1,5 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
def init_logger() -> None:
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
||||
stream=sys.stdout)
|
||||
level = logging.INFO
|
||||
logging.basicConfig(level=level, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
|
||||
@@ -57,8 +57,8 @@ with st.container(key="counter-table"):
|
||||
|
||||
case CounterType.WEEKLY.value:
|
||||
stats = sql.get_weekly_analytics(counter_id)
|
||||
stats_current = stats.iloc[-1]["count"]
|
||||
stats_prev = stats.iloc[-2]["count"]
|
||||
stats_current = stats.iloc[0]["count"]
|
||||
stats_prev = stats.iloc[1]["count"]
|
||||
|
||||
case CounterType.MONTHLY.value:
|
||||
stats = sql.get_monthly_analytics(counter_id)
|
||||
|
||||
@@ -11,8 +11,8 @@ connection = st.connection("sqlite")
|
||||
with connection.session as configure_session:
|
||||
configure_session.execute(text('PRAGMA foreign_keys=ON'))
|
||||
|
||||
|
||||
def create_counter(title:str, counter_type:CounterType, counter_color) -> None:
|
||||
logger.info("Adding counter %s", counter_type)
|
||||
with connection.session as session:
|
||||
try:
|
||||
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)
|
||||
session.rollback()
|
||||
|
||||
|
||||
def get_counters():
|
||||
try:
|
||||
return connection.query('SELECT id, name, type, color FROM counters', ttl=0)
|
||||
@@ -31,6 +30,7 @@ def get_counters():
|
||||
return st.dataframe()
|
||||
|
||||
def increment_counter(counter_id:int) -> None:
|
||||
logger.info("Incrementing counter %s", counter_id)
|
||||
with connection.session as session:
|
||||
try:
|
||||
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:
|
||||
logger.info("Removing counter %s", counter_id)
|
||||
with connection.session as session:
|
||||
try:
|
||||
query = text('DELETE FROM counters WHERE id = :id')
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"short_name": "Daily Counter",
|
||||
"name": "Daily Counter",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "white",
|
||||
"background_color": "white"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
self.addEventListener('fetch', event => {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(response => {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
@@ -2,9 +2,6 @@ import streamlit as st
|
||||
|
||||
from logger import init_logger
|
||||
from styles import init_styles
|
||||
from components import pwa
|
||||
|
||||
pwa.init()
|
||||
|
||||
init_logger()
|
||||
init_styles()
|
||||
|
||||
Reference in New Issue
Block a user