Skip to content

Commit

Permalink
Merge pull request #5 from JacksonBurns/small_fix
Browse files Browse the repository at this point in the history
Couple small fixes
  • Loading branch information
TomasTomecek authored Mar 13, 2024
2 parents 74d9ba4 + c8237f3 commit 134a928
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions show_me/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"""
import json
import logging
from datetime import date
from typing import Dict, List

import requests
Expand Down Expand Up @@ -237,10 +238,10 @@ def get_contributions(self, start_year: int) -> List[Dict]:
# we could make this function async and display stuff real-time
json_set = []
j = None
if start_year >= 2020:
raise RuntimeError("The start year should be smaller than 2020.")
# FIXME: default to current date+time
years_to_scan = iter(range(start_year, 2020))
current_year = date.today().year
if start_year >= current_year:
raise RuntimeError(f"The start year should be smaller than {current_year}.")
years_to_scan = iter(range(start_year, current_year))
year = next(years_to_scan)
while True:
query = self._get_template_query(year, last_response=j)
Expand Down
5 changes: 3 additions & 2 deletions show_me/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def convert(self, value, param, ctx):

@click.command(context_settings=CONTEXT_SETTINGS)
@click.option(
"-n", "--lines", default=15, show_default=True, help="Print first N lines."
"-n", "--lines", default=15, show_default=True, help="Print first N lines (-1 for all)."
)
@click.option(
"--cache-file-path",
Expand Down Expand Up @@ -102,6 +102,7 @@ def main(load_from_cache, save_to_cache, cache_file_path, debug, lines, start_ye
a.cache_to_file(c)
repo_stats: Iterable[RepositoryStat] = a.get_stats(c)

slice = repo_stats if lines == -1 else repo_stats[:lines]
data = [
(
x.name_with_owner,
Expand All @@ -112,7 +113,7 @@ def main(load_from_cache, save_to_cache, cache_file_path, debug, lines, start_ye
x.commit_count,
x.review_count,
)
for x in repo_stats[:lines]
for x in slice
]

headers = ("Repo", "★", "Total", "Pulls", "Issues", "Commits", "Reviews")
Expand Down

0 comments on commit 134a928

Please sign in to comment.