Show number of reviews in table.
This commit is contained in:
parent
2beaecaab0
commit
8ce7859f08
1 changed files with 22 additions and 17 deletions
|
@ -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
|
# 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
|
# tags and highlights, as well as the actual game_name
|
||||||
if type_name == "Updates":
|
def row(r):
|
||||||
name = lambda r: "[{name}]({nfo})".format(name=r["rls_name"], nfo=r["nfo_link"])
|
if type_name == "Updates":
|
||||||
else:
|
name = "[{}]({})".format(r["rls_name"], r["nfo_link"])
|
||||||
tags = lambda r: " ({})".format(" ".join(r["tags"])) if r["tags"] else ""
|
else:
|
||||||
highlights = lambda r: " **- {}**".format(", ".join(r["highlights"])) if r["highlights"] else ""
|
tags = " ({})".format(" ".join(r["tags"])) if r["tags"] else ""
|
||||||
name = lambda r: "[{name}{tags}]({nfo}){highlights}".format(name=r["game_name"],
|
highlights = " **- {}**".format(", ".join(r["highlights"])) if r["highlights"] else ""
|
||||||
tags=tags(r),
|
name = "[{}{}]({}){}".format(r["game_name"], tags, r["nfo_link"], highlights)
|
||||||
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"])
|
|
||||||
|
|
||||||
# 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.
|
# 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:
|
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,
|
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)]
|
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("")
|
||||||
post.append(" ")
|
post.append(" ")
|
||||||
|
|
Reference in a new issue