[CSM Portal] Include endDate in project search results - #1200
Conversation
Both backends already had the project end date available (Postgres query selects end_date; ServiceNow's search response already returns it), but ProjectView dropped it when mapping to the unified search shape, so GET /projects/search never surfaced it despite endDate already being a supported search filter/sort key. Needed to compute ACP notice-window buckets (90/60/30/15/7/0 days) client-side from the sorted "Open" result set without a second per-project detail fetch. Also documented the closure-state fields in openapi.yaml's ProjectView and ProjectDetailsView schemas — present in the actual response since the earlier project/account contact work, but missing from the spec.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughProject view responses now expose project end dates. Repository and ServiceNow search mappings populate the new field, while OpenAPI project schemas add nullable closure-related properties. ChangesProject view field expansion
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant ServiceNow
participant snProject
participant SearchProjects
participant ProjectView
ServiceNow->>snProject: Return endDate JSON field
snProject->>SearchProjects: Unmarshal EndDate string
SearchProjects->>SearchProjects: Parse non-empty EndDate
SearchProjects->>ProjectView: Assign parsed EndDate
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@entity-service/internal/domain/entity.go`:
- Line 436: Preserve nullable ProjectView.endDate across all affected sites: in
entity-service/internal/domain/entity.go:436-436, change ProjectView.EndDate to
*time.Time; in entity-service/openapi.yaml:2722-2724, mark the property
nullable; in entity-service/internal/service/project_service.go:57-57, pass
PostgreSQL nullability through without pointing to a zero time; and in
entity-service/internal/service/sn_project_service.go:153-165, parse the source
value into a local time and assign nil when p.EndDate is absent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: edd9933e-b5ea-4a41-a179-1cfeafbba787
📒 Files selected for processing (4)
entity-service/internal/domain/entity.goentity-service/internal/service/project_service.goentity-service/internal/service/sn_project_service.goentity-service/openapi.yaml
ServiceNow can omit a project's end date; the previous value-typed field silently turned that absence into a year-1 zero timestamp while the OpenAPI schema disallowed null. EndDate is now *time.Time end-to-end (domain, Postgres and SN mapping, OpenAPI contract).
Summary
endDatetoProjectView, the unified shape returned byPOST /projects/searchfor both data sources.end_date, and ServiceNow's search response already returnsendDateper project — it just wasn't carried through the mapping into the search response, even thoughendDateis already a supported filter/sort key on the same endpoint.Open-filtered result set without an extra per-project detail fetch.closureState,endDateClosureState,invoiceDueDateClosureState,complianceViolationClosureState,complianceViolationDate) onProjectView/ProjectDetailsViewinopenapi.yaml— these are already present in the real response from earlier project/account contact work, but were missing from the spec.Goals
endDateon project search results for bothpostgresandservicenowdata sources.openapi.yamlin line with the actual response shape.Approach
domain.ProjectViewgains anEndDate time.Timefield.project_service.go): populate it from the already-selecteddomain.Project.EndDate.sn_project_service.go): addendDateto thesnProjectunmarshal target and parse it (guarded on non-empty, since the field is nullable upstream) alongside the existingcreatedOnparse.Test plan
go build ./...go vet ./...go test ./...gofmt -lon changed files (clean)Release note
GET /projects/searchresults now include each project'sendDate.Documentation
Updated
entity-service/openapi.yaml(ProjectView,ProjectDetailsView).Security checks
go vetran clean, no new external calls or inputs introducedRelated PRs
Builds on #1191 (project/account contact search, closure fields, project update).
Summary by CodeRabbit