{"id":21696443,"url":"https://github.com/madetech/pd-shifts","last_synced_at":"2025-03-20T14:48:08.358Z","repository":{"id":44533462,"uuid":"457027498","full_name":"madetech/pd-shifts","owner":"madetech","description":"A tool to count users' PagerDuty shifts","archived":false,"fork":false,"pushed_at":"2023-12-15T11:10:05.000Z","size":229,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T14:11:40.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madetech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-08T17:07:15.000Z","updated_at":"2023-08-30T14:14:11.000Z","dependencies_parsed_at":"2024-11-25T19:33:04.060Z","dependency_job_id":null,"html_url":"https://github.com/madetech/pd-shifts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fpd-shifts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fpd-shifts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fpd-shifts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fpd-shifts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madetech","download_url":"https://codeload.github.com/madetech/pd-shifts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244636016,"owners_count":20485441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T19:19:53.676Z","updated_at":"2025-03-20T14:48:08.340Z","avatar_url":"https://github.com/madetech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pd-shifts\n\nThis is a command-line tool to generate a CSV tally of on-call shifts per user for one or more PagerDuty schedules.\n\nIt goes from this:\n\n![An example PagerDuty schedule](./pagerduty-schedule.png)\n\nTo this ⬇️\n\n| User    | Weekday Shifts | Weekend Shifts | Total Shifts |\n|---------|----------------|----------------|--------------|\n| Alice   | 2              | 1              | 3            |\n| Bob     | 3              | 1              | 4            |\n| Charlie | 1              | 0              | 1            |\n| David   | 2              | 0              | 2            |\n| Eve     | 9              | 0              | 9            |\n| Frank   | 1              | 1              | 2            |\n\n## Assumptions\n\nThis tool is designed to count shifts according to a couple of unique assumptions. You'll likely need to have the same assumptions in order to find this tool helpful:\n\n- The length of shifts are irrelevant; we only care about the number of distinct shifts each user has completed.\n- We determine whether an on-call shift is a weekday or a weekend shift by the time that the shift started, irrespective of when the shift ends. For example, a Fri 17:00 - Sat 09:00 shift would be counted as a weekday shift.\n- All shifts that are started on a UK bank holiday are also counted as 'weekend' shifts.\n\n## Installation\n\nYou can install the `pd-shifts` tool directly from this repository:\n\n```sh\n$ cd /path/to/pd-shifts\n$ npm install -g .\n```\n\n## Usage\n\nIn order to use the tool, you must have:\n\n* **A valid PagerDuty API token:** you can get one by going to the \"My Profile\" page in the PagerDuty web interface, clicking on the \"User Settings\" tab, and then clicking the button to \"Create API User Token\".\n* **The ID(s) of the PagerDuty schedules you want to use:** you can get this directly from the URL when viewing a schedule in the PagerDuty web interface. For example, for this schedule https://organisation.pagerduty.com/schedules#PABCD12, the schedule ID is `PABCD12`.\n\nOnce you have these, you can plug them into the tool to generate your CSV:\n\n```sh\n$ pd-shifts \\\n    --token abcdeFGhIJklMn123456 \\\n    --schedule PABCD12 \\\n    --schedule PQRST34 \\\n    --from 2022-01-01 \\\n    --until 2022-02-01 \\\n    \u003e shifts.csv\n```\n\n### Options\n\n- `-f, --from` - The start date of the export (inclusive)\n- `-u, --until` - The end date of the export (exclusive)\n- `-t, --token` - The PagerDuty API token\n- `-s, --schedule` - ID of the PagerDuty schedule to count shifts from. Can be specified multiple times for multiple schedules.\n- `-l, --list-shifts` - Output a JSON listing of the shifts for each user, instead of the regular CSV output. Helpful for debugging.\n- `--max-shift-length` - The maximum length of a single shift, in hours. Default: 24 hours.\n    - This is needed because the PagerDuty API 'squashes' together multiple consecutive shifts, and so we need a way of determining at what point to 'chop' them back up again.\n\n## A note on bank holidays\n\nThe bank holidays are determined from the `data/bank-holidays.json` file, which is sourced from https://www.gov.uk/bank-holidays.json. In the future, a fresh copy of this JSON may need to be fetched in order to pull down new bank holidays:\n\n```sh\n$ curl \"https://www.gov.uk/bank-holidays.json\" \u003e data/bank-holidays.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadetech%2Fpd-shifts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadetech%2Fpd-shifts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadetech%2Fpd-shifts/lists"}