Skip to content

[RTI][TOOL] Enable multiple emails and contact nos for receivers#152

Open
ChanukaUOJ wants to merge 4 commits into
LDFLK:mainfrom
ChanukaUOJ:feat/multiple-receiver-email-number
Open

[RTI][TOOL] Enable multiple emails and contact nos for receivers#152
ChanukaUOJ wants to merge 4 commits into
LDFLK:mainfrom
ChanukaUOJ:feat/multiple-receiver-email-number

Conversation

@ChanukaUOJ
Copy link
Copy Markdown
Member

@ChanukaUOJ ChanukaUOJ commented May 21, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request transitions the receiver contact information from single string fields to JSONB arrays for both emails and contact numbers. This change involves updates to the SQL schema, seed data, Pydantic models, and the service layer. Review feedback highlights that the removal of UNIQUE constraints on these fields makes existing error handling logic in the service layer unreachable and renders the conflict-related unit tests ineffective. Additionally, it is recommended to use generic SQLAlchemy JSON types instead of dialect-specific JSONB to maintain database flexibility and to ensure contact numbers are stored without hyphens per project standards.

Comment thread tool/backend/sql/schema.sql
Comment thread tool/backend/src/services/receiver_service.py Outdated
Comment thread tool/backend/src/models/table_schemas/table_schemas.py Outdated
Comment thread tool/backend/src/models/table_schemas/table_schemas.py Outdated
Comment thread tool/backend/test/test_receiver_service.py Outdated
@ChanukaUOJ ChanukaUOJ requested a review from zaeema-n May 21, 2026 10:10
@ChanukaUOJ
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the receiver contact information from single string fields to JSONB lists for both emails and contact numbers across the backend and frontend. Key changes include database schema updates, Pydantic model adjustments, and the introduction of a TagInput component in the frontend for managing multiple entries. Feedback focuses on maintaining data consistency by removing hyphens from stored phone numbers, restoring regex validation for contact lists using Annotated, cleaning up unreachable error handling in the service layer, and improving type safety by avoiding 'as any' in the frontend validation logic.

Comment thread tool/backend/sql/seed.sql Outdated
Comment thread tool/backend/src/models/request_models/receiver.py Outdated
Comment thread tool/backend/src/models/request_models/receiver.py Outdated
Comment thread tool/backend/src/services/receiver_service.py Outdated
Comment thread tool/frontend/src/consts/regx.ts
Comment thread tool/frontend/src/data/mockData.ts Outdated
Comment thread tool/frontend/src/data/mockData.ts Outdated
Comment thread tool/frontend/src/pages/Receivers.tsx Outdated
Comment thread tool/frontend/src/pages/Receivers.tsx Outdated
@ChanukaUOJ ChanukaUOJ linked an issue May 27, 2026 that may be closed by this pull request
position_id: UUID = Field(foreign_key="positions.id", description="ID of the position")
institution_id: UUID = Field(foreign_key="institutions.id", description="ID of the institution")
email: Optional[str] = Field(None, unique=True, description="Email of the receiver")
emails: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of email of the receiver")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
emails: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of email of the receiver")
emails: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of emails of the receiver")

emails: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of email of the receiver")
address: Optional[str] = Field(None, description="Address of the receiver")
contact_no: Optional[str] = Field(None, unique=True, description="Contact number of the receiver")
contact_nos: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of contact number of the receiver")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
contact_nos: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of contact number of the receiver")
contact_nos: Optional[List[str]] = Field(default_factory=list, sa_column=Column(JSON), description="List of contact numbers of the receiver")

Comment thread tool/backend/sql/seed.sql
((SELECT id FROM positions WHERE name = 'Department Head' LIMIT 1), (SELECT id FROM institutions WHERE name = 'Public Service Commission' LIMIT 1), 'head.psc@gov.lk', 'Gampaha', NULL);
INSERT INTO receivers (position_id, institution_id, emails, address, contact_nos) VALUES
((SELECT id FROM positions WHERE name = 'Information Officer' LIMIT 1), (SELECT id FROM institutions WHERE name = 'Ministry of Health' LIMIT 1), '["io.health@gov.lk"]', NULL, '["0112444555"]'),
((SELECT id FROM positions WHERE name = 'Designated Officer' LIMIT 1), (SELECT id FROM institutions WHERE name = 'Department of Education' LIMIT 1), '["do.edu@gov.lk"]', NULL, '[]'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we not keep empty values for contact nos or emails as NULL? Does it have to be an empty list?

position_id: Optional[UUID] = Field(None, alias="positionId", description="ID of the position")
institution_id: Optional[UUID] = Field(None, alias="institutionId", description="ID of the institution")
email: Optional[EmailStr] = Field(None, description="Email of the receiver")
emails: Optional[List[EmailStr]] = Field(None, description="List of receiver Emails")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
emails: Optional[List[EmailStr]] = Field(None, description="List of receiver Emails")
emails: Optional[List[EmailStr]] = Field(None, description="List of receiver emails")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file is called receiver.py but the file in response_models is receivers.py

email: Optional[str] = Field(
None, description="Email of the receiver"
emails: Optional[List[str]] = Field(
None, description="Email list of the receiver"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
None, description="Email list of the receiver"
None, description="List of receiver emails"

serialization_alias="contactNo",
description="Contact number of the receiver"
serialization_alias="contactNos",
description="Contact number list of the receiver"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
description="Contact number list of the receiver"
description="List of receiver contact numbers"

position_id: UUID = Field(..., alias="positionId", description="ID of the position")
institution_id: UUID = Field(..., alias="institutionId", description="ID of the institution")
email: Optional[EmailStr] = Field(None, description="Email of the receiver")
emails: Optional[List[EmailStr]] = Field(None, description="List of receiver Emails")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
emails: Optional[List[EmailStr]] = Field(None, description="List of receiver Emails")
emails: Optional[List[EmailStr]] = Field(None, description="List of receiver emails")

position: PositionShortResponse = Field(..., description="Position object of the receiver")
institution: InstitutionShortResponse = Field(..., description="Institution object of the receiver")
email: Optional[str] = Field(None, description="Email of the receiver")
emails: Optional[List[str]] = Field(None, description="Email list of the receiver")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
emails: Optional[List[str]] = Field(None, description="Email list of the receiver")
emails: Optional[List[str]] = Field(None, description="List of receiver emails")

emails: Optional[List[str]] = Field(None, description="Email list of the receiver")
address: Optional[str] = Field(None, description="Address of the receiver")
contact_no: Optional[str] = Field(None, serialization_alias="contactNo", description="Contact number of the receiver")
contact_nos: Optional[List[str]] = Field(None, serialization_alias="contactNos", description="Contact number list of the receiver")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
contact_nos: Optional[List[str]] = Field(None, serialization_alias="contactNos", description="Contact number list of the receiver")
contact_nos: Optional[List[str]] = Field(None, serialization_alias="contactNos", description="List of receiver contact numbers")

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.

[RTI][TOOL] Enable multiple emails and contact nos for receivers

2 participants