Skip to content

Commit 3e37cee

Browse files
authored
Merge branch 'yihong0618:master' into master
2 parents 597cea4 + 371ce67 commit 3e37cee

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

run_page/gen_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def main():
243243
# circular not add footer and header
244244
p.drawer_type = "plain" if is_circular else "title"
245245
if args.type == "github":
246-
p.height = 55 + p.years.count() * 43
246+
p.height = 55 + p.years.real_year * 43
247247
# for special circular
248248
if is_circular:
249249
years = p.years.all()[:]

run_page/generator/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def sync(self, force):
6464
if self.only_run and activity.type != "Run":
6565
continue
6666
if IGNORE_BEFORE_SAVING:
67-
activity.summary_polyline = filter_out(activity.summary_polyline)
67+
if activity.map and activity.map.summary_polyline:
68+
activity.map.summary_polyline = filter_out(
69+
activity.map.summary_polyline
70+
)
6871
created = update_or_create_activity(self.session, activity)
6972
if created:
7073
sys.stdout.write("+")

run_page/gpxtrackposter/github_drawer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
3737
)
3838
year_length = total_length_year_dict.get(year, 0)
3939
year_length = format_float(self.poster.m2u(year_length))
40+
41+
if str(year_length) == "0.0":
42+
continue
4043
try:
4144
month_names = [
4245
locale.nl_langinfo(day)[:3] # Get only first three letters

run_page/gpxtrackposter/year_range.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(self):
2828
"""Inits YearRange with empty bounds -- to be built after init"""
2929
self.from_year = None
3030
self.to_year = None
31+
self.years_dict = dict()
3132

3233
def parse(self, s: str) -> bool:
3334
"""Parse a plaintext range of years into a pair of years
@@ -69,6 +70,11 @@ def add(self, t: datetime.datetime):
6970
self.from_year = t.year
7071
elif t.year > self.to_year:
7172
self.to_year = t.year
73+
"""record the year which has running data"""
74+
if t.year not in self.years_dict:
75+
self.years_dict[t.year] = 1
76+
else:
77+
self.years_dict[t.year] += 1
7278

7379
def contains(self, t: datetime.datetime) -> bool:
7480
"""Return True if current year range contains t, False if not"""
@@ -82,5 +88,10 @@ def count(self) -> Optional[int]:
8288
return None
8389
return 1 + self.to_year - self.from_year
8490

91+
@property
92+
def real_year(self):
93+
"""Return number of years which has running data"""
94+
return len(self.years_dict)
95+
8596
def all(self):
8697
return list(range(int(self.from_year), int(self.to_year) + 1))

0 commit comments

Comments
 (0)