Skip to content

feat(working-patterns): add Working Patterns and Allocations CRUD#104

Open
sgerrand wants to merge 3 commits into
mainfrom
feat/working-patterns
Open

feat(working-patterns): add Working Patterns and Allocations CRUD#104
sgerrand wants to merge 3 commits into
mainfrom
feat/working-patterns

Conversation

@sgerrand
Copy link
Copy Markdown
Owner

@sgerrand sgerrand commented May 4, 2026

💁 These changes add CRUD coverage for Working Patterns and Working Pattern Allocations.

Summary

  • `Humaans.WorkingPatterns` — `/api/working-patterns` (named schedule definitions)
  • `Humaans.WorkingPatternAllocations` — `/api/working-pattern-allocations` (per-person assignments within a date window)

Both ship as struct + module + tests using `Humaans.Resource`. Helpers and README updated.

The Working Pattern struct only declares the documented top-level fields (`id`, `companyId`, `name`, timestamps); deeper schedule-shape fields (e.g. day-of-week breakdowns) are not exposed in the public API reference excerpt and can be added additively if required.

Addresses Group D1 (Working Patterns family) of the API coverage review.

Test plan

  • `mix test` passes (14 new tests)
  • `mix credo` clean
  • `mix format --check-formatted` clean

sgerrand added 3 commits May 4, 2026 16:27
Adds Humaans.WorkingPatterns covering /api/working-patterns. Working
patterns are company-scoped schedule definitions referenced from
working pattern allocations.
Adds Humaans.WorkingPatternAllocations covering
/api/working-pattern-allocations. Allocations link a person to a
working pattern within a date window.
Copilot AI review requested due to automatic review settings May 4, 2026 15:28
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25327820523

Coverage decreased (-1.0%) to 98.98%

Details

  • Coverage decreased (-1.0%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (2 of 4 lines covered, 50.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
lib/humaans.ex 2 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 196
Covered Lines: 194
Line Coverage: 98.98%
Coverage Strength: 20.98 hits per line

💛 - Coveralls

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for the Humaans “Working Patterns” API family by introducing new resource modules + structs, wiring them into the top-level Humaans module, and adding ExUnit coverage and README documentation so consumers can CRUD working patterns and their per-person allocations.

Changes:

  • Add Humaans.WorkingPatterns and Humaans.WorkingPatternAllocations CRUD modules via use Humaans.Resource.
  • Add Humaans.Resources.WorkingPattern and Humaans.Resources.WorkingPatternAllocation structs with date/datetime parsing.
  • Add new tests for both resources and list them in the README + module access helpers in Humaans.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/humaans/working_patterns_test.exs Adds CRUD tests for Working Patterns.
test/humaans/working_pattern_allocations_test.exs Adds CRUD tests for Working Pattern Allocations (incl. date parsing).
README.md Documents the new resource modules in the “Available resources” list.
lib/humaans/working_patterns.ex Introduces Working Patterns resource module using the shared CRUD macro.
lib/humaans/working_pattern_allocations.ex Introduces Working Pattern Allocations resource module using the shared CRUD macro.
lib/humaans/resources/working_pattern.ex Adds Working Pattern struct + timestamp parsing.
lib/humaans/resources/working_pattern_allocation.ex Adds Working Pattern Allocation struct + date/datetime parsing.
lib/humaans.ex Exposes module-access helpers for the two new resource modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +21
expect(Humaans.MockHTTPClient, :request, fn client_param, opts ->
assert client_param == client
assert Keyword.fetch!(opts, :method) == :get
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/working-patterns"

Comment on lines +43 to +44
assert response.id == "wp_abc"
assert response.name == "Mon-Fri 9-5"
Comment on lines +17 to +23
expect(Humaans.MockHTTPClient, :request, fn client_param, opts ->
assert client_param == client
assert Keyword.fetch!(opts, :method) == :get

assert Keyword.fetch!(opts, :url) ==
"https://app.humaans.io/api/working-pattern-allocations"

assert response.working_pattern_id == "wp_abc"
assert response.start_date == ~D[2025-01-01]
assert response.end_date == ~D[2025-12-31]
assert response.created_at == ~U[2025-01-01 08:44:42.000Z]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants