git-contribution-analyzer 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- git_contribution_analyzer/__init__.py +3 -0
- git_contribution_analyzer/adapters/__init__.py +1 -0
- git_contribution_analyzer/adapters/git/__init__.py +1 -0
- git_contribution_analyzer/adapters/git/local_identity.py +51 -0
- git_contribution_analyzer/adapters/git/native_git.py +353 -0
- git_contribution_analyzer/adapters/git/pydriller_history.py +57 -0
- git_contribution_analyzer/adapters/git/repository_discovery.py +75 -0
- git_contribution_analyzer/adapters/gui/__init__.py +1 -0
- git_contribution_analyzer/adapters/gui/app.py +63 -0
- git_contribution_analyzer/adapters/gui/controller.py +1084 -0
- git_contribution_analyzer/adapters/gui/models/__init__.py +3 -0
- git_contribution_analyzer/adapters/gui/models/base_table.py +108 -0
- git_contribution_analyzer/adapters/gui/settings.py +53 -0
- git_contribution_analyzer/adapters/gui/task_runner.py +196 -0
- git_contribution_analyzer/adapters/llm/__init__.py +1 -0
- git_contribution_analyzer/adapters/llm/anthropic.py +52 -0
- git_contribution_analyzer/adapters/llm/base.py +142 -0
- git_contribution_analyzer/adapters/llm/cache.py +148 -0
- git_contribution_analyzer/adapters/llm/claude_cli.py +52 -0
- git_contribution_analyzer/adapters/llm/codex_cli.py +52 -0
- git_contribution_analyzer/adapters/llm/command_base.py +153 -0
- git_contribution_analyzer/adapters/llm/mock.py +82 -0
- git_contribution_analyzer/adapters/llm/ollama.py +53 -0
- git_contribution_analyzer/adapters/llm/openai_compatible.py +61 -0
- git_contribution_analyzer/adapters/llm/registry.py +117 -0
- git_contribution_analyzer/adapters/mcp/__init__.py +13 -0
- git_contribution_analyzer/adapters/mcp/installer.py +175 -0
- git_contribution_analyzer/adapters/mcp/prompts_resources.py +218 -0
- git_contribution_analyzer/adapters/mcp/protocol.py +361 -0
- git_contribution_analyzer/adapters/mcp/server.py +52 -0
- git_contribution_analyzer/adapters/mcp/tools.py +621 -0
- git_contribution_analyzer/adapters/outcomes/__init__.py +1 -0
- git_contribution_analyzer/adapters/outcomes/yaml_loader.py +55 -0
- git_contribution_analyzer/adapters/outcomes/yaml_store.py +104 -0
- git_contribution_analyzer/adapters/reporting/__init__.py +1 -0
- git_contribution_analyzer/adapters/reporting/brag_markdown.py +115 -0
- git_contribution_analyzer/adapters/reporting/html_report.py +1413 -0
- git_contribution_analyzer/adapters/reporting/markdown.py +217 -0
- git_contribution_analyzer/adapters/reporting/portfolio_markdown.py +167 -0
- git_contribution_analyzer/adapters/reporting/recap_markdown.py +212 -0
- git_contribution_analyzer/adapters/reporting/resume_markdown.py +37 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_csv.py +117 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_markdown.py +90 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_series_markdown.py +31 -0
- git_contribution_analyzer/adapters/storage/__init__.py +1 -0
- git_contribution_analyzer/adapters/storage/sqlite/__init__.py +1 -0
- git_contribution_analyzer/adapters/storage/sqlite/analysis.py +708 -0
- git_contribution_analyzer/adapters/storage/sqlite/database.py +98 -0
- git_contribution_analyzer/adapters/storage/sqlite/git_index.py +482 -0
- git_contribution_analyzer/adapters/storage/sqlite/identity_merge.py +373 -0
- git_contribution_analyzer/adapters/storage/sqlite/llm_audit.py +109 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/env.py +34 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/script.py.mako +22 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0001_initial.py +51 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0002_git_index.py +146 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0003_analysis.py +79 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0004_llm_audit.py +69 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0005_run_types.py +42 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0006_identity_merges.py +83 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0007_structural_baselines.py +173 -0
- git_contribution_analyzer/adapters/storage/sqlite/models.py +354 -0
- git_contribution_analyzer/adapters/storage/sqlite/structural_baseline.py +841 -0
- git_contribution_analyzer/adapters/workspace/__init__.py +1 -0
- git_contribution_analyzer/adapters/workspace/config.py +135 -0
- git_contribution_analyzer/adapters/workspace/git_exclude.py +32 -0
- git_contribution_analyzer/adapters/workspace/layout.py +40 -0
- git_contribution_analyzer/adapters/workspace/locks.py +27 -0
- git_contribution_analyzer/adapters/workspace/portfolio_workspace.py +380 -0
- git_contribution_analyzer/adapters/workspace/ranking_config.py +17 -0
- git_contribution_analyzer/application/__init__.py +1 -0
- git_contribution_analyzer/application/dto/__init__.py +19 -0
- git_contribution_analyzer/application/dto/gui.py +86 -0
- git_contribution_analyzer/application/dto/results.py +21 -0
- git_contribution_analyzer/application/facades/__init__.py +3 -0
- git_contribution_analyzer/application/facades/gui.py +568 -0
- git_contribution_analyzer/application/ports/__init__.py +22 -0
- git_contribution_analyzer/application/ports/cancellation.py +50 -0
- git_contribution_analyzer/application/ports/git_history.py +22 -0
- git_contribution_analyzer/application/ports/llm.py +44 -0
- git_contribution_analyzer/application/ports/portfolio_store.py +34 -0
- git_contribution_analyzer/application/ports/progress.py +43 -0
- git_contribution_analyzer/application/ports/structural_baseline.py +93 -0
- git_contribution_analyzer/application/services/__init__.py +1 -0
- git_contribution_analyzer/application/services/assessment_explanation.py +127 -0
- git_contribution_analyzer/application/services/default_person.py +61 -0
- git_contribution_analyzer/application/services/evidence_snapshot.py +64 -0
- git_contribution_analyzer/application/services/person_selection.py +88 -0
- git_contribution_analyzer/application/services/resume_generation.py +318 -0
- git_contribution_analyzer/application/services/semantic_enhancement.py +157 -0
- git_contribution_analyzer/application/services/time_boundaries.py +49 -0
- git_contribution_analyzer/application/use_cases/__init__.py +1 -0
- git_contribution_analyzer/application/use_cases/analyze_contributions.py +276 -0
- git_contribution_analyzer/application/use_cases/analyze_project.py +295 -0
- git_contribution_analyzer/application/use_cases/assess_portfolio.py +327 -0
- git_contribution_analyzer/application/use_cases/assess_work.py +602 -0
- git_contribution_analyzer/application/use_cases/assess_work_series.py +212 -0
- git_contribution_analyzer/application/use_cases/compare_assessment_runs.py +121 -0
- git_contribution_analyzer/application/use_cases/export_report.py +49 -0
- git_contribution_analyzer/application/use_cases/generate_brag.py +308 -0
- git_contribution_analyzer/application/use_cases/generate_portfolio_recap.py +244 -0
- git_contribution_analyzer/application/use_cases/generate_portfolio_resume.py +152 -0
- git_contribution_analyzer/application/use_cases/generate_recap.py +316 -0
- git_contribution_analyzer/application/use_cases/generate_report.py +32 -0
- git_contribution_analyzer/application/use_cases/generate_resume.py +209 -0
- git_contribution_analyzer/application/use_cases/get_portfolio_status.py +83 -0
- git_contribution_analyzer/application/use_cases/get_run.py +16 -0
- git_contribution_analyzer/application/use_cases/get_status.py +69 -0
- git_contribution_analyzer/application/use_cases/index_repository.py +267 -0
- git_contribution_analyzer/application/use_cases/init_portfolio.py +89 -0
- git_contribution_analyzer/application/use_cases/init_project.py +71 -0
- git_contribution_analyzer/application/use_cases/list_identities.py +16 -0
- git_contribution_analyzer/application/use_cases/list_providers.py +29 -0
- git_contribution_analyzer/application/use_cases/list_runs.py +17 -0
- git_contribution_analyzer/application/use_cases/manage_identity_merges.py +48 -0
- git_contribution_analyzer/application/use_cases/manage_outcomes.py +189 -0
- git_contribution_analyzer/application/use_cases/manage_structural_baselines.py +262 -0
- git_contribution_analyzer/application/use_cases/map_identity.py +28 -0
- git_contribution_analyzer/application/use_cases/recover_runs.py +22 -0
- git_contribution_analyzer/application/use_cases/run_doctor.py +81 -0
- git_contribution_analyzer/application/use_cases/sync_portfolio.py +232 -0
- git_contribution_analyzer/application/use_cases/test_provider.py +22 -0
- git_contribution_analyzer/application/use_cases/uninit_project.py +23 -0
- git_contribution_analyzer/application/use_cases/verify_portfolio.py +165 -0
- git_contribution_analyzer/cli/__init__.py +1 -0
- git_contribution_analyzer/cli/app.py +1430 -0
- git_contribution_analyzer/cli/exit_codes.py +13 -0
- git_contribution_analyzer/cli/output.py +26 -0
- git_contribution_analyzer/cli/portfolio_commands.py +629 -0
- git_contribution_analyzer/domain/__init__.py +1 -0
- git_contribution_analyzer/domain/errors.py +55 -0
- git_contribution_analyzer/domain/models/__init__.py +3 -0
- git_contribution_analyzer/domain/models/analysis.py +29 -0
- git_contribution_analyzer/domain/models/assessment.py +12 -0
- git_contribution_analyzer/domain/models/brag.py +148 -0
- git_contribution_analyzer/domain/models/contribution.py +55 -0
- git_contribution_analyzer/domain/models/git_history.py +69 -0
- git_contribution_analyzer/domain/models/person_selection.py +46 -0
- git_contribution_analyzer/domain/models/portfolio.py +498 -0
- git_contribution_analyzer/domain/models/ranking.py +48 -0
- git_contribution_analyzer/domain/models/recap.py +235 -0
- git_contribution_analyzer/domain/models/repository.py +10 -0
- git_contribution_analyzer/domain/models/resume.py +59 -0
- git_contribution_analyzer/domain/models/run.py +10 -0
- git_contribution_analyzer/domain/models/semantic.py +34 -0
- git_contribution_analyzer/domain/models/snapshot.py +208 -0
- git_contribution_analyzer/domain/models/structural_baseline.py +120 -0
- git_contribution_analyzer/domain/models/work_assessment.py +81 -0
- git_contribution_analyzer/domain/services/assessment_periods.py +182 -0
- git_contribution_analyzer/domain/services/brag_rules.py +250 -0
- git_contribution_analyzer/domain/services/capability_rules.py +91 -0
- git_contribution_analyzer/domain/services/contribution_clustering.py +98 -0
- git_contribution_analyzer/domain/services/contribution_rules.py +79 -0
- git_contribution_analyzer/domain/services/difficulty_rules.py +191 -0
- git_contribution_analyzer/domain/services/dimensional_summary.py +117 -0
- git_contribution_analyzer/domain/services/portfolio_aggregation.py +250 -0
- git_contribution_analyzer/domain/services/portfolio_resume_rules.py +265 -0
- git_contribution_analyzer/domain/services/portfolio_verifier.py +238 -0
- git_contribution_analyzer/domain/services/ranking_rules.py +226 -0
- git_contribution_analyzer/domain/services/recap_rules.py +268 -0
- git_contribution_analyzer/domain/services/resume_claim_rules.py +70 -0
- git_contribution_analyzer/domain/services/structural_baseline.py +317 -0
- git_contribution_analyzer/domain/services/structural_signals.py +151 -0
- git_contribution_analyzer/domain/services/workload_rules.py +185 -0
- git_contribution_analyzer/gui/__init__.py +1 -0
- git_contribution_analyzer/gui/qml/Main.qml +1141 -0
- git_contribution_analyzer/gui/qml/__init__.py +1 -0
- git_contribution_analyzer/prompts/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/v1/explanation.txt +4 -0
- git_contribution_analyzer/prompts/resume/__init__.py +1 -0
- git_contribution_analyzer/prompts/resume/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-concise.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-star.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-xyz.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/system.txt +3 -0
- git_contribution_analyzer/prompts/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/v1/capability_explanation.txt +2 -0
- git_contribution_analyzer/prompts/v1/contribution_summary.txt +2 -0
- git_contribution_analyzer/prompts/v1/overall_summary.txt +2 -0
- git_contribution_analyzer/prompts/v1/resume_bullet.txt +2 -0
- git_contribution_analyzer-0.8.0.dist-info/METADATA +667 -0
- git_contribution_analyzer-0.8.0.dist-info/RECORD +187 -0
- git_contribution_analyzer-0.8.0.dist-info/WHEEL +4 -0
- git_contribution_analyzer-0.8.0.dist-info/entry_points.txt +3 -0
- git_contribution_analyzer-0.8.0.dist-info/licenses/LICENSE +201 -0
- git_contribution_analyzer-0.8.0.dist-info/licenses/NOTICE +6 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
8
|
+
class AssessmentRequest:
|
|
9
|
+
repository: Path
|
|
10
|
+
person_selectors: tuple[str, ...] = ()
|
|
11
|
+
all_people: bool = False
|
|
12
|
+
exclude_selectors: tuple[str, ...] = ()
|
|
13
|
+
rank_by: tuple[str, ...] = ()
|
|
14
|
+
ranking_config: Path | None = None
|
|
15
|
+
since_text: str | None = None
|
|
16
|
+
until_text: str | None = None
|
|
17
|
+
period: str | None = None
|
|
18
|
+
branch: str | None = None
|
|
19
|
+
release: str | None = None
|
|
20
|
+
scope: str | None = None
|
|
21
|
+
delivery: str | None = None
|
|
22
|
+
time_basis: str = "authored"
|
|
23
|
+
use_llm: bool = True
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
27
|
+
class ExportRequest:
|
|
28
|
+
repository: Path
|
|
29
|
+
run_id: str
|
|
30
|
+
report_format: str
|
|
31
|
+
target: Path
|
|
32
|
+
include_email: bool = False
|
|
33
|
+
overwrite: bool = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
37
|
+
class IdentityMapRequest:
|
|
38
|
+
repository: Path
|
|
39
|
+
name: str
|
|
40
|
+
email: str
|
|
41
|
+
person_name: str
|
|
42
|
+
person_email: str
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
46
|
+
class IdentityMergeRequest:
|
|
47
|
+
repository: Path
|
|
48
|
+
sources: tuple[str, ...]
|
|
49
|
+
target: str
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
53
|
+
class ResumeRequest:
|
|
54
|
+
repository: Path
|
|
55
|
+
person_selector: str
|
|
56
|
+
since_text: str | None = None
|
|
57
|
+
until_text: str | None = None
|
|
58
|
+
branch: str | None = None
|
|
59
|
+
release: str | None = None
|
|
60
|
+
scope: str | None = None
|
|
61
|
+
delivery: str | None = None
|
|
62
|
+
time_basis: str = "LANDED"
|
|
63
|
+
target_role: str = ""
|
|
64
|
+
language: str = "zh-CN"
|
|
65
|
+
style: str = "concise"
|
|
66
|
+
max_bullets: int = 6
|
|
67
|
+
include_pending: bool = False
|
|
68
|
+
use_llm: bool = True
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
72
|
+
class StructuralBaselineRequest:
|
|
73
|
+
repository: Path
|
|
74
|
+
cutoff_text: str | None = None
|
|
75
|
+
branch: str | None = None
|
|
76
|
+
scope: str | None = None
|
|
77
|
+
time_strategy: str = "lifetime"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
81
|
+
class GuiError:
|
|
82
|
+
code: str
|
|
83
|
+
title: str
|
|
84
|
+
message: str
|
|
85
|
+
detail: str = ""
|
|
86
|
+
retryable: bool = False
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CommandError(BaseModel):
|
|
9
|
+
code: str
|
|
10
|
+
message: str
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CommandEnvelope(BaseModel):
|
|
14
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
15
|
+
|
|
16
|
+
schema_version: str = Field(default="1.0", alias="schemaVersion")
|
|
17
|
+
command: str
|
|
18
|
+
success: bool = True
|
|
19
|
+
data: dict[str, Any] = Field(default_factory=dict)
|
|
20
|
+
warnings: list[str] = Field(default_factory=list)
|
|
21
|
+
error: CommandError | None = None
|
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import date
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from git_contribution_analyzer.adapters.git.repository_discovery import discover_repository
|
|
8
|
+
from git_contribution_analyzer.adapters.llm.registry import build_provider
|
|
9
|
+
from git_contribution_analyzer.adapters.reporting.brag_markdown import render_brag_markdown
|
|
10
|
+
from git_contribution_analyzer.adapters.reporting.html_report import render_html_report
|
|
11
|
+
from git_contribution_analyzer.adapters.reporting.recap_markdown import render_recap_markdown
|
|
12
|
+
from git_contribution_analyzer.adapters.workspace.config import load_config
|
|
13
|
+
from git_contribution_analyzer.adapters.workspace.layout import WorkspaceLayout
|
|
14
|
+
from git_contribution_analyzer.adapters.workspace.ranking_config import load_ranking_config
|
|
15
|
+
from git_contribution_analyzer.application.dto.gui import (
|
|
16
|
+
AssessmentRequest,
|
|
17
|
+
ExportRequest,
|
|
18
|
+
GuiError,
|
|
19
|
+
IdentityMapRequest,
|
|
20
|
+
IdentityMergeRequest,
|
|
21
|
+
ResumeRequest,
|
|
22
|
+
StructuralBaselineRequest,
|
|
23
|
+
)
|
|
24
|
+
from git_contribution_analyzer.application.ports.cancellation import (
|
|
25
|
+
CancellationToken,
|
|
26
|
+
NeverCancelledToken,
|
|
27
|
+
)
|
|
28
|
+
from git_contribution_analyzer.application.ports.progress import (
|
|
29
|
+
NullProgressReporter,
|
|
30
|
+
ProgressReporter,
|
|
31
|
+
)
|
|
32
|
+
from git_contribution_analyzer.application.services.time_boundaries import (
|
|
33
|
+
parse_boundaries,
|
|
34
|
+
uses_system_timezone,
|
|
35
|
+
)
|
|
36
|
+
from git_contribution_analyzer.application.use_cases.assess_portfolio import assess_portfolio
|
|
37
|
+
from git_contribution_analyzer.application.use_cases.assess_work import assess_work
|
|
38
|
+
from git_contribution_analyzer.application.use_cases.assess_work_series import assess_work_series
|
|
39
|
+
from git_contribution_analyzer.application.use_cases.compare_assessment_runs import (
|
|
40
|
+
compare_assessment_runs,
|
|
41
|
+
)
|
|
42
|
+
from git_contribution_analyzer.application.use_cases.export_report import export_report
|
|
43
|
+
from git_contribution_analyzer.application.use_cases.generate_brag import generate_brag
|
|
44
|
+
from git_contribution_analyzer.application.use_cases.generate_portfolio_resume import (
|
|
45
|
+
generate_portfolio_resume,
|
|
46
|
+
)
|
|
47
|
+
from git_contribution_analyzer.application.use_cases.generate_recap import generate_recap
|
|
48
|
+
from git_contribution_analyzer.application.use_cases.generate_resume import generate_resume
|
|
49
|
+
from git_contribution_analyzer.application.use_cases.get_portfolio_status import (
|
|
50
|
+
get_portfolio_status,
|
|
51
|
+
)
|
|
52
|
+
from git_contribution_analyzer.application.use_cases.get_run import get_run
|
|
53
|
+
from git_contribution_analyzer.application.use_cases.get_status import get_status
|
|
54
|
+
from git_contribution_analyzer.application.use_cases.index_repository import index_repository
|
|
55
|
+
from git_contribution_analyzer.application.use_cases.init_project import init_project
|
|
56
|
+
from git_contribution_analyzer.application.use_cases.list_identities import list_identities
|
|
57
|
+
from git_contribution_analyzer.application.use_cases.list_providers import list_providers
|
|
58
|
+
from git_contribution_analyzer.application.use_cases.list_runs import list_runs
|
|
59
|
+
from git_contribution_analyzer.application.use_cases.manage_identity_merges import (
|
|
60
|
+
list_identity_merges,
|
|
61
|
+
merge_identities,
|
|
62
|
+
preview_identity_merge,
|
|
63
|
+
unmerge_identities,
|
|
64
|
+
)
|
|
65
|
+
from git_contribution_analyzer.application.use_cases.manage_outcomes import (
|
|
66
|
+
add_outcome,
|
|
67
|
+
list_outcomes,
|
|
68
|
+
remove_outcome,
|
|
69
|
+
)
|
|
70
|
+
from git_contribution_analyzer.application.use_cases.manage_structural_baselines import (
|
|
71
|
+
default_structural_cutoff,
|
|
72
|
+
get_structural_status,
|
|
73
|
+
prune_structural_baselines,
|
|
74
|
+
rebuild_structural_baseline,
|
|
75
|
+
show_structural_baseline,
|
|
76
|
+
)
|
|
77
|
+
from git_contribution_analyzer.application.use_cases.map_identity import map_identity
|
|
78
|
+
from git_contribution_analyzer.application.use_cases.recover_runs import (
|
|
79
|
+
recover_interrupted_runs,
|
|
80
|
+
)
|
|
81
|
+
from git_contribution_analyzer.application.use_cases.run_doctor import run_doctor
|
|
82
|
+
from git_contribution_analyzer.application.use_cases.sync_portfolio import sync_portfolio
|
|
83
|
+
from git_contribution_analyzer.application.use_cases.test_provider import test_provider
|
|
84
|
+
from git_contribution_analyzer.application.use_cases.verify_portfolio import verify_portfolio
|
|
85
|
+
from git_contribution_analyzer.domain.errors import (
|
|
86
|
+
ConfigurationError,
|
|
87
|
+
GcaError,
|
|
88
|
+
IdentityResolutionError,
|
|
89
|
+
LlmProviderError,
|
|
90
|
+
NotARepositoryError,
|
|
91
|
+
ReportError,
|
|
92
|
+
WorkspaceError,
|
|
93
|
+
)
|
|
94
|
+
from git_contribution_analyzer.domain.models.analysis import AnalysisFilters
|
|
95
|
+
from git_contribution_analyzer.domain.models.structural_baseline import StructuralTimeStrategy
|
|
96
|
+
from git_contribution_analyzer.domain.services.ranking_rules import SUPPORTED_DIMENSIONS
|
|
97
|
+
|
|
98
|
+
_TIME_BASES = {"AUTHORED", "COMMITTED", "MERGED", "LANDED", "RELEASED"}
|
|
99
|
+
_PERIODS = {"week", "month", "quarter"}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class GuiApplicationFacade:
|
|
103
|
+
def open_repository(self, path: Any) -> dict[str, Any]:
|
|
104
|
+
repository = discover_repository(path)
|
|
105
|
+
status = get_status(repository.root)
|
|
106
|
+
if status["workspaceInitialized"] and status["databaseHealthy"]:
|
|
107
|
+
status["recoveredRuns"] = recover_interrupted_runs(repository.root)
|
|
108
|
+
else:
|
|
109
|
+
status["recoveredRuns"] = 0
|
|
110
|
+
return status
|
|
111
|
+
|
|
112
|
+
def initialize(
|
|
113
|
+
self,
|
|
114
|
+
path: Any,
|
|
115
|
+
*,
|
|
116
|
+
progress: ProgressReporter | None = None,
|
|
117
|
+
cancellation: CancellationToken | None = None,
|
|
118
|
+
) -> dict[str, Any]:
|
|
119
|
+
layout = init_project(
|
|
120
|
+
path,
|
|
121
|
+
progress=progress,
|
|
122
|
+
cancellation=cancellation,
|
|
123
|
+
)
|
|
124
|
+
return get_status(layout.repository_root)
|
|
125
|
+
|
|
126
|
+
def status(self, path: Any) -> dict[str, Any]:
|
|
127
|
+
return get_status(path)
|
|
128
|
+
|
|
129
|
+
def doctor(self, path: Any) -> dict[str, Any]:
|
|
130
|
+
return run_doctor(path)
|
|
131
|
+
|
|
132
|
+
def index(
|
|
133
|
+
self,
|
|
134
|
+
path: Any,
|
|
135
|
+
*,
|
|
136
|
+
full_rebuild: bool,
|
|
137
|
+
progress: ProgressReporter | None = None,
|
|
138
|
+
cancellation: CancellationToken | None = None,
|
|
139
|
+
) -> dict[str, Any]:
|
|
140
|
+
return index_repository(
|
|
141
|
+
path,
|
|
142
|
+
full_rebuild=full_rebuild,
|
|
143
|
+
progress=progress,
|
|
144
|
+
cancellation=cancellation,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
def structural_status(self, path: Any) -> dict[str, Any]:
|
|
148
|
+
return get_structural_status(path)
|
|
149
|
+
|
|
150
|
+
def rebuild_structural(
|
|
151
|
+
self,
|
|
152
|
+
request: StructuralBaselineRequest,
|
|
153
|
+
*,
|
|
154
|
+
progress: ProgressReporter | None = None,
|
|
155
|
+
cancellation: CancellationToken | None = None,
|
|
156
|
+
) -> dict[str, Any]:
|
|
157
|
+
cutoff = (
|
|
158
|
+
parse_boundaries(request.cutoff_text, None)[0]
|
|
159
|
+
if request.cutoff_text
|
|
160
|
+
else default_structural_cutoff()
|
|
161
|
+
)
|
|
162
|
+
if cutoff is None:
|
|
163
|
+
raise ValueError("Structural cutoff is required")
|
|
164
|
+
strategy = StructuralTimeStrategy(request.time_strategy.replace("-", "_").upper())
|
|
165
|
+
return rebuild_structural_baseline(
|
|
166
|
+
request.repository,
|
|
167
|
+
cutoff=cutoff,
|
|
168
|
+
branch=request.branch,
|
|
169
|
+
scope=request.scope,
|
|
170
|
+
time_strategy=strategy,
|
|
171
|
+
progress=progress,
|
|
172
|
+
cancellation=cancellation,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
def show_structural(self, path: Any, baseline_id: str) -> dict[str, Any]:
|
|
176
|
+
return show_structural_baseline(path, baseline_id)
|
|
177
|
+
|
|
178
|
+
def prune_structural(self, path: Any, *, keep: int) -> dict[str, int]:
|
|
179
|
+
return prune_structural_baselines(path, keep=keep)
|
|
180
|
+
|
|
181
|
+
def list_identities(self, path: Any, *, unresolved_only: bool = False) -> dict[str, Any]:
|
|
182
|
+
return list_identities(path, unresolved_only=unresolved_only)
|
|
183
|
+
|
|
184
|
+
def map_identity(self, request: IdentityMapRequest) -> dict[str, Any]:
|
|
185
|
+
return map_identity(
|
|
186
|
+
request.repository,
|
|
187
|
+
name=request.name,
|
|
188
|
+
email=request.email,
|
|
189
|
+
person_name=request.person_name,
|
|
190
|
+
person_email=request.person_email,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def preview_identity_merge(self, request: IdentityMergeRequest) -> dict[str, Any]:
|
|
194
|
+
return preview_identity_merge(request.repository, request.sources, request.target)
|
|
195
|
+
|
|
196
|
+
def merge_identities(self, request: IdentityMergeRequest) -> dict[str, Any]:
|
|
197
|
+
return merge_identities(request.repository, request.sources, request.target)
|
|
198
|
+
|
|
199
|
+
def list_identity_merges(self, path: Any, *, status: str = "ALL") -> dict[str, Any]:
|
|
200
|
+
return list_identity_merges(path, status)
|
|
201
|
+
|
|
202
|
+
def unmerge_identities(self, path: Any, merge_id: str) -> dict[str, Any]:
|
|
203
|
+
return unmerge_identities(path, merge_id)
|
|
204
|
+
|
|
205
|
+
def assess(
|
|
206
|
+
self,
|
|
207
|
+
request: AssessmentRequest,
|
|
208
|
+
*,
|
|
209
|
+
progress: ProgressReporter | None = None,
|
|
210
|
+
cancellation: CancellationToken | None = None,
|
|
211
|
+
) -> dict[str, Any]:
|
|
212
|
+
self._validate_assessment(request)
|
|
213
|
+
parsed_since, parsed_until = parse_boundaries(
|
|
214
|
+
request.since_text,
|
|
215
|
+
request.until_text,
|
|
216
|
+
)
|
|
217
|
+
time_basis = request.time_basis.upper()
|
|
218
|
+
filters = AnalysisFilters(
|
|
219
|
+
since=parsed_since,
|
|
220
|
+
until=parsed_until,
|
|
221
|
+
branch=request.branch,
|
|
222
|
+
release=request.release,
|
|
223
|
+
scope=request.scope,
|
|
224
|
+
delivery=request.delivery,
|
|
225
|
+
time_basis=time_basis,
|
|
226
|
+
system_timezone=uses_system_timezone(
|
|
227
|
+
request.since_text,
|
|
228
|
+
request.until_text,
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
ranking_config = (
|
|
232
|
+
load_ranking_config(request.ranking_config)
|
|
233
|
+
if request.ranking_config is not None
|
|
234
|
+
else None
|
|
235
|
+
)
|
|
236
|
+
provider = None
|
|
237
|
+
allow_fallback = True
|
|
238
|
+
if request.use_llm:
|
|
239
|
+
repository = discover_repository(request.repository)
|
|
240
|
+
config = load_config(WorkspaceLayout.for_repository(repository.root).config)
|
|
241
|
+
if config.llm.enabled:
|
|
242
|
+
provider = build_provider(config.llm)
|
|
243
|
+
allow_fallback = config.llm.allow_fallback_to_rules
|
|
244
|
+
|
|
245
|
+
active_progress = progress or NullProgressReporter()
|
|
246
|
+
active_cancellation = cancellation or NeverCancelledToken()
|
|
247
|
+
rank_by = tuple(value.casefold() for value in request.rank_by)
|
|
248
|
+
if request.period is not None:
|
|
249
|
+
return assess_work_series(
|
|
250
|
+
request.repository,
|
|
251
|
+
period=request.period.casefold(),
|
|
252
|
+
person_selectors=request.person_selectors,
|
|
253
|
+
all_people=request.all_people,
|
|
254
|
+
exclude_selectors=request.exclude_selectors,
|
|
255
|
+
rank_by=rank_by,
|
|
256
|
+
ranking_config=ranking_config,
|
|
257
|
+
filters=filters,
|
|
258
|
+
llm_provider=provider,
|
|
259
|
+
allow_llm_fallback=allow_fallback,
|
|
260
|
+
progress=active_progress,
|
|
261
|
+
cancellation=active_cancellation,
|
|
262
|
+
)
|
|
263
|
+
return assess_work(
|
|
264
|
+
request.repository,
|
|
265
|
+
person_selectors=request.person_selectors,
|
|
266
|
+
all_people=request.all_people,
|
|
267
|
+
exclude_selectors=request.exclude_selectors,
|
|
268
|
+
rank_by=rank_by,
|
|
269
|
+
ranking_config=ranking_config,
|
|
270
|
+
filters=filters,
|
|
271
|
+
llm_provider=provider,
|
|
272
|
+
allow_llm_fallback=allow_fallback,
|
|
273
|
+
progress=active_progress,
|
|
274
|
+
cancellation=active_cancellation,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
def list_runs(self, path: Any) -> dict[str, Any]:
|
|
278
|
+
return list_runs(path)
|
|
279
|
+
|
|
280
|
+
def get_run(self, path: Any, run_id: str) -> dict[str, Any]:
|
|
281
|
+
return get_run(path, run_id)
|
|
282
|
+
|
|
283
|
+
def compare_runs(self, path: Any, base_run_id: str, target_run_id: str) -> dict[str, Any]:
|
|
284
|
+
if base_run_id == target_run_id:
|
|
285
|
+
raise ValueError("Base and target runs must be different")
|
|
286
|
+
return compare_assessment_runs(path, base_run_id, target_run_id)
|
|
287
|
+
|
|
288
|
+
def export_report(self, request: ExportRequest) -> Any:
|
|
289
|
+
return export_report(
|
|
290
|
+
request.repository,
|
|
291
|
+
request.run_id,
|
|
292
|
+
request.report_format,
|
|
293
|
+
request.target,
|
|
294
|
+
include_email=request.include_email,
|
|
295
|
+
overwrite=request.overwrite,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
def generate_resume(self, request: ResumeRequest) -> dict[str, Any]:
|
|
299
|
+
since, until = parse_boundaries(request.since_text, request.until_text)
|
|
300
|
+
filters = AnalysisFilters(
|
|
301
|
+
since=since,
|
|
302
|
+
until=until,
|
|
303
|
+
branch=request.branch,
|
|
304
|
+
release=request.release,
|
|
305
|
+
scope=request.scope,
|
|
306
|
+
delivery=request.delivery,
|
|
307
|
+
time_basis=request.time_basis.upper(),
|
|
308
|
+
system_timezone=uses_system_timezone(request.since_text, request.until_text),
|
|
309
|
+
)
|
|
310
|
+
provider = None
|
|
311
|
+
allow_fallback = True
|
|
312
|
+
if request.use_llm:
|
|
313
|
+
repository = discover_repository(request.repository)
|
|
314
|
+
config = load_config(WorkspaceLayout.for_repository(repository.root).config)
|
|
315
|
+
if config.llm.enabled:
|
|
316
|
+
provider = build_provider(config.llm)
|
|
317
|
+
allow_fallback = config.llm.allow_fallback_to_rules
|
|
318
|
+
return generate_resume(
|
|
319
|
+
request.repository,
|
|
320
|
+
person_selector=request.person_selector,
|
|
321
|
+
filters=filters,
|
|
322
|
+
target_role=request.target_role,
|
|
323
|
+
language=request.language,
|
|
324
|
+
style=request.style,
|
|
325
|
+
max_bullets=request.max_bullets,
|
|
326
|
+
include_pending=request.include_pending,
|
|
327
|
+
llm_provider=provider,
|
|
328
|
+
allow_llm_fallback=allow_fallback,
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
def generate_recap(
|
|
332
|
+
self,
|
|
333
|
+
path: Any,
|
|
334
|
+
*,
|
|
335
|
+
person_selector: str | None = None,
|
|
336
|
+
window: str | None = "7d",
|
|
337
|
+
language: str = "zh-CN",
|
|
338
|
+
export_html: bool = False,
|
|
339
|
+
progress: ProgressReporter | None = None,
|
|
340
|
+
cancellation: CancellationToken | None = None,
|
|
341
|
+
) -> dict[str, Any]:
|
|
342
|
+
repo_path = Path(path)
|
|
343
|
+
data = generate_recap(
|
|
344
|
+
repo_path,
|
|
345
|
+
person_selector=person_selector or None,
|
|
346
|
+
window=window or "7d",
|
|
347
|
+
auto_sync=False,
|
|
348
|
+
progress=progress or NullProgressReporter(),
|
|
349
|
+
cancellation=cancellation or NeverCancelledToken(),
|
|
350
|
+
)
|
|
351
|
+
report = data["report"]
|
|
352
|
+
markdown = render_recap_markdown(report, language=language)
|
|
353
|
+
html_path: str | None = None
|
|
354
|
+
if export_html:
|
|
355
|
+
repository = discover_repository(repo_path)
|
|
356
|
+
layout = WorkspaceLayout.for_repository(repository.root)
|
|
357
|
+
layout.reports.mkdir(parents=True, exist_ok=True)
|
|
358
|
+
label = str(report["window"]["label"]).replace("/", "-")
|
|
359
|
+
target = layout.reports / f"recap-{label}.html"
|
|
360
|
+
target.write_text(
|
|
361
|
+
render_html_report(report, language=language),
|
|
362
|
+
encoding="utf-8",
|
|
363
|
+
newline="\n",
|
|
364
|
+
)
|
|
365
|
+
html_path = str(target)
|
|
366
|
+
return {"report": report, "markdown": markdown, "htmlPath": html_path}
|
|
367
|
+
|
|
368
|
+
def generate_brag(
|
|
369
|
+
self,
|
|
370
|
+
path: Any,
|
|
371
|
+
*,
|
|
372
|
+
person_selector: str | None = None,
|
|
373
|
+
year: int | None = None,
|
|
374
|
+
quarter: str | None = None,
|
|
375
|
+
language: str = "zh-CN",
|
|
376
|
+
export_html: bool = False,
|
|
377
|
+
progress: ProgressReporter | None = None,
|
|
378
|
+
cancellation: CancellationToken | None = None,
|
|
379
|
+
) -> dict[str, Any]:
|
|
380
|
+
repo_path = Path(path)
|
|
381
|
+
data = generate_brag(
|
|
382
|
+
repo_path,
|
|
383
|
+
person_selector=person_selector or None,
|
|
384
|
+
year=year,
|
|
385
|
+
quarter=quarter or None,
|
|
386
|
+
auto_sync=False,
|
|
387
|
+
progress=progress or NullProgressReporter(),
|
|
388
|
+
cancellation=cancellation or NeverCancelledToken(),
|
|
389
|
+
)
|
|
390
|
+
report = data["report"]
|
|
391
|
+
markdown = render_brag_markdown(report, language=language)
|
|
392
|
+
html_path: str | None = None
|
|
393
|
+
if export_html:
|
|
394
|
+
repository = discover_repository(repo_path)
|
|
395
|
+
layout = WorkspaceLayout.for_repository(repository.root)
|
|
396
|
+
layout.reports.mkdir(parents=True, exist_ok=True)
|
|
397
|
+
label = str(report["period"]["label"]).replace("/", "-")
|
|
398
|
+
target = layout.reports / f"brag-{label}.html"
|
|
399
|
+
target.write_text(
|
|
400
|
+
render_html_report(report, language=language),
|
|
401
|
+
encoding="utf-8",
|
|
402
|
+
newline="\n",
|
|
403
|
+
)
|
|
404
|
+
html_path = str(target)
|
|
405
|
+
return {"report": report, "markdown": markdown, "htmlPath": html_path}
|
|
406
|
+
|
|
407
|
+
def list_outcomes(self, path: Any) -> dict[str, Any]:
|
|
408
|
+
return list_outcomes(Path(path))
|
|
409
|
+
|
|
410
|
+
def add_outcome(
|
|
411
|
+
self,
|
|
412
|
+
path: Any,
|
|
413
|
+
*,
|
|
414
|
+
text: str,
|
|
415
|
+
source: str,
|
|
416
|
+
verified_by: str,
|
|
417
|
+
verified_at: str | None = None,
|
|
418
|
+
evidence_ids: tuple[str, ...] = (),
|
|
419
|
+
tags: tuple[str, ...] = (),
|
|
420
|
+
verify_evidence: bool = True,
|
|
421
|
+
) -> dict[str, Any]:
|
|
422
|
+
parsed_date = date.fromisoformat(verified_at) if verified_at else None
|
|
423
|
+
return add_outcome(
|
|
424
|
+
Path(path),
|
|
425
|
+
text=text,
|
|
426
|
+
source=source,
|
|
427
|
+
verified_by=verified_by,
|
|
428
|
+
verified_at=parsed_date,
|
|
429
|
+
evidence_ids=evidence_ids,
|
|
430
|
+
tags=tags,
|
|
431
|
+
verify_evidence=verify_evidence,
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
def remove_outcome(self, path: Any, outcome_id: str) -> dict[str, Any]:
|
|
435
|
+
return remove_outcome(Path(path), outcome_id=outcome_id)
|
|
436
|
+
|
|
437
|
+
def list_providers(self, path: Any) -> dict[str, Any]:
|
|
438
|
+
return list_providers(path)
|
|
439
|
+
|
|
440
|
+
def test_provider(self, path: Any) -> dict[str, Any]:
|
|
441
|
+
return test_provider(path)
|
|
442
|
+
|
|
443
|
+
def portfolio_status(self, portfolio_dir: Any) -> dict[str, Any]:
|
|
444
|
+
return get_portfolio_status(portfolio_dir)
|
|
445
|
+
|
|
446
|
+
def portfolio_sync(
|
|
447
|
+
self,
|
|
448
|
+
portfolio_dir: Any,
|
|
449
|
+
*,
|
|
450
|
+
full_rebuild: bool = False,
|
|
451
|
+
concurrency: int = 1,
|
|
452
|
+
progress: ProgressReporter | None = None,
|
|
453
|
+
cancellation: CancellationToken | None = None,
|
|
454
|
+
) -> dict[str, Any]:
|
|
455
|
+
return sync_portfolio(
|
|
456
|
+
portfolio_dir,
|
|
457
|
+
full_rebuild=full_rebuild,
|
|
458
|
+
concurrency=concurrency,
|
|
459
|
+
progress=progress or NullProgressReporter(),
|
|
460
|
+
cancellation=cancellation or NeverCancelledToken(),
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
def portfolio_assess(
|
|
464
|
+
self,
|
|
465
|
+
portfolio_dir: Any,
|
|
466
|
+
*,
|
|
467
|
+
person_selector: str,
|
|
468
|
+
refresh: bool = False,
|
|
469
|
+
progress: ProgressReporter | None = None,
|
|
470
|
+
cancellation: CancellationToken | None = None,
|
|
471
|
+
) -> dict[str, Any]:
|
|
472
|
+
return assess_portfolio(
|
|
473
|
+
portfolio_dir,
|
|
474
|
+
person_selector=person_selector,
|
|
475
|
+
refresh=refresh,
|
|
476
|
+
progress=progress or NullProgressReporter(),
|
|
477
|
+
cancellation=cancellation or NeverCancelledToken(),
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
def portfolio_resume(
|
|
481
|
+
self,
|
|
482
|
+
portfolio_dir: Any,
|
|
483
|
+
*,
|
|
484
|
+
person_selector: str,
|
|
485
|
+
target_role: str = "",
|
|
486
|
+
language: str = "zh-CN",
|
|
487
|
+
style: str = "star",
|
|
488
|
+
max_bullets_per_group: int = 6,
|
|
489
|
+
include_pending: bool = False,
|
|
490
|
+
progress: ProgressReporter | None = None,
|
|
491
|
+
cancellation: CancellationToken | None = None,
|
|
492
|
+
) -> dict[str, Any]:
|
|
493
|
+
return generate_portfolio_resume(
|
|
494
|
+
portfolio_dir,
|
|
495
|
+
person_selector=person_selector,
|
|
496
|
+
target_role=target_role,
|
|
497
|
+
language=language,
|
|
498
|
+
style=style,
|
|
499
|
+
max_bullets_per_group=max_bullets_per_group,
|
|
500
|
+
include_pending=include_pending,
|
|
501
|
+
progress=progress or NullProgressReporter(),
|
|
502
|
+
cancellation=cancellation or NeverCancelledToken(),
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
def portfolio_verify(
|
|
506
|
+
self,
|
|
507
|
+
portfolio_dir: Any,
|
|
508
|
+
*,
|
|
509
|
+
run_id: str = "latest",
|
|
510
|
+
resume_markdown_path: Any = None,
|
|
511
|
+
) -> dict[str, Any]:
|
|
512
|
+
return verify_portfolio(
|
|
513
|
+
portfolio_dir,
|
|
514
|
+
run_id=run_id,
|
|
515
|
+
resume_markdown_path=resume_markdown_path,
|
|
516
|
+
)
|
|
517
|
+
|
|
518
|
+
@staticmethod
|
|
519
|
+
def map_error(error: Exception) -> GuiError:
|
|
520
|
+
mappings: tuple[tuple[type[Exception], str, str, bool], ...] = (
|
|
521
|
+
(NotARepositoryError, "NOT_A_REPOSITORY", "Not a Git repository", False),
|
|
522
|
+
(WorkspaceError, "WORKSPACE", "Workspace unavailable", True),
|
|
523
|
+
(ConfigurationError, "CONFIGURATION", "Invalid configuration", False),
|
|
524
|
+
(IdentityResolutionError, "IDENTITY", "Identity needs attention", False),
|
|
525
|
+
(ReportError, "REPORT", "Report unavailable", False),
|
|
526
|
+
(LlmProviderError, "PROVIDER", "Provider unavailable", True),
|
|
527
|
+
(ValueError, "VALIDATION", "Check the entered values", False),
|
|
528
|
+
)
|
|
529
|
+
for error_type, code, title, retryable in mappings:
|
|
530
|
+
if isinstance(error, error_type):
|
|
531
|
+
return GuiError(
|
|
532
|
+
code=code,
|
|
533
|
+
title=title,
|
|
534
|
+
message=str(error),
|
|
535
|
+
retryable=retryable,
|
|
536
|
+
)
|
|
537
|
+
if isinstance(error, GcaError):
|
|
538
|
+
return GuiError(code="APPLICATION", title="Operation failed", message=str(error))
|
|
539
|
+
return GuiError(
|
|
540
|
+
code="UNEXPECTED",
|
|
541
|
+
title="Unexpected error",
|
|
542
|
+
message="The operation could not be completed.",
|
|
543
|
+
detail=str(error),
|
|
544
|
+
retryable=True,
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
@staticmethod
|
|
548
|
+
def _validate_assessment(request: AssessmentRequest) -> None:
|
|
549
|
+
if request.person_selectors and request.all_people:
|
|
550
|
+
raise ValueError("person selectors and all_people are mutually exclusive")
|
|
551
|
+
if not request.person_selectors and not request.all_people:
|
|
552
|
+
raise ValueError("Either person selectors or all_people is required")
|
|
553
|
+
if request.exclude_selectors and not request.all_people:
|
|
554
|
+
raise ValueError("exclude selectors require all_people")
|
|
555
|
+
normalized_dimensions = tuple(value.casefold() for value in request.rank_by)
|
|
556
|
+
if len(normalized_dimensions) != len(set(normalized_dimensions)):
|
|
557
|
+
raise ValueError("Ranking dimensions must not be repeated")
|
|
558
|
+
unsupported = set(normalized_dimensions) - set(SUPPORTED_DIMENSIONS)
|
|
559
|
+
if unsupported:
|
|
560
|
+
raise ValueError("Unsupported ranking dimension: " + ", ".join(sorted(unsupported)))
|
|
561
|
+
if request.time_basis.upper() not in _TIME_BASES:
|
|
562
|
+
raise ValueError("Unsupported assessment time basis")
|
|
563
|
+
if request.period is not None and request.period.casefold() not in _PERIODS:
|
|
564
|
+
raise ValueError("Unsupported assessment period")
|
|
565
|
+
if request.period is not None and (
|
|
566
|
+
request.since_text is None or request.until_text is None
|
|
567
|
+
):
|
|
568
|
+
raise ValueError("Periodic assessment requires since and until")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Application ports."""
|
|
2
|
+
from git_contribution_analyzer.application.ports.cancellation import (
|
|
3
|
+
CancellationSource,
|
|
4
|
+
CancellationToken,
|
|
5
|
+
NeverCancelledToken,
|
|
6
|
+
OperationCancelled,
|
|
7
|
+
)
|
|
8
|
+
from git_contribution_analyzer.application.ports.progress import (
|
|
9
|
+
NullProgressReporter,
|
|
10
|
+
ProgressEvent,
|
|
11
|
+
ProgressReporter,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"CancellationSource",
|
|
16
|
+
"CancellationToken",
|
|
17
|
+
"NeverCancelledToken",
|
|
18
|
+
"NullProgressReporter",
|
|
19
|
+
"OperationCancelled",
|
|
20
|
+
"ProgressEvent",
|
|
21
|
+
"ProgressReporter",
|
|
22
|
+
]
|