Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kishnahai0806/SteelWorks/llms.txt
Use this file to discover all available pages before exploring further.
OperationsMetricsService is the central application service that SteelWorks’ Streamlit UI calls. It accepts an optional OperationsDataSource repository; when none is provided, it uses built-in fallback data so the dashboard can run and be tested without a live database connection.
Constructor
An object satisfying the
OperationsDataSource protocol. When None, the service uses built-in in-memory fallback data containing 2 weeks (2026-W03, 2026-W04), 3 production lines (Line 1, Line 2, Line 4), and 6 issue occurrences. When a repository is provided, all queries delegate to it.Methods
get_available_weeks
calendar_week_id. When a repository is configured, the result comes directly from repository.get_available_weeks(); otherwise it is derived from the built-in fallback data.
Returns list[dict[str, Any]] — each dict contains:
Numeric primary-key identifier for the calendar week.
Human-readable ISO week string, e.g.
"2026-W03".get_available_lines
is_active=True), sorted alphabetically by line_name. When using fallback data, Line 2 (is_active=False) is excluded so only Line 1 and Line 4 are returned.
Returns list[dict[str, Any]] — each dict contains:
Numeric primary-key identifier for the production line.
Display name of the production line, e.g.
"Line 1".Always
True in the returned list — inactive lines are filtered out before returning.get_issue_summary
selection. Line IDs are normalized via normalize_line_ids() before any query is executed. Returns an empty list immediately when selection.production_line_ids is empty.
A frozen dataclass carrying the selected
calendar_week_id and production_line_ids. See IssueFilterSelection.When
False, results are grouped by (week_label, issue_type_name). When True, results are also broken down by line_name.list[dict[str, Any]]:
Example
get_affected_lots
issue_count descending, then by lot_code ascending. Returns an empty list immediately when selection.production_line_ids is empty.
A frozen dataclass carrying the selected
calendar_week_id and production_line_ids. See IssueFilterSelection.list[dict[str, Any]] — each dict contains:
ISO week label for the selected week.
Name of the production line the lot ran on.
Identifier for the affected lot, e.g.
"LOT-1001".Total number of issue occurrences recorded against this lot.
Comma-separated, alphabetically sorted list of distinct issue type names recorded against this lot, e.g.
"changeover_delay, tool_wear".export_issue_summary_csv
get_issue_summary() internally and serializes the result to UTF-8 encoded CSV bytes. The output always includes a header row. The line_name column is only present when group_by_line=True.
Filter scope for the export. See
IssueFilterSelection.Controls whether
line_name is included as a column in the CSV output.bytes — UTF-8 encoded CSV content.
Columns (in order):
| Column | Present when |
|---|---|
week_label | Always |
line_name | group_by_line=True only |
issue_type_name | Always |
issue_count | Always |
export_affected_lots_csv
get_affected_lots() internally and serializes the result to UTF-8 encoded CSV bytes. The output always includes a header row.
Filter scope for the export. See
IssueFilterSelection.bytes — UTF-8 encoded CSV content.
Columns (in order): week_label, line_name, lot_code, issue_count, issue_types.
normalize_line_ids
line_ids. This method is called internally by get_issue_summary() and get_affected_lots() before any query is executed, ensuring deterministic behavior regardless of the order or duplication in the caller’s input. The CSV export methods (export_issue_summary_csv, export_affected_lots_csv) benefit from this normalization indirectly because they delegate to those two methods.
A list of production line IDs, possibly containing duplicates and in any order.
list[int] — sorted list with duplicates removed.
Example