Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get values from input
- const { recordDuration, description} = input
- // duration seconds => hours, mins, seconds
- function secondsToHMS(d) {
- d = Number(d)
- var h = Math.floor(d / 3600)
- var m = Math.floor(d % 3600 / 60)
- var s = Math.floor(d % 3600 % 60)
- var hDisplay = h > 0 ? h + (h == 1 ? " hour " : " hours ") : ""
- var mDisplay = m > 0 ? m + (m == 1 ? " minute " : " minutes ") : ""
- var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""
- return hDisplay + mDisplay + sDisplay
- }
- const duration = secondsToHMS(recordDuration)
- if (description && description.includes("https://github.com/")) {
- // parse PR ID from description
- const descriptionSplit = description.split("/pull/")
- const afterPull = descriptionSplit.length > 1 ? descriptionSplit[1].split()[0] : ""
- const prID = afterPull.split(/(\s)/)[0]
- // get Repo from description
- const repoDescriptionSplit = description.split("https://github.com/")
- const repo = repoDescriptionSplit.length > 1
- ? repoDescriptionSplit[1].split("/pull/")[0]
- : ""
- output = [{duration, prID, repo}]
- } else {
- output = [{duration, prID: null, repo: null}]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement