Skip to content

[CSM Portal] Include endDate in project search results - #1200

Merged
cloby99 merged 2 commits into
wso2-open-operations:mainfrom
rksk:acp-project-enddate
Jul 22, 2026
Merged

[CSM Portal] Include endDate in project search results#1200
cloby99 merged 2 commits into
wso2-open-operations:mainfrom
rksk:acp-project-enddate

Conversation

@rksk

@rksk rksk commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds endDate to ProjectView, the unified shape returned by POST /projects/search for both data sources.
  • Both backends already had the value: the Postgres query already selects end_date, and ServiceNow's search response already returns endDate per project — it just wasn't carried through the mapping into the search response, even though endDate is already a supported filter/sort key on the same endpoint.
  • Needed to compute account-closure notice-window buckets (90/60/30/15/7/0 days) client-side from the sorted, Open-filtered result set without an extra per-project detail fetch.
  • Also documented the closure-state fields (closureState, endDateClosureState, invoiceDueDateClosureState, complianceViolationClosureState, complianceViolationDate) on ProjectView/ProjectDetailsView in openapi.yaml — these are already present in the real response from earlier project/account contact work, but were missing from the spec.

Goals

  • Surface endDate on project search results for both postgres and servicenow data sources.
  • Bring openapi.yaml in line with the actual response shape.

Approach

  • domain.ProjectView gains an EndDate time.Time field.
  • Postgres path (project_service.go): populate it from the already-selected domain.Project.EndDate.
  • ServiceNow path (sn_project_service.go): add endDate to the snProject unmarshal target and parse it (guarded on non-empty, since the field is nullable upstream) alongside the existing createdOn parse.
  • No changes needed in the Ballerina entity-service or ServiceNow — the field was already returned there, just dropped in this layer's mapping.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./...
  • gofmt -l on changed files (clean)

Release note

GET /projects/search results now include each project's endDate.

Documentation

Updated entity-service/openapi.yaml (ProjectView, ProjectDetailsView).

Security checks

  • Secure coding standards followed: yes
  • FindSecurityBugs/static analysis: N/A for Go — go vet ran clean, no new external calls or inputs introduced
  • No secrets committed: yes

Related PRs

Builds on #1191 (project/account contact search, closure fields, project update).

Summary by CodeRabbit

  • New Features
    • Project search and detail responses now include an optional (nullable) project end date; it’s omitted when no end date is available.
    • Added nullable closure and compliance-related properties (including closure states, invoice due date closure state, and compliance violation date information) to project API responses.
    • ServiceNow-sourced project search results now populate the end date whenever it is provided.

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.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 987aef01-fabc-45cd-b18b-c94a96145691

📥 Commits

Reviewing files that changed from the base of the PR and between 1e10f32 and b7c6187.

📒 Files selected for processing (4)
  • entity-service/internal/domain/entity.go
  • entity-service/internal/service/project_service.go
  • entity-service/internal/service/sn_project_service.go
  • entity-service/openapi.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • entity-service/internal/domain/entity.go
  • entity-service/internal/service/project_service.go
  • entity-service/internal/service/sn_project_service.go

📝 Walkthrough

Walkthrough

Project 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.

Changes

Project view field expansion

Layer / File(s) Summary
Project view contracts
entity-service/internal/domain/entity.go, entity-service/openapi.yaml
ProjectView adds serialized EndDate; project detail and summary schemas add nullable closure state and closure-date properties.
Project search end-date mapping
entity-service/internal/service/project_service.go, entity-service/internal/service/sn_project_service.go
Repository results assign EndDate directly, while ServiceNow results unmarshal and parse non-empty end-date strings before assigning them to ProjectView.

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
Loading

Possibly related PRs

Suggested labels: Area/Backend, Type/Improvement, App/CSM Portal

Suggested reviewers: rashmika998

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding endDate to project search results.
Description check ✅ Passed The description covers purpose, goals, approach, tests, release note, docs, security, and related PRs, so it is mostly complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 230e248 and 1e10f32.

📒 Files selected for processing (4)
  • entity-service/internal/domain/entity.go
  • entity-service/internal/service/project_service.go
  • entity-service/internal/service/sn_project_service.go
  • entity-service/openapi.yaml

Comment thread entity-service/internal/domain/entity.go Outdated
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).
@cloby99
cloby99 merged commit 59831a5 into wso2-open-operations:main Jul 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants