UNCLASSIFIED - NO CUI

Skip to content

Refactor process_data function

Need to find a way to refactor process_data function so that it's length is not dragged on because right now it seems to be very large. Thinking the following way as a psuedocode

@dataclass
class TeamData:
   team: Team
   ...

processors: Callable[[TeamData, TeamMetrics]] = [
   insert_cumulative_flow_metrics,
   insert_effort_data,
]

def process_organization(organization: Organization):
    """Process organization metrics."""
    result: List[TeamMetrics] = []
    for value_stream in organization.valuestreams:
       for team in value_stream.teams:
           team_data = new TeamData()
           # some code to initialize team_data
           team_metrics = new TeamMetrics()
           for apply_metrics in processors:
               apply_metrics(team_data, team_metrics)
           result.append(team_metrics)
    return result
Edited by abhayashrestha