Skip to content

Remove unassigned deliveries section from campaign delivery summary#494

Merged
neal-bpm merged 1 commit intomainfrom
vn/remove-undelivered-slack-summary
Apr 30, 2026
Merged

Remove unassigned deliveries section from campaign delivery summary#494
neal-bpm merged 1 commit intomainfrom
vn/remove-undelivered-slack-summary

Conversation

@neal-bpm
Copy link
Copy Markdown
Contributor

@neal-bpm neal-bpm commented Apr 24, 2026

Describe your changes

Data Model (CampaignDeliverySummary)

  • Removed unassigned field from the struct
  • Updated module documentation to remove references to unassigned tracking
  • Clarified that :total now represents only assigned tasks

Delivery Summary Logic

  • Modified add_task/2 to skip counting unassigned tasks in the total
  • Introduced total_assigned_task/2 helper that only increments total for tasks with an assigned rider
  • Removed delivery/2 clause that collected unassigned tasks
  • Removed append/2 helper function (no longer needed)

Slack Integration

  • Removed build_unassigned_block/1 function from PayloadBuilder
  • Removed unassigned deliveries block from detailed delivery summary messages
  • Simplified message building to only include rider-assigned deliveries

Tests

  • Removed test validating empty unassigned list after adding a task
  • Removed tests for unassigned task tracking and display
  • Kept test validating unassigned tasks don't increment total count (renamed and clarified purpose)
  • Removed debug IO.inspect statement from test

Impact

Users will no longer see a separate "Unassigned Deliveries" section in campaign delivery summary Slack messages. The total delivery count reflects only assigned tasks, making the summary cleaner and more focused on actual rider assignments.
AI can make mistakes, so double-check responses

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added tests.
  • Are there other PRs or Issues that I should link to here?
  • Will this be part of a product update? If yes, please write one phrase
    about this update in the description above.

Summary by cubic

Removed the "Unassigned Deliveries" section from Slack campaign delivery summaries and stopped counting unassigned tasks in totals. The total now reflects only rider-assigned deliveries for a cleaner summary.

  • Refactors
    • Dropped unassigned from BikeBrigade.Delivery.CampaignDeliverySummary and updated docs.
    • Added total_assigned_task/2; add_task/2 only increments total for assigned tasks.
    • Simplified delivery/2 to ignore unassigned tasks; removed append/2 and the unassigned block in PayloadBuilder.
    • Removed tests for unassigned tracking/Slack block; kept a test to ensure unassigned tasks don't affect totals.

Written for commit 1bd488a. Summary will update on new commits.

Summary by CodeRabbit

  • Changes
    • Delivery summaries now track only assigned deliveries; total counts reflect assigned tasks only.
    • Unassigned deliveries are no longer tracked or displayed separately in summaries.
    • Slack notifications no longer include an "Unassigned Deliveries" section.

The total count now reflects only assigned delivery tasks.

- Remove `unassigned` field from CampaignDeliverySummary struct
  - Remove unassigned deliveries block from Slack message payloads
  - Update total count logic to only increment for assigned tasks
  - Remove related tests
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

The PR removes unassigned delivery tracking from the campaign delivery summary system. The CampaignDeliverySummary struct no longer tracks unassigned tasks, the unassigned field is removed, and associated logic for computing and rendering unassigned deliveries in Slack payloads is eliminated.

Changes

Cohort / File(s) Summary
Delivery Summary Core
lib/bike_brigade/delivery/campaign_delivery_summary.ex
Removed unassigned field from struct; updated module documentation to clarify :total tracks only assigned tasks; removed logic that aggregated unassigned deliveries.
Slack Payload Generation
lib/bike_brigade/slack_api/payload_builder.ex
Removed computation of unassigned_blocks and eliminated the "Unassigned Deliveries" section from Slack message payloads.
Test Suite
test/bike_brigade/delivery/campaign_delivery_summary_test.exs, test/bike_brigade/slack_api/payload_builder_test.exs
Removed test assertions validating unassigned delivery tracking and Slack rendering; updated expectations to exclude unassigned field from struct assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

  • Vn/campaign summary scheduler #486: Modified the same modules (CampaignDeliverySummary and PayloadBuilder) to add unassigned delivery tracking; this PR reverses those changes.

Suggested reviewers

  • mveytsman

Poem

