This commit is contained in:
parent
f780447eb1
commit
518b9534ba
@ -11,8 +11,8 @@ cols = 2
|
|||||||
|
|
||||||
images = list(Path("./export/").glob("*.png"))
|
images = list(Path("./export/").glob("*.png"))
|
||||||
image_count = len(images)
|
image_count = len(images)
|
||||||
total_image_height = (image_count / cols * per_image_height)
|
total_image_height = image_count / cols * per_image_height
|
||||||
if(image_count / cols * per_image_height > total_image_height):
|
if image_count / cols * per_image_height > total_image_height:
|
||||||
total_image_height += per_image_height
|
total_image_height += per_image_height
|
||||||
total_image_width = image_count / cols * per_image_width
|
total_image_width = image_count / cols * per_image_width
|
||||||
|
|
||||||
@ -23,7 +23,11 @@ for path in images:
|
|||||||
image = image.resize((per_image_width, per_image_height))
|
image = image.resize((per_image_width, per_image_height))
|
||||||
resized_images.append((path, image))
|
resized_images.append((path, image))
|
||||||
|
|
||||||
new_image = Image.new("RGB",(per_image_width * cols, int(per_image_height * image_count / cols)), (250,250,250))
|
new_image = Image.new(
|
||||||
|
"RGB",
|
||||||
|
(per_image_width * cols, int(per_image_height * image_count / cols)),
|
||||||
|
(250, 250, 250),
|
||||||
|
)
|
||||||
|
|
||||||
current_col = 0
|
current_col = 0
|
||||||
current_row = 0
|
current_row = 0
|
||||||
|
@ -4,6 +4,7 @@ import sys
|
|||||||
|
|
||||||
printr = functools.partial(print, file=sys.stderr)
|
printr = functools.partial(print, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def dump():
|
def dump():
|
||||||
statistics_text = [
|
statistics_text = [
|
||||||
f"devRant(developer community) haves {db.get_user_count()} active users(ranters)."
|
f"devRant(developer community) haves {db.get_user_count()} active users(ranters)."
|
||||||
@ -17,18 +18,28 @@ def dump():
|
|||||||
)
|
)
|
||||||
printr(statistics_text[-1])
|
printr(statistics_text[-1])
|
||||||
print("\n".join(statistics_text))
|
print("\n".join(statistics_text))
|
||||||
all_content = ''
|
all_content = ""
|
||||||
for user in db.get_users():
|
for user in db.get_users():
|
||||||
text = db.get_all_rants_of_user(user).replace("\n"," ").replace(" "," ").strip()
|
text = (
|
||||||
|
db.get_all_rants_of_user(user).replace("\n", " ").replace(" ", " ").strip()
|
||||||
|
)
|
||||||
total_text = ""
|
total_text = ""
|
||||||
if text:
|
if text:
|
||||||
total_text += text
|
total_text += text
|
||||||
print("```",f"All rants written by user(ranter) `{user}` on devRant(developer community)```.")
|
print(
|
||||||
|
"```",
|
||||||
|
f"All rants written by user(ranter) `{user}` on devRant(developer community)```.",
|
||||||
|
)
|
||||||
print(text, "```")
|
print(text, "```")
|
||||||
text = db.get_all_posts_of_user(user).replace("\n", " ").replace(" "," ").strip()
|
text = (
|
||||||
|
db.get_all_posts_of_user(user).replace("\n", " ").replace(" ", " ").strip()
|
||||||
|
)
|
||||||
if text:
|
if text:
|
||||||
total_text += text
|
total_text += text
|
||||||
print("```",f"All posts written by user(ranter) `{user}` on devRant(developer community): ```.")
|
print(
|
||||||
|
"```",
|
||||||
|
f"All posts written by user(ranter) `{user}` on devRant(developer community): ```.",
|
||||||
|
)
|
||||||
print(text, "```")
|
print(text, "```")
|
||||||
all_content += total_text
|
all_content += total_text
|
||||||
|
|
||||||
@ -37,6 +48,3 @@ def dump():
|
|||||||
line = f"{user} is {all_content.count(mention_text)} times mentioned on devRant(developer comminity)."
|
line = f"{user} is {all_content.count(mention_text)} times mentioned on devRant(developer comminity)."
|
||||||
printr(line)
|
printr(line)
|
||||||
print(line)
|
print(line)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Duration:
|
class Duration:
|
||||||
|
|
||||||
def __init__(self, description):
|
def __init__(self, description):
|
||||||
|
@ -188,7 +188,9 @@ async def score_most_ignored_last_7_days():
|
|||||||
x = []
|
x = []
|
||||||
y = []
|
y = []
|
||||||
|
|
||||||
for record in db.query("SELECT * FROM score_ignored_most_last_7_days LIMIT 15"):
|
for record in db.query(
|
||||||
|
"SELECT * FROM score_ignored_most_last_7_days LIMIT 15"
|
||||||
|
):
|
||||||
x.append(record["username"])
|
x.append(record["username"])
|
||||||
y.append(record["userscore"])
|
y.append(record["userscore"])
|
||||||
|
|
||||||
@ -199,7 +201,9 @@ async def score_most_ignored_last_7_days():
|
|||||||
plt.ylabel("Times ignored")
|
plt.ylabel("Times ignored")
|
||||||
plt.title("Most ignored based on score regarding last 7 days")
|
plt.title("Most ignored based on score regarding last 7 days")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig(f"export/score_ignored_most_last_7_days_{get_date_range_str()}.png")
|
plt.savefig(
|
||||||
|
f"export/score_ignored_most_last_7_days_{get_date_range_str()}.png"
|
||||||
|
)
|
||||||
plt_reset()
|
plt_reset()
|
||||||
# plt.show()
|
# plt.show()
|
||||||
|
|
||||||
@ -226,6 +230,7 @@ async def score_last_7_days():
|
|||||||
plt_reset()
|
plt_reset()
|
||||||
# plt.show()
|
# plt.show()
|
||||||
|
|
||||||
|
|
||||||
async def user_score_per_day(username):
|
async def user_score_per_day(username):
|
||||||
with Duration("User {} score per day".format(username)):
|
with Duration("User {} score per day".format(username)):
|
||||||
plt = figure_inc()
|
plt = figure_inc()
|
||||||
@ -239,28 +244,36 @@ async def user_score_per_day(username):
|
|||||||
x = []
|
x = []
|
||||||
y = []
|
y = []
|
||||||
|
|
||||||
for record in db.query("SELECT * FROM user_stats WHERE username = '{}'".format(username)):
|
for record in db.query(
|
||||||
|
"SELECT * FROM user_stats WHERE username = '{}'".format(username)
|
||||||
|
):
|
||||||
x.append(record["date"])
|
x.append(record["date"])
|
||||||
y.append(record["post_count"])
|
y.append(record["post_count"])
|
||||||
plt.plot(x, y, label="Posts")
|
plt.plot(x, y, label="Posts")
|
||||||
|
|
||||||
x = []
|
x = []
|
||||||
y = []
|
y = []
|
||||||
for record in db.query("SELECT * FROM user_stats WHERE username = '{}'".format(username)):
|
for record in db.query(
|
||||||
|
"SELECT * FROM user_stats WHERE username = '{}'".format(username)
|
||||||
|
):
|
||||||
x.append(record["date"])
|
x.append(record["date"])
|
||||||
y.append(record["ignore_count"])
|
y.append(record["ignore_count"])
|
||||||
plt.plot(x, y, label="Times ignored")
|
plt.plot(x, y, label="Times ignored")
|
||||||
|
|
||||||
x = []
|
x = []
|
||||||
y = []
|
y = []
|
||||||
for record in db.query("SELECT * FROM user_stats WHERE username = '{}'".format(username)):
|
for record in db.query(
|
||||||
|
"SELECT * FROM user_stats WHERE username = '{}'".format(username)
|
||||||
|
):
|
||||||
x.append(record["date"])
|
x.append(record["date"])
|
||||||
y.append(record["upvote_times"])
|
y.append(record["upvote_times"])
|
||||||
plt.plot(x, y, label="Times upvoted")
|
plt.plot(x, y, label="Times upvoted")
|
||||||
|
|
||||||
x = []
|
x = []
|
||||||
y = []
|
y = []
|
||||||
for record in db.query("SELECT * FROM user_stats WHERE username = '{}'".format(username)):
|
for record in db.query(
|
||||||
|
"SELECT * FROM user_stats WHERE username = '{}'".format(username)
|
||||||
|
):
|
||||||
x.append(record["date"])
|
x.append(record["date"])
|
||||||
y.append(record["upvote_total"])
|
y.append(record["upvote_total"])
|
||||||
plt.plot(x, y, label="Sum upvotes")
|
plt.plot(x, y, label="Sum upvotes")
|
||||||
@ -284,7 +297,3 @@ def rant_stats_all():
|
|||||||
asyncio.run(score_last_7_days())
|
asyncio.run(score_last_7_days())
|
||||||
for user in get_users():
|
for user in get_users():
|
||||||
asyncio.run(user_score_per_day(user))
|
asyncio.run(user_score_per_day(user))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import json
|
|||||||
import asyncio
|
import asyncio
|
||||||
from pprint import pprint as pp
|
from pprint import pprint as pp
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
dr = Devrant()
|
dr = Devrant()
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ async def get_recent_rants(start_from=1, page_size=10):
|
|||||||
yield rant
|
yield rant
|
||||||
start_from += page_size
|
start_from += page_size
|
||||||
|
|
||||||
|
|
||||||
async def sync_rants():
|
async def sync_rants():
|
||||||
count = 0
|
count = 0
|
||||||
start_from = 0
|
start_from = 0
|
||||||
@ -54,6 +56,7 @@ async def sync_rants():
|
|||||||
except:
|
except:
|
||||||
print("Rate limit of server exceeded. That's normal.s")
|
print("Rate limit of server exceeded. That's normal.s")
|
||||||
|
|
||||||
|
|
||||||
async def sync_comments():
|
async def sync_comments():
|
||||||
comments_synced = 0
|
comments_synced = 0
|
||||||
rants_synced = 0
|
rants_synced = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user