Add in stats file: authors number

This commit is contained in:
Cyrille L 2023-04-05 08:22:51 +02:00
parent b32046e183
commit cba1abbe8a
2 changed files with 21 additions and 4 deletions

View File

@ -435,9 +435,6 @@ def check_opt_tags(post_header):
for ln, line in enumerate(post_header, 1): for ln, line in enumerate(post_header, 1):
if line.startswith('%s:'%tag): if line.startswith('%s:'%tag):
check_3lines(tag, ln, line) check_3lines(tag, ln, line)
print("> post_files =", post_files)
print("> post_links =", post_links)
#============================================# #============================================#

View File

@ -98,7 +98,11 @@ def loop_articles(process):
def count_stats(add): def count_stats(add):
# Set # Set
if not add: if not add:
global stats global stats, authors, author_names
# Specific for Authors (not in database stats)
author_names = author.replace(' ', '').split(",")
authors = 0
stats = { \ stats = { \
"sti_uniq_anchors" : uniq_anchors, "sti_uniq_anchors" : uniq_anchors,
@ -137,6 +141,17 @@ def count_stats(add):
# Count # Count
else: else:
# Authors are not set in database stats
new_authors = author.replace(' ', '').split(",")
# Do not count author if known
for name in new_authors:
if name in author_names:
continue
author_names = author_names + [name]
# From database stats
for i in stats: for i in stats:
stat_db = i.rsplit("sti_")[1] stat_db = i.rsplit("sti_")[1]
stats[i] = stats[i] + eval(stat_db) stats[i] = stats[i] + eval(stat_db)
@ -146,6 +161,9 @@ def count_stats(add):
# Create stat file in server # # Create stat file in server #
#----------------------------# #----------------------------#
def create_stats_file(file_uri): def create_stats_file(file_uri):
# Count authors
authors = len(author_names)
sti = \ sti = \
'# Statistics file created by %s\n'%tyto.Tyto + \ '# Statistics file created by %s\n'%tyto.Tyto + \
'# Website: %s\n'%domain_srv + \ '# Website: %s\n'%domain_srv + \
@ -154,6 +172,7 @@ def create_stats_file(file_uri):
'\n' + \ '\n' + \
'# Uniq statistics from articles\' headers\n' + \ '# Uniq statistics from articles\' headers\n' + \
'articles = %d\n'%int(sti_articles) + \ 'articles = %d\n'%int(sti_articles) + \
'uniq_authors = %d\n'%int(authors) + \
'uniq_anchors = %d\n'%stats["sti_uniq_anchors"] + \ 'uniq_anchors = %d\n'%stats["sti_uniq_anchors"] + \
'uniq_abbrs = %d\n'%stats["sti_uniq_abbrs"] + \ 'uniq_abbrs = %d\n'%stats["sti_uniq_abbrs"] + \
'uniq_links = %d\n'%stats["sti_uniq_links"] + \ 'uniq_links = %d\n'%stats["sti_uniq_links"] + \
@ -203,3 +222,4 @@ def create_stats_file(file_uri):
sti_articles, stats["sti_words"] sti_articles, stats["sti_words"]
) )
) )