Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and kevinc16 committed Jun 5, 2024
1 parent 8e92de6 commit ac53068
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 7 additions & 3 deletions openlibrary/core/bookshelves_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ def summary(cls):
return {
'total_yearly_reading_goals': {
'total': BookshelvesEvents.total_yearly_reading_goals(),
'month': BookshelvesEvents.total_yearly_reading_goals(since=DATE_ONE_MONTH_AGO),
'week': BookshelvesEvents.total_yearly_reading_goals(since=DATE_ONE_WEEK_AGO),
'month': BookshelvesEvents.total_yearly_reading_goals(
since=DATE_ONE_MONTH_AGO
),
'week': BookshelvesEvents.total_yearly_reading_goals(
since=DATE_ONE_WEEK_AGO
),
},
}

Expand Down Expand Up @@ -138,7 +142,7 @@ def select_distinct_by_user_type_and_year(cls, username, event_type, year):

@classmethod
def total_yearly_reading_goals(cls, since: date | None = None) -> int:
"""Returns a Storage object of <Storage {'count': int}> where 'count' specifies the
"""Returns a Storage object of <Storage {'count': int}> where 'count' specifies the
number reading goals updated. `since` may be used
to limit the result to those reading goals updated since a specific
date. Any python datetime.date type should work.
Expand Down
4 changes: 4 additions & 0 deletions openlibrary/i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,10 @@ msgstr ""
msgid "Users Logging"
msgstr ""

#: admin/index.html
msgid "Yearly Reading Goals"
msgstr ""

#: admin/index.html
msgid "Books Review Tags"
msgstr ""
Expand Down
5 changes: 4 additions & 1 deletion openlibrary/tests/core/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ def teardown_method(self):
def test_total_yearly_reading_goals(self):
assert BookshelvesEvents.total_yearly_reading_goals()['count(*)'] == 3
# Combination of issues
assert BookshelvesEvents.total_yearly_reading_goals(since="2022-12-25")['count(*)'] == 1
assert (
BookshelvesEvents.total_yearly_reading_goals(since="2022-12-25")['count(*)']
== 1
)

def test_create(self):
assert len(list(self.db.select(self.TABLENAME))) == 3
Expand Down

0 comments on commit ac53068

Please sign in to comment.