🐰 Unassigned tasks fade away,
No more waiting in the gray,
Only riders with their route,
Slack stays clean, the message mute! 📬✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: removing the unassigned deliveries section from campaign delivery summaries.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description comprehensively addresses all required sections with clear explanations of changes across the data model, logic, Slack integration, and tests, including the impact of removing unassigned deliveries tracking.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vn/remove-undelivered-slack-summary

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@neal-bpm neal-bpm moved this to In Progress in Bike Brigade all things tech Apr 28, 2026
@neal-bpm neal-bpm requested a review from mveytsman April 28, 2026 17:45
@neal-bpm neal-bpm marked this pull request as ready for review April 28, 2026 17:46
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/bike_brigade/delivery/campaign_delivery_summary.ex">

<violation number="1" location="lib/bike_brigade/delivery/campaign_delivery_summary.ex:50">
P2: `completed` can now include unassigned completed tasks while `total` excludes unassigned tasks, causing inconsistent campaign summary counts.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

def add_task(cds, task) do
cds
|> Map.update!(:total, &(&1 + 1))
|> total_assigned_task(task)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: completed can now include unassigned completed tasks while total excludes unassigned tasks, causing inconsistent campaign summary counts.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/bike_brigade/delivery/campaign_delivery_summary.ex, line 50:

<comment>`completed` can now include unassigned completed tasks while `total` excludes unassigned tasks, causing inconsistent campaign summary counts.</comment>

<file context>
@@ -50,7 +47,7 @@ defmodule BikeBrigade.Delivery.CampaignDeliverySummary do
   def add_task(cds, task) do
     cds
-    |> Map.update!(:total, &(&1 + 1))
+    |> total_assigned_task(task)
     |> completed(task)
     |> delivery(task)
</file context>

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/bike_brigade/slack_api/payload_builder.ex (1)

110-116: Avoid rendering a trailing divider when there are no rider blocks.

This is a minor Slack formatting edge case; when cds.assigned is empty, the divider is left hanging.

Suggested refactor
-    blocks =
-      [
-        %{type: "section", text: %{type: "mrkdwn", text: header}},
-        %{type: "section", text: %{type: "mrkdwn", text: summary}},
-        %{type: "divider"}
-      ] ++ rider_blocks
+    blocks =
+      [
+        %{type: "section", text: %{type: "mrkdwn", text: header}},
+        %{type: "section", text: %{type: "mrkdwn", text: summary}}
+      ] ++
+        if rider_blocks == [] do
+          []
+        else
+          [%{type: "divider"} | rider_blocks]
+        end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/bike_brigade/slack_api/payload_builder.ex` around lines 110 - 116, The
blocks array is always adding a trailing divider before rider_blocks which
leaves a hanging divider when cds.assigned (and thus rider_blocks) is empty;
update the payload_builder logic that builds blocks so the divider is appended
only when rider_blocks is non-empty (e.g., create base_blocks = [%{type:
"section", text: %{type: "mrkdwn", text: header}}, %{type: "section", text:
%{type: "mrkdwn", text: summary}}] and then if rider_blocks != [] do base_blocks
++ [%{type: "divider"}] ++ rider_blocks else use base_blocks), referencing the
blocks and rider_blocks variables (and the source of rider_blocks from
cds.assigned) to locate and change the code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/bike_brigade/slack_api/payload_builder.ex`:
- Around line 110-116: The blocks array is always adding a trailing divider
before rider_blocks which leaves a hanging divider when cds.assigned (and thus
rider_blocks) is empty; update the payload_builder logic that builds blocks so
the divider is appended only when rider_blocks is non-empty (e.g., create
base_blocks = [%{type: "section", text: %{type: "mrkdwn", text: header}},
%{type: "section", text: %{type: "mrkdwn", text: summary}}] and then if
rider_blocks != [] do base_blocks ++ [%{type: "divider"}] ++ rider_blocks else
use base_blocks), referencing the blocks and rider_blocks variables (and the
source of rider_blocks from cds.assigned) to locate and change the code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 11df28ef-f26e-461b-a91b-0f574d068630

📥 Commits

Reviewing files that changed from the base of the PR and between f9f2db7 and 1bd488a.

📒 Files selected for processing (4)
  • lib/bike_brigade/delivery/campaign_delivery_summary.ex
  • lib/bike_brigade/slack_api/payload_builder.ex
  • test/bike_brigade/delivery/campaign_delivery_summary_test.exs
  • test/bike_brigade/slack_api/payload_builder_test.exs
💤 Files with no reviewable changes (1)
  • test/bike_brigade/slack_api/payload_builder_test.exs

Copy link
Copy Markdown
Member

@mveytsman mveytsman left a comment

Choose a reason for hiding this comment

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

LGTM!

@neal-bpm neal-bpm merged commit ff808be into main Apr 30, 2026
3 checks passed
@neal-bpm neal-bpm deleted the vn/remove-undelivered-slack-summary branch April 30, 2026 17:31
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Bike Brigade all things tech Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants