This commit is contained in:
parent
ee470de884
commit
c807f87f60
@ -130,45 +130,32 @@ ORDER BY hour
|
|||||||
DROP VIEW IF EXISTS user_stats
|
DROP VIEW IF EXISTS user_stats
|
||||||
""")
|
""")
|
||||||
|
|
||||||
/************* ✨ Codeium Command 🌟 *************/
|
|
||||||
db.query("""
|
db.query("""
|
||||||
CREATE VIEW user_stats AS
|
CREATE VIEW user_stats AS
|
||||||
SELECT
|
SELECT
|
||||||
user_username AS username,
|
user_username AS username,
|
||||||
COUNT(0) AS post_count,
|
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,
|
(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,
|
DATE(comments.created) AS date,
|
||||||
(SELECT COUNT(0)
|
(SELECT COUNT(0)
|
||||||
FROM comments AS comments2
|
FROM comments AS comments2
|
||||||
WHERE comments2.user_username = comments.user_username
|
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,
|
AND comments2.score = 0 and date(comments2.created) = date(comments.created)) AS ignore_count,
|
||||||
(SELECT COUNT(0)
|
(SELECT COUNT(0)
|
||||||
FROM comments AS comments2
|
FROM comments AS comments2
|
||||||
WHERE comments2.user_username = comments.user_username
|
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,
|
AND comments2.score > 0 and date(comments2.created) = date(comments.created)) AS upvote_times,
|
||||||
(SELECT SUM(score)
|
(SELECT SUM(score)
|
||||||
FROM comments AS comments2
|
FROM comments AS comments2
|
||||||
WHERE comments2.user_username = comments.user_username
|
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
|
AND comments2.score > 0 and date(comments2.created) = date(comments.created)) AS upvote_total
|
||||||
FROM comments
|
FROM comments
|
||||||
GROUP BY username, DATE(comments.created)
|
GROUP BY username, DATE(comments.created)
|
||||||
ORDER BY username ASC, date ASC;
|
ORDER BY username ASC, date ASC;
|
||||||
""")
|
""")
|
||||||
db.query("DROP VIEW IF EXISTS contributions")
|
|
||||||
db.query("DROP VIEW IF EXISTS contributions")
|
db.query("DROP VIEW IF EXISTS contributions")
|
||||||
db.query("""
|
db.query("""
|
||||||
CREATE VIEW contributions AS
|
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
|
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
|
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
|
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
|
||||||
@ -177,18 +164,14 @@ ORDER BY hour
|
|||||||
""")
|
""")
|
||||||
db.query("DROP VIEW IF EXISTS contributions_extended")
|
db.query("DROP VIEW IF EXISTS contributions_extended")
|
||||||
db.query("""
|
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
|
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
|
FROM contributions
|
||||||
""")
|
""")
|
||||||
db.query("DROP VIEW IF EXISTS rants_of_user")
|
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("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("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")
|
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
|
return db
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user