8000 web: remove unused function expandScheduleCronString · coder/coder@077284f · GitHub
[go: up one dir, main page]

Skip to content

Commit 077284f

Browse files
committed
web: remove unused function expandScheduleCronString
1 parent f65dbba commit 077284f

File tree

3 files changed

+3
-35
lines changed

3 files changed

+3
-35
lines changed

site/src/components/Workspace/WorkspaceSchedule.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Box from "@material-ui/core/Box"
22
import Typography from "@material-ui/core/Typography"
33
import cronstrue from "cronstrue"
44
import React from "react"
5-
import { expandScheduleCronString, extractTimezone } from "../../util/schedule"
5+
import { stripTimezone, extractTimezone } from "../../util/schedule"
66
import { WorkspaceSection } from "./WorkspaceSection"
77

88
const Language = {
@@ -26,7 +26,7 @@ const Language = {
2626
},
2727
cronHumanDisplay: (schedule: string): string => {
2828
if (schedule) {
29-
return cronstrue.toString(expandScheduleCronString(schedule), { throwExceptionOnParseError: false })
29+
return cronstrue.toString(stripTimezone(schedule), { throwExceptionOnParseError: false })
3030
}
3131
return "Manual"
3232
},

site/src/util/schedule.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expandScheduleCronString, extractTimezone, stripTimezone } from "./schedule"
1+
import { extractTimezone, stripTimezone } from "./schedule"
22

33
describe("util/schedule", () => {
44
describe("stripTimezone", () => {
@@ -20,14 +20,4 @@ describe("util/schedule", () => {
2020
expect(extractTimezone(input)).toBe(expected)
2121
})
2222
})
23-
24-
describe("expandScheduleCronString", () => {
25-
it.each<[string, string]>([
26-
["CRON_TZ=Canada/Eastern 30 9 1-5", "30 9 * * 1-5"],
27-
["CRON_TZ=America/Central 0 8 1,2,4,5", "0 8 * * 1,2,4,5"],
28-
["30 9 1-5", "30 9 * * 1-5"],
29-
])(`expandScheduleCronString(%p) returns %p`, (input, expected) => {
30-
expect(expandScheduleCronString(input)).toBe(expected)
31-
})
32-
})
3323
})

site/src/util/schedule.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,3 @@ export const extractTimezone = (raw: string): string => {
3030
return DEFAULT_TIMEZONE
3131
}
3232
}
33-
34-
/**
35-
* expandScheduleCronString ensures a Schedule is expanded to a valid 5-value
36-
* cron string by inserting '*' in month and day positions. If there is a
37-
* leading timezone, it is removed.
38-
*
39-
* @example
40-
* expandScheduleCronString("30 9 1-5") // -> "30 9 * * 1-5"
41-
*/
42-
export const expandScheduleCronString = (schedule: string): string => {
43-
const prepared = stripTimezone(schedule).trim()
44-
45-
const parts = prepared.split(" ")
46-
47-
while (parts.length < 5) {
48-
// insert '*' in the second to last position
49-
// ie [a, b, c] --> [a, b, *, c]
50-
parts.splice(parts.length - 1, 0, "*")
51-
}
52-
53-
return parts.join(" ")
54-
}

0 commit comments

Comments
 (0)
0