Skip to content

Commit 8fbdbcf

Browse files
committed
set default 'current' when getting reading goals
1 parent c5c55c4 commit 8fbdbcf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

openlibrary/plugins/upstream/yearly_reading_goals.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@ def GET(self):
2727
username = user['key'].split('/')[-1]
2828
if i.year:
2929
results = [
30-
{'year': i.year, 'goal': record.target, 'progress': record.current}
30+
{
31+
'year': i.year,
32+
'goal': record.target,
33+
'progress': getattr(record, 'current', 0),
34+
}
3135
for record in YearlyReadingGoals.select_by_username_and_year(
3236
username, i.year
3337
)
3438
]
3539
else:
3640
results = [
37-
{'year': record.year, 'goal': record.target, 'progress': record.current}
41+
{
42+
'year': record.year,
43+
'goal': record.target,
44+
'progress': getattr(record, 'current', 0),
45+
}
3846
for record in YearlyReadingGoals.select_by_username(username)
3947
]
4048

0 commit comments

Comments
 (0)