stats for statoolinfos. wip/publish OK. Fix db check for publish

This commit is contained in:
Cyrille L 2023-03-11 17:56:11 +01:00
parent 57b401da70
commit 35794a8ae8
3 changed files with 34 additions and 33 deletions

View File

@ -18,7 +18,7 @@
#********************************************************************** #**********************************************************************
import os, sys, shutil, importlib import os, sys, shutil, importlib
import logs, args, db, html, tyto, domain import logs, args, db, html, tyto, domain, stats
#==============================# #==============================#
@ -39,7 +39,8 @@ def manage_publish(target):
'navbar' : html.create_navbar, 'navbar' : html.create_navbar,
'metas' : html.create_user_metas, 'metas' : html.create_user_metas,
'footer' : html.create_user_footer, 'footer' : html.create_user_footer,
'template' : create_template 'template' : create_template,
'stats' : stats.manage_stats
} }
do[target]('www') do[target]('www')
@ -63,9 +64,9 @@ def manage_publish(target):
if db.hash_wip: if db.hash_wip:
# wip and current article have different hash # wip and current article have different hash
if db.hash_post != db.hash_chk: if db.hash_post != db.hash_chk:
logs.out("25", db.uri_file, False) logs.out("9", db.uri_file, False)
err_pub = True err_pub = True
elif db.hash_post != db.hash_wip: elif db.hash_wip != db.hash_chk:
logs.out("30", db.uri_file, False) logs.out("30", db.uri_file, False)
err_pub = True err_pub = True

View File

@ -36,7 +36,7 @@ def manage_stats(process):
do = { do = {
'wip' : loop_articles, 'wip' : loop_articles,
'www' : loop_articles, 'publish' : loop_articles,
'show-wip' : count_stats, # NO 'show-wip' : count_stats, # NO
'show_www' : count_stats, # NO 'show_www' : count_stats, # NO
} }
@ -60,7 +60,8 @@ def loop_articles(process):
# Get databases of wip's articles # Get databases of wip's articles
for post_db in os.listdir(db.articles_db): for post_db in os.listdir(db.articles_db):
if post_db.endswith('.conf'): if not post_db.endswith('.conf'): continue
# Load DB # Load DB
post_db = '%s%s'%(db.articles_db, post_db) post_db = '%s%s'%(db.articles_db, post_db)
exec(open(post_db).read(),globals()) exec(open(post_db).read(),globals())
@ -68,25 +69,24 @@ def loop_articles(process):
importlib.reload(db) importlib.reload(db)
# Check hash status (wip/www) # Check hash status (wip/www)
# wip if process == 'wip': hash_srv = db.hash_wip
if process == 'wip': elif process == 'www': hash_srv = db.hash_www
if not db.hash_wip: continue
if not hash_srv: continue
print(':> [%s] | %s'%(db.title, db.post_src)) print(':> [%s] | %s'%(db.title, db.post_src))
# Article has changed and could have different stats # Article has changed and could have different stats
if not db.hash_wip == db.hash_chk: if hash_srv != db.hash_chk:
logs.out("9", db.post_src, False) logs.out("9", db.post_src, False)
continue continue
sti_articles += 1 sti_articles += 1
count_stats() count_stats()
# www # Create file if article
elif process == 'www': if sti_articles > 0: create_stats_file(file_uri)
if not db.hash_www: continue else: logs.out("28", '(%s stats)'%process, True)
create_stats_file(file_uri)
#================================# #================================#