1
0
Fork 0

Show number of reviews in table.

This commit is contained in:
Casper V. Kristensen 2018-08-01 03:31:50 +02:00
parent 2beaecaab0
commit 8ce7859f08
Signed by: caspervk
GPG key ID: B1156723DB3BDDA8

View file

@ -300,29 +300,34 @@ class DailyReleasesBot(object):
# The sub-tables for updates will use the entire rls_name as the name, while games and dlcs will show
# tags and highlights, as well as the actual game_name
def row(r):
if type_name == "Updates":
name = lambda r: "[{name}]({nfo})".format(name=r["rls_name"], nfo=r["nfo_link"])
name = "[{}]({})".format(r["rls_name"], r["nfo_link"])
else:
tags = lambda r: " ({})".format(" ".join(r["tags"])) if r["tags"] else ""
highlights = lambda r: " **- {}**".format(", ".join(r["highlights"])) if r["highlights"] else ""
name = lambda r: "[{name}{tags}]({nfo}){highlights}".format(name=r["game_name"],
tags=tags(r),
nfo=r["nfo_link"],
highlights=highlights(r))
review = lambda r: "{:.0%}".format(r["review_score"]) if r["review_score"] != -1 else "-"
store = lambda r: "[{}]({})".format(r["store_name"], r["store_link"])
tags = " ({})".format(" ".join(r["tags"])) if r["tags"] else ""
highlights = " **- {}**".format(", ".join(r["highlights"])) if r["highlights"] else ""
name = "[{}{}]({}){}".format(r["game_name"], tags, r["nfo_link"], highlights)
# Releases in these sub-tables are grouped by release group, and the groups are ordered according to the
if r["review_score"] != -1:
review_score = "{:.0%} ^^\({}\)".format(r["review_score"], r["popularity"])
else:
review_score = "-"
store = "[{}]({})".format(r["store_name"], r["store_link"])
return name, r["group"], review_score, store
# Releases in the sub-tables are grouped by release group, and the groups are ordered according to the
# most popular game within the group. Games are sorted by popularity internally in the groups.
max_group_popularity = defaultdict(int)
group_popularity = defaultdict(int)
for rls in type_releases:
max_group_popularity[rls["group"]] = max(max_group_popularity[rls["group"]], rls["popularity"])
group_popularity[rls["group"]] = max(group_popularity[rls["group"]], rls["popularity"])
table = [(name(rls), rls["group"], review(rls), store(rls))
table = [row(rls)
for rls in sorted(type_releases,
key=lambda r: (max_group_popularity[r["group"]], r["popularity"]),
key=lambda r: (group_popularity[r["group"]], r["group"], r["popularity"]),
reverse=True)]
post.append(tabulate(table, headers=(type_name, "Group", "Reviews", "Store"), tablefmt="pipe"))
post.append(tabulate(table, headers=(type_name, "Group", "Score", "Store"), tablefmt="pipe"))
post.append("")
post.append(" ")