Skip to content

Commit b8c3dcb

Browse files
committed
feature, test: completed the selections by time interval
1 parent b3b1931 commit b8c3dcb

File tree

10 files changed

+153
-61
lines changed

10 files changed

+153
-61
lines changed

.github/workflows/code-check-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
- run: pipx install "poetry~=2.0.0"
4545
- run: poetry install --with dev
4646
- run: poetry run ruff check --select I .
47-
- run: poetry run pytest --cov=git_analytics --cov-report=term-missing --cov-fail-under=30
47+
- run: poetry run pytest --cov=git_analytics --cov-report=term-missing --cov-fail-under=40

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ poetry run git-analytics
4949

5050
```bash
5151
poetry run pytest
52-
poetry run pytest --cov=git_analytics --cov-report=term-missing --cov-fail-under=30
52+
poetry run pytest --cov=git_analytics --cov-report=term-missing --cov-fail-under=40
5353
```
5454

5555
### Type Checking

git_analytics/engine.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ def run(
2020
stop_date: Optional[date] = None,
2121
) -> Dict[str, AnalyticsResult]:
2222
analyzers = self._analyzers_factory()
23+
24+
if start_date and stop_date and start_date > stop_date:
25+
start_date, stop_date = stop_date, start_date
26+
2327
for commit in self._source.iter_commits():
24-
if start_date and stop_date:
25-
commit_day = commit.committed_datetime.astimezone(timezone.utc).date()
26-
if commit_day < start_date:
27-
break
28-
if stop_date > commit_day:
29-
continue
28+
commit_day = commit.committed_datetime.astimezone(timezone.utc).date()
29+
30+
if stop_date and commit_day > stop_date:
31+
continue
32+
33+
if start_date and commit_day < start_date:
34+
break
35+
3036
for analyzer in analyzers:
3137
analyzer.process(commit)
3238

git_analytics/static/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ <h1 class="h3 mb-4">Statistics by time</h1>
119119
<div class="col-md-12">
120120
<div class="card h-100 w-100">
121121
<div class="card-header">
122-
Commit by day of week
122+
Commit by day of month
123123
</div>
124124
<div class="card-body">
125125
<canvas id="chartMonth"></canvas>
@@ -191,7 +191,7 @@ <h1 class="h3 mb-4">Other statistics</h1>
191191
<script src="js/git-analytics.js"></script>
192192

193193
<!-- Loading Modal -->
194-
<div class="modal fade" id="loadingModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
194+
<div class="modal" id="loadingModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
195195
<div class="modal-dialog modal-dialog-centered">
196196
<div class="modal-content text-center">
197197
<div class="modal-body">

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pytest = "^7.4"
2020
pytest-cov = "^4.1"
2121
mypy = "^1.4"
2222
ruff = "^0.12"
23+
freezegun= "^1.5"
2324

2425
[tool.poetry.scripts]
2526
git-analytics = 'git_analytics.main:run'

tests/fake_analyzer.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from dataclasses import dataclass, field
2+
from typing import List
3+
4+
from git_analytics.entities import AnalyticsCommit, AnalyticsResult
5+
from git_analytics.interfaces import CommitAnalyzer
6+
7+
8+
@dataclass
9+
class Result(AnalyticsResult):
10+
list_sha: List[str] = field(default_factory=list)
11+
12+
13+
class FakeAnalyzer(CommitAnalyzer):
14+
name = "fake_analyzer"
15+
16+
def __init__(self) -> None:
17+
self._result = Result()
18+
19+
def process(self, commit: AnalyticsCommit) -> None:
20+
self._result.list_sha.append(commit.sha)
21+
22+
def result(self) -> Result:
23+
return self._result

0 commit comments

Comments
 (0)