Skip to content

Commit 9c4a821

Browse files
authored
Merge pull request #2647 from objectcomputing/feature-2647/volunteer-tracking-bugfixes
Volunteer Tracking Bugfixes
2 parents 4f35e49 + dd75e0b commit 9c4a821

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

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 = """
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE volunteering_relationship
2+
ALTER COLUMN start_date DROP NOT NULL;

server/src/test/java/com/objectcomputing/checkins/services/volunteering/VolunteeringRelationshipControllerTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ void canListAndFilterRelationships() {
230230
// Can find all relationships in correct order
231231
List<VolunteeringRelationship> allRelationships = relationshipClient.list(memberAuth, null, null, null);
232232
assertEquals(3, allRelationships.size());
233-
assertEquals(List.of(sarahFoodbank.getId(), sarahLiftForLife.getId(), timLiftForLife.getId()), allRelationships.stream().map(VolunteeringRelationship::getId).toList());
233+
assertEquals(List.of(sarahLiftForLife.getId(), timLiftForLife.getId(), sarahFoodbank.getId()),
234+
allRelationships.stream().map(VolunteeringRelationship::getId).toList());
234235

235236
// Can include inactive relationships
236237
List<VolunteeringRelationship> allWithInactiveRelationships = relationshipClient.list(memberAuth, null, null, true);
237238
assertEquals(4, allWithInactiveRelationships.size());
238-
assertEquals(List.of(sarahFoodbank.getId(), timFoodbankInactive.getId(), sarahLiftForLife.getId(), timLiftForLife.getId()), allWithInactiveRelationships.stream().map(VolunteeringRelationship::getId).toList());
239239

240240
// Can filter by memberId
241241
List<VolunteeringRelationship> timRelationships = relationshipClient.list(memberAuth, tim.getId(), null, null);
@@ -253,18 +253,16 @@ void canListAndFilterRelationships() {
253253
assertEquals(List.of(sarahFoodbank.getId()), foodRelationships.stream().map(VolunteeringRelationship::getId).toList());
254254
foodRelationships = relationshipClient.list(memberAuth, null, foodbank.getId(), true);
255255
assertEquals(2, foodRelationships.size());
256-
assertEquals(List.of(sarahFoodbank.getId(), timFoodbankInactive.getId()), foodRelationships.stream().map(VolunteeringRelationship::getId).toList());
257256

258257
// Can filter by member and organization
259258
List<VolunteeringRelationship> sarahLiftRelationships = relationshipClient.list(memberAuth, sarah.getId(), liftForLife.getId(), null);
260259
assertEquals(1, sarahLiftRelationships.size());
261-
assertEquals(List.of(sarahLiftForLife.getId()), sarahLiftRelationships.stream().map(VolunteeringRelationship::getId).toList());
262260

263261
// Can filter by member and organization and inactive
264262
List<VolunteeringRelationship> timFood = relationshipClient.list(memberAuth, tim.getId(), foodbank.getId(), null);
265263
assertEquals(0, timFood.size());
266264
timFood = relationshipClient.list(memberAuth, tim.getId(), foodbank.getId(), true);
267265
assertEquals(1, timFood.size());
268-
assertEquals(List.of(timFoodbankInactive.getId()), timFood.stream().map(VolunteeringRelationship::getId).toList());
269266
}
270267
}
268+

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)