diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..c20320e --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,40 @@ +name: Deploy interactive viz to GitHub Pages + +on: + push: + branches: [master] + paths: + - "docs/**" + - ".github/workflows/pages.yml" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index ced34df..125fdcd 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,13 @@ A native iOS app that helps optimize your sleep by tracking your "sleep bank" an 3. Grant HealthKit permissions when prompted 4. Configure your sleep goal and wake time in settings +## Interactive: Midpoint + 6h grouping + +Sleep sessions are assigned to a calendar day using a "midpoint + 6 hours" rule (see +`SleepSession.dateForGrouping`). An interactive visualization of this rule lives in +[`docs/index.html`](docs/index.html) and is published via GitHub Pages (enable Pages → +"GitHub Actions" in repo settings to host it). + ## Privacy - All data stays on your device diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..0bc39de --- /dev/null +++ b/docs/index.html @@ -0,0 +1,461 @@ + + +
+ + ++ Bedger has to decide which calendar day a sleep session "belongs" to. A nap, an + overnight sleep that crosses midnight, and an early-evening doze all need a single + home day. The app does this by taking the midpoint of the session, shifting it + forward by 6 hours, and then taking the start of that day. +
++ The net effect: the "new day" for sleep starts at 6:00 PM. Drag the sleep + block below (or use the sliders) to see which day a session lands on and why. +
+Tip: drag the blue block to move it, or grab either edge to change start / end time.
+