Update workflow
This commit is contained in:
parent
190456236a
commit
f58c0cc407
18
.gitea/workflows/export.yaml
Normal file
18
.gitea/workflows/export.yaml
Normal file
@ -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 }}."
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
.history
|
||||
dist
|
||||
venv
|
||||
export
|
||||
src/drstats/__pycache__
|
||||
|
6
Makefile
6
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."
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user