From 83c1d8c73c3cd1dd3a92321e3499e5fdd580f1eb Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Sun, 26 Feb 2023 22:51:52 +0100 Subject: [PATCH] add stats --- stats.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/stats.py b/stats.py index 200cd57..05a4967 100644 --- a/stats.py +++ b/stats.py @@ -82,12 +82,24 @@ select sum(array_length(regexp_split_to_array(text,'\\s'),1)) from line """ +class TotalLines(SingleValueStats): + query = """ +select count(1) from line +""" + + +class TotalPhrases(SingleValueStats): + query = """ +select count(1) from phrase +""" + + class PhraseTableSize(SingleValueStats): - query = "SELECT pg_size_pretty(pg_relation_size('phrase'));" + query = "SELECT pg_size_pretty(pg_relation_size('phrase')) as size;" class LineTableSize(SingleValueStats): - query = "SELECT pg_size_pretty(pg_relation_size('line'));" + query = "SELECT pg_size_pretty(pg_relation_size('line')) as size;" class TotalVideoTime(SingleValueStats): @@ -99,7 +111,8 @@ from (select distinct on (episode_id) endtime from line order by episode_id, "or def aggregate_stats(plaintext: bool): text = "" data = {} - for stats_class in [TotalWords, PhraseTableSize, LineTableSize, TotalVideoTime, MostCommonNounChunks, + for stats_class in [TotalLines, TotalWords, TotalPhrases, PhraseTableSize, LineTableSize, TotalVideoTime, + MostCommonNounChunks, LongestNounChunks, LinesPerPerson]: name = type(stats_class()).__name__ if plaintext: