Path:
strictdoc/features/project_statistics/models/project_tree_stats.py
Lines:
62
Non-empty lines:
48
Non-empty lines covered with requirements:
48 / 48 (100.0%)
Functions:
3
Functions covered by requirements:
3 / 3 (100.0%)
1
"""2
Model class that holds the default project metrics data.3
4
NOTE: If a user wants to customize the default project statistics screen by5
implementing their own statistics generator, they will likely need to6
create a custom version of this model class with their own set of metric7
fields. This class serves as an example of how project metrics and8
statistics can be structured and stored.9
10
@relation(SDOC-SRS-97, scope=file)11
"""12
13
from collections import defaultdict
14
from dataclasses import dataclass, field
15
from typing import Dict, List, Optional
16
17
from strictdoc.backend.sdoc.models.node import SDocNode
18
19
20
@dataclass21
class DocumentStats:
22
requirements_total: int = 0
23
requirements_no_uid: List[SDocNode] = field(default_factory=list)
24
25
26
@dataclass27
class DocumentTreeStats:
28
total_documents: int = 0
29
total_requirements: int = 0
30
total_sections: int = 0
31
total_source_files: int = 0
32
total_source_files_complete_coverage: int = 0
33
total_source_files_partial_coverage: int = 0
34
total_source_files_no_coverage: int = 0
35
36
total_tbd: int = 0
37
total_tbc: int = 0
38
39
git_commit_hash: Optional[str] = None
40
41
# Section.42
sections_without_text_nodes: int = 0
43
44
# UID.45
requirements_no_uid: int = 0
46
requirements_no_links: int = 0
47
requirements_root_no_links: int = 0
48
requirements_no_rationale: int = 0
49
50
# STATUS.51
requirements_status_breakdown: Dict[Optional[str], int] = field(
52
default_factory=lambda: defaultdict(int)
53
)54
55
def sort_requirements_status_breakdown(self) -> None:
56
self.requirements_status_breakdown = dict(
57
sorted(
58
self.requirements_status_breakdown.items(),
59
key=lambda item: (item[0] is not None, item[1]),
60
reverse=True,
61
)62
)