Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
Deploying provider-intelligence-hub with
|
| Latest commit: |
ea82b49
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a22e9868.provider-intelligence-hub.pages.dev |
| Branch Preview URL: | https://expansion-reports-foundation.provider-intelligence-hub.pages.dev |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04266bde03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const activations = procurement | ||
| .filter((record) => inPeriod(record.activatedAt, period.start, period.end)) | ||
| .sort((a, b) => new Date(b.activatedAt || 0).getTime() - new Date(a.activatedAt || 0).getTime()); | ||
| const losses = procurement.filter((record) => inPeriod(record.lostAt, period.start, period.end)); |
There was a problem hiding this comment.
Derive activation history from immutable events
When an activated record is later moved back to another stage, the procurement PATCH route clears activatedAt (and similarly clears lostAt when reopening a loss), so this current-row lookup retroactively removes the event from prior-period reports and CSV exports. Reactivation also overwrites the timestamp, moving the original activation into the new period; use the persisted stage-change audit events to preserve historical activation and loss dates.
Useful? React with 👍 / 👎.
| const transitions = audits | ||
| .filter((event) => event.entityType === "procurement_record" && event.action === "stage_changed" && inPeriod(event.createdAt, period.start, period.end)) |
There was a problem hiding this comment.
Include outreach-driven stage changes
Stage changes performed by syncProcurementFromOutreach are recorded with action stage_changed_from_outreach, not stage_changed, so routine received/signed outreach transitions are omitted from transitions, the timeline, and the contact/agreement KPIs. Include both stage-change action values when building the transition history.
Useful? React with 👍 / 👎.
| .sort((a, b) => new Date(b.activatedAt || 0).getTime() - new Date(a.activatedAt || 0).getTime()); | ||
| const losses = procurement.filter((record) => inPeriod(record.lostAt, period.start, period.end)); | ||
| const newProviders = providers.filter((provider) => inPeriod(provider.createdAt, period.start, period.end)); | ||
| const outreachTouches = outreach.filter((record) => inPeriod(record.createdAt || record.sentAt, period.start, period.end)); |
There was a problem hiding this comment.
Exclude unsent drafts from outreach touches
Whenever email or fax delivery fails, the outreach route still creates a draft record, and imported planned drafts are also valid records; filtering every row by createdAt therefore reports these non-deliveries as outreach touches. This overstates both the current and comparison KPIs, so only actual sent/received/follow-up activity should contribute.
Useful? React with 👍 / 👎.
| function marketKey(record: Pick<ProcurementRecord, "city" | "state" | "country">) { | ||
| const parts = locationParts(record); | ||
| return parts.length ? parts.join(" | ").toLowerCase() : "unlocated"; | ||
| } |
There was a problem hiding this comment.
Exclude locationless records from market counts
Procurement locations are optional, but this sentinel key is inserted into activationMarkets and later contributes one to kpis.newMarkets and appears as an activated market. Thus any activation without city/state/country falsely reports a newly covered market; skip such records for market metrics instead of grouping them as unlocated.
Useful? React with 👍 / 👎.
Implements the non-visual foundation for the agreed Network Development Hub plan without adding or redesigning any UI.
Expansion tracking API
/api/analytics/network-development/expansionfrom/toReport data API
/api/analytics/network-development/report-dataExport
/api/analytics/network-development/activations.csvNo frontend changes are included in this PR. UI work will only proceed from an established external template/reference after explicit approval.