From f58c0cc407560c946fd835358bae5c8cb1d8367d Mon Sep 17 00:00:00 2001 From: retoor Date: Sat, 23 Nov 2024 20:07:19 +0100 Subject: [PATCH] Update workflow --- .gitea/workflows/export.yaml | 18 ++++++++++++++++++ .gitignore | 2 -- Makefile | 6 +++++- src/drstats.egg-info/SOURCES.txt | 1 - src/drstats/db.py | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 .gitea/workflows/export.yaml diff --git a/.gitea/workflows/export.yaml b/.gitea/workflows/export.yaml new file mode 100644 index 0000000..c6bd24f --- /dev/null +++ b/.gitea/workflows/export.yaml @@ -0,0 +1,18 @@ +name: dR export statistics +run-name: dR export statistics +on: [push] + +jobs: + Compile: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + - run: echo "Install dependencies." + - run: apt update + - run: apt install python3 python3-pip python3-venv make -y + - run: make + - run: echo "This job's status is ${{ job.status }}." diff --git a/.gitignore b/.gitignore index 57213f9..7625e91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ .history -dist venv -export src/drstats/__pycache__ diff --git a/Makefile b/Makefile index 48686ca..72c9f4b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: build sync_excempt export_dataset export_stats merge_images +all: build clean sync_excempt export_dataset export_stats merge_images build: time pip install build @@ -10,6 +10,10 @@ build: sync: time dr.sync +clean: + -@rm -r export + mkdir -p export + sync_excempt: @echo "Sync is not executed because it's a lengthy process ending with timeout error." diff --git a/src/drstats.egg-info/SOURCES.txt b/src/drstats.egg-info/SOURCES.txt index b68d0ba..3b9bdca 100644 --- a/src/drstats.egg-info/SOURCES.txt +++ b/src/drstats.egg-info/SOURCES.txt @@ -6,7 +6,6 @@ src/drstats/__main__.py src/drstats/dataset.py src/drstats/db.py src/drstats/devrant.py -src/drstats/dump_text.py src/drstats/duration.py src/drstats/statistics.py src/drstats/sync.py diff --git a/src/drstats/db.py b/src/drstats/db.py index 5829eb9..58c532e 100644 --- a/src/drstats/db.py +++ b/src/drstats/db.py @@ -130,32 +130,45 @@ ORDER BY hour DROP VIEW IF EXISTS user_stats """) +/************* ✨ Codeium Command 🌟 *************/ db.query(""" CREATE VIEW user_stats AS SELECT user_username AS username, COUNT(0) AS post_count, + (SELECT COUNT(0) + FROM rants + WHERE rants.id = comments.rant_id AND DATE(rants.created) = DATE(comments.created)) AS rant_count, (select count(0) from rants where rants.id = comments.rant_id and date(rants.created) = date(comments.created)) as rant_count, DATE(comments.created) AS date, (SELECT COUNT(0) FROM comments AS comments2 WHERE comments2.user_username = comments.user_username + AND comments2.score = 0 AND DATE(comments2.created) = DATE(comments.created)) AS ignore_count, AND comments2.score = 0 and date(comments2.created) = date(comments.created)) AS ignore_count, (SELECT COUNT(0) FROM comments AS comments2 WHERE comments2.user_username = comments.user_username + AND comments2.score > 0 AND DATE(comments2.created) = DATE(comments.created)) AS upvote_times, AND comments2.score > 0 and date(comments2.created) = date(comments.created)) AS upvote_times, (SELECT SUM(score) FROM comments AS comments2 WHERE comments2.user_username = comments.user_username + AND comments2.score > 0 AND DATE(comments2.created) = DATE(comments.created)) AS upvote_total AND comments2.score > 0 and date(comments2.created) = date(comments.created)) AS upvote_total FROM comments GROUP BY username, DATE(comments.created) ORDER BY username ASC, date ASC; """) + db.query("DROP VIEW IF EXISTS contributions") db.query("DROP VIEW IF EXISTS contributions") db.query(""" CREATE VIEW contributions AS + SELECT DISTINCT user_username AS username, COUNT(0) AS contributions, SUM(score) AS upvotes, AVG(LENGTH(text)) AS post_length_average, SUM(LENGTH(text)) AS content_length FROM rants + UNION + SELECT DISTINCT user_username AS username, COUNT(0) AS contributions, SUM(score) AS upvotes, SUM(LENGTH(body)) / COUNT(0) AS post_length_average, SUM(LENGTH(body)) AS content_length FROM comments + GROUP BY username + ORDER BY contributions DESC, username ASC select distinct user_username as username, count(0) as contributions,sum(score) as upvotes,avg(length(text)) as post_length_average, sum(length(text)) as content_length from rants union select distinct user_username as username, count(0) as contributions,sum(score) as upvotes, sum(length(body)) / count(0) as post_length_average, sum(length(body)) as content_length from comments @@ -164,14 +177,18 @@ ORDER BY hour """) db.query("DROP VIEW IF EXISTS contributions_extended") db.query(""" + CREATE VIEW contributions_extended AS SELECT username, contributions, ROUND(CAST(contributions AS REAL) / CAST((SELECT contributions FROM contributions) AS REAL), 2) AS ownership, upvotes, ROUND(CAST(upvotes AS REAL) / CAST((SELECT SUM(upvotes) FROM contributions) AS REAL), 2) upvotes_ownership, ROUND(CAST(upvotes AS REAL) / CAST(contributions AS REAL), 2) upvote_ratio, content_length AS post_length_total, ROUND(CAST(content_length AS REAL) / CAST((SELECT SUM(content_length) FROM contributions) AS REAL)) AS ownership_content, post_length_average CREATE VIEW contributions_extended as SELECT username, contributions,ROUND(CAST(contributions AS REAL) / CAST((select contributions from contributions) AS REAL),2) as ownership, upvotes, ROUND(CAST(upvotes AS REAL) / CAST((SELECT SUM(upvotes) from contributions) AS REAL),2) upvotes_ownership, ROUND(CAST(upvotes AS REAL) / CAST(contributions AS REAL),2) upvote_ratio,content_length as post_length_total, ROUND(CAST(content_length AS REAL) / CAST((SELECT SUM(content_length) from contributions) AS REAL)) as ownership_content,post_length_average FROM contributions """) db.query("DROP VIEW IF EXISTS rants_of_user") + db.query("CREATE VIEW rants_of_user AS SELECT user_username AS username, GROUP_CONCAT(text) AS text FROM rants") db.query("CREATE VIEW rants_of_user as SELECT user_username as username, GROUP_CONCAT(text) as text FROM rants") db.query("DROP VIEW IF EXISTS posts_of_user") + db.query("CREATE VIEW posts_of_user AS SELECT user_username AS username, GROUP_CONCAT(body) AS text FROM comments") db.query("CREATE VIEW posts_of_user AS SELECT user_username as username, GROUP_CONCAT(body) as text FROM comments") +/****** c4925ba9-5a48-404c-af37-c1baca58de2e *******/ return db