Skip to content

Commit

Permalink
address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3rw3rk committed Jan 6, 2025
1 parent 9ad60fc commit 2c26f72
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/elm/Components/BarChart.elm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type BarChartConfig
}


{-| newBarChart: creates a new BarChart configuration with default values.
{-| newBarChartConfig : creates a new BarChart configuration with default values.
-}
newBarChartConfig : BarChartConfig
newBarChartConfig =
Expand All @@ -107,56 +107,56 @@ newBarChartConfig =
}


{-| withWidth: override the width of the chart (in pixels).
{-| withWidth : override the width of the chart (in pixels).
-}
withWidth : Float -> BarChartConfig -> BarChartConfig
withWidth v (BarChartConfig config) =
BarChartConfig { config | width = v }


{-| withHeight: override the height of the chart (in pixels).
{-| withHeight : override the height of the chart (in pixels).
-}
withHeight : Float -> BarChartConfig -> BarChartConfig
withHeight v (BarChartConfig config) =
BarChartConfig { config | height = v }


{-| withPadding: override the padding of the chart (in pixels).
{-| withPadding : override the padding of the chart (in pixels).
-}
withPadding : Float -> BarChartConfig -> BarChartConfig
withPadding v (BarChartConfig config) =
BarChartConfig { config | padding = v }


{-| withTitle: override the title of the chart.
{-| withTitle : override the title of the chart.
-}
withTitle : String -> BarChartConfig -> BarChartConfig
withTitle v (BarChartConfig config) =
BarChartConfig { config | title = v }


{-| withTitle: set the data for the chart.
{-| withData : set the data for the chart.
-}
withData : List ( Time.Posix, Float ) -> BarChartConfig -> BarChartConfig
withData v (BarChartConfig config) =
BarChartConfig { config | data = v }


{-| withTitle: override the max y-axis value (default value is inferred based on dataset).
{-| withMaxY : override the max y-axis value (default value is inferred based on dataset).
-}
withMaxY : Float -> BarChartConfig -> BarChartConfig
withMaxY v (BarChartConfig config) =
BarChartConfig { config | maybeMaxY = Just v }


{-| withPercentUnit: override unit for the values in the dataset to be percentages (default is time values).
{-| withPercentUnit : override unit for the values in the dataset to be percentages (default is time values).
-}
withPercentUnit : BarChartConfig -> BarChartConfig
withPercentUnit (BarChartConfig config) =
BarChartConfig { config | unit = percent }


{-| withNumberUnit: override unit for the values in the dataset to be plain number format
{-| withNumberUnit : override unit for the values in the dataset to be plain number format
with the given decimal places.
-}
withNumberUnit : Int -> BarChartConfig -> BarChartConfig
Expand All @@ -168,7 +168,7 @@ withNumberUnit v (BarChartConfig config) =
-- VIEW


{-| view: takes title, width (optional), height (optional), data, optional maximum y-axis value,
{-| view : takes title, width (optional), height (optional), data, optional maximum y-axis value,
unit as string, and returns a chart.
-}
view : BarChartConfig -> Html msg
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Pages/Org_/Repo_/Insights.elm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ init shared route () =
Time.posixToMillis shared.time // 1000

sevenDaysInSeconds =
7 * 24 * 60 * 60
7 * Helpers.oneDaySeconds

timeMinusSevenDaysInSeconds : Int
timeMinusSevenDaysInSeconds =
Expand Down
12 changes: 10 additions & 2 deletions src/elm/Utils/Helpers.elm
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,22 @@ noSomeSecondsAgo _ =
"just now"


{-| formatTimeFromFloat : takes a float (seconds) and passes it to formatTime
for a string representation. the value is floored since we don't measure
at sub-second accuraacy.
-}
formatTimeFromFloat : Float -> String
formatTimeFromFloat number =
number
|> floor
|> max 0
|> formatTime


{-| formatTime : takes an int (seconds) and converts it to a string representation.
example: 4000 -> 1h 6m 40s
-}
formatTime : Int -> String
formatTime totalSeconds =
let
Expand Down Expand Up @@ -256,7 +264,7 @@ formatTime totalSeconds =
else
""
in
if totalSeconds == 0 then
if totalSeconds < 1 then
"0s"

else
Expand Down

0 comments on commit 2c26f72

Please sign in to comment.