Skip to content

Commit 74a0fe1

Browse files
authored
Search actual date in view/clone stat
fix #12
1 parent 68b6d21 commit 74a0fe1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/writegithubstat/githubstat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ def _get_actual_stat(
162162
self, data: Dict[str, Any], name: str
163163
) -> Dict[str, Union[int, str]]:
164164
try:
165-
stat = data[name][-1]
166-
if not stat["timestamp"].startswith(self._date):
167-
raise ValueError(
168-
f"The views data for the date {self._date} is not available."
169-
)
170-
return stat
165+
for stat in data[name]:
166+
if stat["timestamp"].startswith(self._date):
167+
return stat
168+
raise ValueError(
169+
f"The views data for the date {self._date} is not available."
170+
)
171171
except (KeyError, IndexError, ValueError):
172172
return {"count": 0, "uniques": 0}
173173

0 commit comments

Comments
 (0)