Only check for missing scores

This commit is contained in:
2022-05-31 10:35:02 -05:00
parent 5fef7f8332
commit 8c3494e35d
3 changed files with 26 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ ipython = "^8.4.0"
wordlinator = "wordlinator.app:sync_main"
update = "wordlinator.app:sync_update"
show-user = "wordlinator.app:sync_show_user"
show-missing = "wordlinator.app:sync_show_missing"
[tool.mypy]
ignore_missing_imports = true

View File

@@ -12,7 +12,7 @@ import wordlinator.utils
async def get_scores(
wordle_day: wordlinator.utils.WordleDay = wordlinator.utils.WORDLE_TODAY,
):
users = wordlinator.sheets.SheetsClient().get_users()
users = wordlinator.sheets.SheetsClient(wordle_day=wordle_day).get_missing_names()
twitter_client = wordlinator.twitter.TwitterClient(wordle_day=wordle_day)
@@ -81,6 +81,13 @@ async def show_user(username: str):
rich.print(scores)
async def show_missing(
wordle_day: wordlinator.utils.WordleDay = wordlinator.utils.WORDLE_TODAY,
):
client = wordlinator.sheets.SheetsClient(wordle_day=wordle_day)
rich.print(client.get_missing_names())
def _get_day():
parser = argparse.ArgumentParser("wordlinator")
days = parser.add_mutually_exclusive_group()
@@ -118,5 +125,10 @@ def sync_show_user():
asyncio.run(show_user(args.username))
def sync_show_missing():
wordle_day = _get_day()
asyncio.run(show_missing(wordle_day=wordle_day))
if __name__ == "__main__":
sync_main()

View File

@@ -99,6 +99,18 @@ class SheetsClient:
scores = ranges[1].get("values", [])
return self.score_dict(names, scores, completed_only=completed_only)
def get_missing_names(self):
if self.game_round is None:
raise ValueError(
"Cannot check missing names when day is not in a game round."
)
scores = self.get_scores()
missing_scores = []
for name, score_list in scores.items():
if len(score_list) < self.game_round or not score_list[self.game_round - 1]:
missing_scores.append(name)
return missing_scores
def write_scores(self, score_dict):
body = {"values": list(score_dict.values())}
sheets = self.client.spreadsheets()