Add core modules (session, recorder, database)
This commit is contained in:
44
.termflow/core/team_comparison.py
Normal file
44
.termflow/core/team_comparison.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
"""Team workflow comparison utilities."""
|
||||||
|
|
||||||
|
from collections import Counter
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class TeamPattern:
|
||||||
|
"""Represents a common pattern across team sessions."""
|
||||||
|
commands: str
|
||||||
|
frequency: int
|
||||||
|
users: List[str]
|
||||||
|
|
||||||
|
|
||||||
|
class TeamComparisonAnalyzer:
|
||||||
|
"""Analyzes patterns across team members."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.patterns: List[TeamPattern] = []
|
||||||
|
|
||||||
|
def analyze_sessions(self, sessions: List[dict]) -> List[TeamPattern]:
|
||||||
|
"""Analyze patterns across multiple sessions."""
|
||||||
|
all_commands = []
|
||||||
|
for session in sessions:
|
||||||
|
commands = session.get("commands", [])
|
||||||
|
for cmd in commands:
|
||||||
|
all_commands.append(cmd.get("command", ""))
|
||||||
|
|
||||||
|
command_counts = Counter(all_commands)
|
||||||
|
self.patterns = [
|
||||||
|
TeamPattern(
|
||||||
|
commands=cmd,
|
||||||
|
frequency=count,
|
||||||
|
users=[s.get("name", "") for s in sessions],
|
||||||
|
)
|
||||||
|
for cmd, count in command_counts.most_common(10)
|
||||||
|
]
|
||||||
|
|
||||||
|
return self.patterns
|
||||||
|
|
||||||
|
def get_recommended_patterns(self) -> List[TeamPattern]:
|
||||||
|
"""Get recommended patterns based on frequency."""
|
||||||
|
return [p for p in self.patterns if p.frequency > 1]
|
||||||
Reference in New Issue
Block a user