feat: add avg in feedback, add post votes
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
56f1026341
commit
6b2cf74eae
1 changed files with 43 additions and 12 deletions
55
commands.py
55
commands.py
|
@ -251,15 +251,13 @@ async def user_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
)
|
||||
)
|
||||
if user_data["is_banned"]:
|
||||
ban_data = get_json(
|
||||
f"bans", [f"search[user_id]={user_data['id']}"]
|
||||
)[0]
|
||||
ban_data = get_json(f"bans", [f"search[user_id]={user_data['id']}"])[0]
|
||||
m.append(
|
||||
" ".join(
|
||||
[
|
||||
"Ban reason:",
|
||||
ban_data["reason"],
|
||||
f"(banned for {timedelta(seconds=ban_data['duration'])})"
|
||||
f"(banned for {timedelta(seconds=ban_data['duration'])})",
|
||||
]
|
||||
)
|
||||
)
|
||||
|
@ -277,6 +275,32 @@ async def user_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
]
|
||||
)
|
||||
)
|
||||
upvote_post_count = get_json(
|
||||
f"counts/posts", [f"tags=upvote:{user_data['name']}"]
|
||||
)["counts"]["posts"]
|
||||
downvote_post_count = get_json(
|
||||
f"counts/posts", [f"tags=downvote:{user_data['name']}"]
|
||||
)["counts"]["posts"]
|
||||
vote_post_count = upvote_post_count + downvote_post_count
|
||||
m.append(
|
||||
" ".join(
|
||||
[
|
||||
"Post Votes:",
|
||||
html_parser.hyperlink(
|
||||
f"up:{upvote_post_count}",
|
||||
f"{app.protocol}://{app.hostname}/post_votes?search[user_name]={user_data['name']}&search[score]=1",
|
||||
),
|
||||
html_parser.hyperlink(
|
||||
f"down:{downvote_post_count}",
|
||||
f"{app.protocol}://{app.hostname}/post_votes?search[user_name]={user_data['name']}&search[score]=-1",
|
||||
),
|
||||
html_parser.hyperlink(
|
||||
f"total:{vote_post_count}",
|
||||
f"{app.protocol}://{app.hostname}/post_votes?search[user_name]={user_data['name']}",
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
m.append(
|
||||
" ".join(
|
||||
[
|
||||
|
@ -394,18 +418,25 @@ async def user_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
]
|
||||
)
|
||||
)
|
||||
avg_feedback_count = user_data["positive_feedback_count"] - user_data["negative_feedback_count"]
|
||||
m.append(
|
||||
" ".join(
|
||||
[
|
||||
"Feedback:",
|
||||
html_parser.hyperlink(
|
||||
" ".join(
|
||||
[
|
||||
f"positive:{user_data['positive_feedback_count']}",
|
||||
f"neutral:{user_data['neutral_feedback_count']}",
|
||||
f"negative:{user_data['negative_feedback_count']}",
|
||||
]
|
||||
),
|
||||
f"positive:{user_data['positive_feedback_count']}",
|
||||
f"{app.protocol}://{app.hostname}/user_feedbacks?search[user_name]={user_data['name']}&search[category]=positive",
|
||||
),
|
||||
html_parser.hyperlink(
|
||||
f"neutral:{user_data['neutral_feedback_count']}",
|
||||
f"{app.protocol}://{app.hostname}/user_feedbacks?search[user_name]={user_data['name']}&search[category]=neutral",
|
||||
),
|
||||
html_parser.hyperlink(
|
||||
f"negative:{user_data['negative_feedback_count']}",
|
||||
f"{app.protocol}://{app.hostname}/user_feedbacks?search[user_name]={user_data['name']}&search[category]=negative",
|
||||
),
|
||||
html_parser.hyperlink(
|
||||
f"avg:{avg_feedback_count}",
|
||||
f"{app.protocol}://{app.hostname}/user_feedbacks?search[user_name]={user_data['name']}",
|
||||
),
|
||||
]
|
||||
|
@ -417,7 +448,7 @@ async def user_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
message.message_id,
|
||||
parse_mode=ParseMode.HTML,
|
||||
reply_markup=reply_markup,
|
||||
disable_web_page_preview=True
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
except (IndexError, ValueError):
|
||||
await update.message.reply_text(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue