Skip to content

Commit

Permalink
Merge pull request #14 from enlyze/enhancement/improve-resolution-field
Browse files Browse the repository at this point in the history
Make resolution field a single select drop down
  • Loading branch information
denizs authored Sep 30, 2024
2 parents 66725f2 + c229a29 commit d054063
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions MachineProductivityMetrics.pqm
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,28 @@ let
DateTimeRanges = loadModule("DateTimeRanges.pqm"),
PostRequest = loadModule("ApiClient.pqm")[PostRequest],
TransformProductivityMetrics = loadModule("Transforms.pqm")[TransformProductivityMetrics],
FunctionSignature = type function (
machines as table,
start as datetimezone,
end as datetimezone,
resolution as (
type text meta [
Documentation.Description = "Select a resolution.",
Documentation.AllowedValues = {"hourly", "daily", "weekly", "monthly"}
]
)
) as table,
MachineProductivityMetrics = (machines as table, start as datetimezone, end as datetimezone, resolution as text) as table =>
let
machineUuids = Table.Column(machines, "uuid"),
validResolutions = {"hourly", "daily", "weekly", "monthly"},
validatedResolution =
if List.Contains(validResolutions, resolution) then
resolution
else
error "Invalid resolution. Please choose 'hourly', 'daily', 'weekly', or 'monthly'.",
dateTimeRanges =
if validatedResolution = "hourly" then
if resolution = "hourly" then
DateTimeRanges[ToHourlyDateTimeRanges](start, end, resolution)
else if validatedResolution = "daily" then
else if resolution = "daily" then
DateTimeRanges[ToDailyDateTimeRanges](start, end)
else if validatedResolution = "weekly" then
else if resolution = "weekly" then
DateTimeRanges[ToWeeklyDateTimeRanges](start, end)
else if validatedResolution = "monthly" then
else if resolution = "monthly" then
DateTimeRanges[ToMonthlyDateTimeRanges](start, end)
else
error "Invalid resolution. Please choose 'hourly', 'daily', 'weekly', or 'monthly'.",
Expand All @@ -52,6 +57,7 @@ let
Table.Combine({state, TransformProductivityMetrics(responseDataWithMachine)})
)
in
accumulated
accumulated,
MachineProductivityMetricsCorrectType = Value.ReplaceType(MachineProductivityMetrics, FunctionSignature)
in
MachineProductivityMetrics
MachineProductivityMetricsCorrectType

0 comments on commit d054063

Please sign in to comment.