Show number of reviews in table.
This commit is contained in:
parent
2beaecaab0
commit
8ce7859f08
|
@ -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
|
||||
if type_name == "Updates":
|
||||
name = lambda r: "[{name}]({nfo})".format(name=r["rls_name"], nfo=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"])
|
||||
def row(r):
|
||||
if type_name == "Updates":
|
||||
name = "[{}]({})".format(r["rls_name"], r["nfo_link"])
|
||||
else:
|
||||
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(" ")
|
||||
|
|
Reference in a new issue