Skip to content

Commit ea92f7a

Browse files
authored
Merge branch 'develop' into feature-2647/volunteer-tracking-bugfixes
2 parents b744ffc + 7cb3342 commit ea92f7a

File tree

16 files changed

+382
-116
lines changed

16 files changed

+382
-116
lines changed

server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServicesImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ public ReviewAssignment save(ReviewAssignment reviewAssignment) {
4343
return newAssignment;
4444
}
4545

46+
// Now that uniqueness constraints have been placed on the
47+
// reviewee-reviewer-reviewPeriod, this method needs to be synchronized
48+
// to avoid multiple calls from the client-side overlapping and attempting
49+
// to create the same review assignments multiple times.
4650
@Override
47-
public List<ReviewAssignment> saveAll(UUID reviewPeriodId, List<ReviewAssignment> reviewAssignments, boolean deleteExisting) {
51+
public synchronized List<ReviewAssignment> saveAll(UUID reviewPeriodId, List<ReviewAssignment> reviewAssignments, boolean deleteExisting) {
4852

4953
if(deleteExisting) {
5054
LOG.warn("Deleting all review assignments for review period {}", reviewPeriodId);

server/src/main/java/com/objectcomputing/checkins/services/role/member_roles/MemberRoleController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.List;
1212
import java.util.UUID;
1313

14-
@Secured(SecurityRule.IS_ANONYMOUS)
14+
@Secured(SecurityRule.IS_AUTHENTICATED)
1515
@ExecuteOn(TaskExecutors.BLOCKING)
1616
@Controller("/services/roles/members")
1717
public class MemberRoleController {

server/src/main/java/com/objectcomputing/checkins/services/settings/SettingOption.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,26 @@
1616
@JsonDeserialize(using = SettingOptionDeserializer.class)
1717
public enum SettingOption {
1818
LOGO_URL("The logo url", Category.THEME, Type.FILE),
19-
PULSE_EMAIL_FREQUENCY("The Pulse Email Frequency (weekly, bi-weekly, monthly)", Category.CHECK_INS, Type.STRING);
19+
PULSE_EMAIL_FREQUENCY("The Pulse Email Frequency", Category.CHECK_INS, Type.STRING, List.of("weekly", "bi-weekly", "monthly"));
2020

2121
private final String description;
2222
private final Category category;
2323
private final Type type;
24+
private final List<String> values;
2425

2526
SettingOption(String description, Category category, Type type) {
2627
this.description = description;
2728
this.category = category;
2829
this.type = type;
30+
this.values = List.of();
2931
}
3032

31-
public String getDescription() {
32-
return description;
33-
}
34-
35-
public Category getCategory() {
36-
return category;
37-
}
38-
39-
public Type getType() {
40-
return type;
33+
SettingOption(String description, Category category, Type type,
34+
List<String> values) {
35+
this.description = description;
36+
this.category = category;
37+
this.type = type;
38+
this.values = values;
4139
}
4240

4341
public static List<SettingOption> getOptions(){

server/src/main/java/com/objectcomputing/checkins/services/settings/SettingOptionSerializer.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
66

77
import java.io.IOException;
8+
import java.util.List;
89

910
public class SettingOptionSerializer extends StdSerializer<SettingOption> {
1011

@@ -28,6 +29,15 @@ public void serialize(
2829
generator.writeString(settingOption.getCategory().name());
2930
generator.writeFieldName("type");
3031
generator.writeString(settingOption.getType().name());
32+
List<String> values = settingOption.getValues();
33+
if (!values.isEmpty()) {
34+
generator.writeFieldName("values");
35+
generator.writeStartArray(values.size());
36+
for(String value : values) {
37+
generator.writeString(value);
38+
}
39+
generator.writeEndArray();
40+
}
3141
generator.writeEndObject();
3242
}
33-
}
43+
}

server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ public SettingsResponseDTO findByName(@PathVariable @NotNull String name) {
7676
public List<SettingsResponseDTO> getOptions() {
7777
List<SettingOption> options = SettingOption.getOptions();
7878
return options.stream().map(option -> {
79-
// Default to an empty value and "invalid" UUID.
80-
// This can be used by the client to determine pre-existance.
8179
String value = "";
82-
UUID uuid = new UUID(0, 0);
80+
UUID uuid = null;
8381
try {
8482
Setting s = settingsServices.findByName(option.name());
8583
uuid = s.getId();
@@ -89,6 +87,7 @@ public List<SettingsResponseDTO> getOptions() {
8987
return new SettingsResponseDTO(
9088
uuid, option.name(), option.getDescription(),
9189
option.getCategory(), option.getType(),
90+
option.getValues(),
9291
value);
9392
}).toList();
9493
}
@@ -150,6 +149,7 @@ private SettingsResponseDTO fromEntity(Setting entity) {
150149
dto.setDescription(option.getDescription());
151150
dto.setCategory(option.getCategory());
152151
dto.setType(option.getType());
152+
dto.setValues(option.getValues());
153153
dto.setValue(entity.getValue());
154154
return dto;
155155
}

server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsResponseDTO.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import lombok.Setter;
1010

1111
import java.util.UUID;
12+
import java.util.List;
1213

1314
@Setter
1415
@Getter
@@ -36,6 +37,10 @@ public class SettingsResponseDTO {
3637
@Schema(description = "type of the setting")
3738
private SettingOption.Type type;
3839

40+
@NotNull
41+
@Schema(description = "possible values for the setting")
42+
private List<String> values;
43+
3944
@NotBlank
4045
@Schema(description = "value of the setting")
4146
private String value;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DELETE FROM review_assignments o USING review_assignments n
2+
WHERE o.id < n.id AND (o.reviewee_id = n.reviewee_id AND
3+
o.reviewer_id = n.reviewer_id AND
4+
o.review_period_id = n.review_period_id);
5+
6+
ALTER TABLE review_assignments
7+
ADD CONSTRAINT unique_assignment UNIQUE (reviewee_id, reviewer_id, review_period_id)

server/src/main/resources/db/dev/R__Load_testing_data.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,12 +1291,12 @@ VALUES
12911291
INSERT INTO review_periods
12921292
(id, name, review_status, review_template_id, self_review_template_id, launch_date, self_review_close_date, close_date, period_start_date, period_end_date)
12931293
VALUES
1294-
('12345678-e29c-4cf4-9ea4-6baa09405c57', 'Review Period 1', 'PLANNING', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-09-01', '2024-09-02', '2024-09-03', '2024-01-01', '2024-12-31');
1294+
('12345678-e29c-4cf4-9ea4-6baa09405c57', 'Review Period 1', 'PLANNING', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-09-01 06:00:00', '2024-09-02 06:00:00', '2024-09-03 06:00:00', '2024-01-01 06:00:00', '2024-08-31 06:00:00');
12951295

12961296
INSERT INTO review_periods
12971297
(id, name, review_status, review_template_id, self_review_template_id, launch_date, self_review_close_date, close_date, period_start_date, period_end_date)
12981298
VALUES
1299-
('12345678-e29c-4cf4-9ea4-6baa09405c58', 'Review Period 2', 'PLANNING', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-09-10', '2024-09-11', '2024-09-12', '2024-01-01', '2024-12-31');
1299+
('12345678-e29c-4cf4-9ea4-6baa09405c58', 'Review Period 2', 'PLANNING', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-09-10 06:00:00', '2024-09-11 06:00:00', '2024-09-12 06:00:00', '2024-01-01 06:00:00', '2024-08-31 06:00:00');
13001300

13011301
-- CAE - Self-Review feedback request, Creator: Big Boss
13021302
INSERT INTO feedback_requests

server/src/test/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentControllerTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ void testGETFindAssignmentsByPeriodIdDefaultAssignments() {
146146

147147
final HttpResponse<Set<ReviewAssignment>> response = client.toBlocking().exchange(request, Argument.setOf(ReviewAssignment.class));
148148

149+
// A review period only has default review assignments added to it when
150+
// the review period is created through the controller. And, they are
151+
// no longer added to the review period when retrieving the review
152+
// assignments for a specific review period. Therefore, this review
153+
// period should have zero review assignments associated with it.
149154
assertNotNull(response.body());
150155
assertEquals(0, Objects.requireNonNull(response.body()).size());
151156
}
@@ -283,4 +288,4 @@ void deleteReviewAssignmentWithoutPermissions() {
283288
assertNotNull(responseException.getResponse());
284289
assertEquals(HttpStatus.FORBIDDEN, responseException.getStatus());
285290
}
286-
}
291+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { resolve } from './api.js';
2+
3+
const reviewAssignmentsUrl = '/services/review-assignments';
4+
5+
export const getReviewAssignments = async (id, cookie) => {
6+
return resolve({
7+
url: `${reviewAssignmentsUrl}/period/${id}`,
8+
headers: { 'X-CSRF-Header': cookie, Accept: 'application/json' }
9+
});
10+
};
11+
12+
export const createReviewAssignments = async (id, assignments, cookie) => {
13+
return resolve({
14+
method: 'POST',
15+
url: `${reviewAssignmentsUrl}/${id}`,
16+
data: assignments,
17+
headers: {
18+
'X-CSRF-Header': cookie,
19+
Accept: 'application/json',
20+
'Content-Type': 'application/json;charset=UTF-8'
21+
}
22+
});
23+
};
24+
25+
export const updateReviewAssignment = async (assignment, cookie) => {
26+
return resolve({
27+
method: assignment.id === null ? 'POST' : 'PUT',
28+
url: reviewAssignmentsUrl,
29+
data: assignment,
30+
headers: {
31+
'X-CSRF-Header': cookie,
32+
Accept: 'application/json',
33+
'Content-Type': 'application/json;charset=UTF-8'
34+
}
35+
});
36+
};
37+
38+
export const removeReviewAssignment = async (id, cookie) => {
39+
return resolve({
40+
method: 'DELETE',
41+
url: `${reviewAssignmentsUrl}/${id}`,
42+
headers: { 'X-CSRF-Header': cookie }
43+
});
44+
};

0 commit comments

Comments
 (0)