Skip to content

Commit

Permalink
Merge pull request #15 from enlyze/minor/expose-products
Browse files Browse the repository at this point in the history
Enable querying products
  • Loading branch information
denizs authored Sep 30, 2024
2 parents d054063 + 48988fe commit e9854c1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion TableSchemas.pqm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let
max_run_speed_start = nullable datetimezone,
max_run_speed_end = nullable datetimezone
],
ProductsTableSchema = type table [uuid = text, external_id = text, name = text],
DowntimesTableSchema = type table [
uuid = text,
machine = text,
Expand Down Expand Up @@ -69,5 +70,6 @@ in
MachinesTableSchema = MachinesTableSchema,
ProductionRunsTableSchema = ProductionRunsTableSchema,
DowntimesTableSchema = DowntimesTableSchema,
ProductivityMetricsTableSchema = ProductivityMetricsTableSchema
ProductivityMetricsTableSchema = ProductivityMetricsTableSchema,
ProductsTableSchema = ProductsTableSchema
]
14 changes: 12 additions & 2 deletions Transforms.pqm
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,22 @@ let
expandedQuantityScrap = ExpandQuantityScrap(expandedProductivity),
expandedQuantityYield = ExpandQuantityYield(expandedQuantityScrap)
in
Table.ChangeType(expandedQuantityYield, TableSchemas[ProductivityMetricsTableSchema])
Table.ChangeType(expandedQuantityYield, TableSchemas[ProductivityMetricsTableSchema]),
TransformProducts = (products as list) as table =>
let
productsTable = Table.FromList(products, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
namedTable = Value.ReplaceMetadata(productsTable, Value.Metadata(productsTable) & [Name = "Products"]),
expandedTable = Table.ExpandRecordColumn(
namedTable, "Column1", {"uuid", "code", "name"}, {"uuid", "external_id", "name"}
)
in
Table.ChangeType(expandedTable, TableSchemas[ProductsTableSchema])
in
[
TransformMachines = TransformMachines,
TransformDowntimes = TransformDowntimes,
TransformProductionRuns = TransformProductionRuns,
TransformSites = TransformSites,
TransformProductivityMetrics = TransformProductivityMetrics
TransformProductivityMetrics = TransformProductivityMetrics,
TransformProducts = TransformProducts
]
9 changes: 9 additions & 0 deletions enlyze.pq
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TransformMachines = Transformers[TransformMachines];
TransformDowntimes = Transformers[TransformDowntimes];
TransformProductionRuns = Transformers[TransformProductionRuns];
TransformProductivityMetrics = Transformers[TransformProductivityMetrics];
TransformProducts = Transformers[TransformProducts];

MachineProductivityMetrics = loadModule("MachineProductivityMetrics.pqm");

Expand Down Expand Up @@ -62,6 +63,14 @@ shared enlyze.Contents = () =>
true
},
{"Sites", "sites", TransformSites(FetchPaginated("/sites", null)), "Table", "Table", true},
{
"Products",
"products",
TransformProducts(FetchPaginated("/products", null)),
"Table",
"Table",
true
},
{
"Machine Productivity Metrics",
"machineProductivityMetrics",
Expand Down

0 comments on commit e9854c1

Please sign in to comment.