Skip to content

Commit 0b7c140

Browse files
committed
Make Start Date Nullable
1 parent d31d799 commit 0b7c140

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id "org.sonarqube" version "5.0.0.4638"
3+
id 'org.flywaydb.flyway' version '10.20.0'
34
}
45

56
tasks.named("sonarqube") {

server/src/main/java/com/objectcomputing/checkins/services/volunteering/VolunteeringRelationship.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class VolunteeringRelationship {
4949
@Schema(description = "id of the organization with the relationship")
5050
private UUID organizationId;
5151

52-
@NotNull
52+
@Nullable
5353
@Column(name = "start_date")
5454
@TypeDef(type = DataType.DATE, converter = LocalDateConverter.class)
5555
@Schema(description = "when the relationship started")
@@ -67,11 +67,11 @@ public class VolunteeringRelationship {
6767
@Schema(description = "whether the Volunteering Relationship is active")
6868
private boolean active = true;
6969

70-
public VolunteeringRelationship(UUID memberId, UUID organizationId, LocalDate startDate, @Nullable LocalDate endDate) {
70+
public VolunteeringRelationship(UUID memberId, UUID organizationId, @Nullable LocalDate startDate, @Nullable LocalDate endDate) {
7171
this(null, memberId, organizationId, startDate, endDate, true);
7272
}
7373

74-
public VolunteeringRelationship(UUID memberId, UUID organizationId, LocalDate startDate, @Nullable LocalDate endDate, boolean active) {
74+
public VolunteeringRelationship(UUID memberId, UUID organizationId, @Nullable LocalDate startDate, @Nullable LocalDate endDate, boolean active) {
7575
this(null, memberId, organizationId, startDate, endDate, active);
7676
}
7777
}

server/src/main/java/com/objectcomputing/checkins/services/volunteering/VolunteeringRelationshipDTO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class VolunteeringRelationshipDTO {
2626
@Schema(description = "id of the organization with the relationship")
2727
private UUID organizationId;
2828

29-
@NotNull
29+
@Nullable
3030
@Schema(description = "when the relationship started")
3131
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
3232
private LocalDate startDate;
@@ -40,7 +40,7 @@ public class VolunteeringRelationshipDTO {
4040
@Schema(description = "whether the Volunteering Relationship is active")
4141
private Boolean active;
4242

43-
public VolunteeringRelationshipDTO(@NotNull UUID memberId, @NotNull UUID organizationId, @NotNull LocalDate startDate, @Nullable LocalDate endDate) {
43+
public VolunteeringRelationshipDTO(@NotNull UUID memberId, @NotNull UUID organizationId, @Nullable LocalDate startDate, @Nullable LocalDate endDate) {
4444
this(memberId, organizationId, startDate, endDate, true);
4545
}
4646
}

server/src/main/java/com/objectcomputing/checkins/services/volunteering/VolunteeringRelationshipRepository.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ JOIN volunteering_organization AS org USING(organization_id)
2121
AND rel.member_id = :memberId
2222
AND (rel.is_active = TRUE OR :includeDeactivated = TRUE)
2323
AND (org.is_active = TRUE OR :includeDeactivated = TRUE)
24-
ORDER BY rel.start_date, org.name""", nativeQuery = true)
24+
ORDER BY org.name""", nativeQuery = true)
2525
List<VolunteeringRelationship> findByMemberIdAndOrganizationId(UUID memberId, UUID organizationId, boolean includeDeactivated);
2626

2727
@Query(value = """
@@ -31,7 +31,7 @@ JOIN volunteering_organization AS org USING(organization_id)
3131
WHERE rel.member_id = :memberId
3232
AND (rel.is_active = TRUE OR :includeDeactivated = TRUE)
3333
AND (org.is_active = TRUE OR :includeDeactivated = TRUE)
34-
ORDER BY rel.start_date, org.name""", nativeQuery = true)
34+
ORDER BY org.name""", nativeQuery = true)
3535
List<VolunteeringRelationship> findByMemberId(UUID memberId, boolean includeDeactivated);
3636

3737
@Query(value = """
@@ -41,7 +41,7 @@ JOIN volunteering_organization AS org USING(organization_id)
4141
WHERE rel.organization_id = :organizationId
4242
AND (rel.is_active = TRUE OR :includeDeactivated = TRUE)
4343
AND (org.is_active = TRUE OR :includeDeactivated = TRUE)
44-
ORDER BY rel.start_date, org.name""", nativeQuery = true)
44+
ORDER BY org.name""", nativeQuery = true)
4545
List<VolunteeringRelationship> findByOrganizationId(UUID organizationId, boolean includeDeactivated);
4646

4747
@Query(value = """
@@ -50,7 +50,7 @@ JOIN volunteering_organization AS org USING(organization_id)
5050
JOIN volunteering_organization AS org USING(organization_id)
5151
WHERE (rel.is_active = TRUE OR :includeDeactivated = TRUE)
5252
AND (org.is_active = TRUE OR :includeDeactivated = TRUE)
53-
ORDER BY rel.start_date, org.name""", nativeQuery = true)
53+
ORDER BY org.name""", nativeQuery = true)
5454
List<VolunteeringRelationship> findAll(boolean includeDeactivated);
5555

5656
@Query(value = """

server/src/main/resources/db/common/V107__create_volunteering_tables.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CREATE TABLE volunteering_relationship
1616
relationship_id varchar PRIMARY KEY,
1717
member_id varchar REFERENCES member_profile (id),
1818
organization_id varchar REFERENCES volunteering_organization (organization_id),
19-
start_date timestamp NOT NULL,
19+
start_date timestamp,
2020
end_date timestamp,
2121
is_active boolean NOT NULL DEFAULT TRUE
2222
);

web-ui/src/components/volunteer/VolunteerRelationships.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
112112
setSelectedRelationship({
113113
memberId: onlyMe ? currentUser.id : '',
114114
organizationId: '',
115-
startDate: null, // Ensure this is a valid date object
116-
endDate: null // Ensure this is a valid date object
115+
startDate: null,
116+
endDate: null
117117
});
118118
setRelationshipDialogOpen(true);
119119
}, [currentUser.id, onlyMe]);
@@ -175,7 +175,7 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
175175
return;
176176
}
177177

178-
const formattedStartDate = formatDate(new Date(startDate));
178+
const formattedStartDate = startDate ? formatDate(new Date(startDate)) : null;
179179
const formattedEndDate = endDate ? formatDate(new Date(endDate)) : null;
180180

181181
const res = await resolve({
@@ -362,7 +362,7 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
362362
value={selectedRelationship?.organizationId || ''}
363363
/>
364364
<DatePickerField
365-
date={selectedRelationship?.startDate}
365+
date={selectedRelationship?.startDate || null}
366366
label="Start Date"
367367
setDate={date => setSelectedRelationship({ ...selectedRelationship, startDate: date })}
368368
/>

0 commit comments

Comments
 (0)