Skip to content

Commit 3253b68

Browse files
author
Holly Williams
committed
Merge branch 'develop' of https://github.com/objectcomputing/PulseSurvey into comments-tests
2 parents 349baf2 + ca06301 commit 3253b68

3 files changed

Lines changed: 20 additions & 42 deletions

File tree

send-surveys/src/main/java/com/objectcomputing/pulsesurvey/receive/responses/SurveyResponseController.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.objectcomputing.pulsesurvey.repositories.ResponseKeyRepository;
77
import com.objectcomputing.pulsesurvey.repositories.ResponseRepository;
88
import com.objectcomputing.pulsesurvey.repositories.UserCommentsRepository;
9-
import io.micronaut.context.annotation.Value;
109
import io.micronaut.core.util.CollectionUtils;
1110
import io.micronaut.http.HttpResponse;
1211
import io.micronaut.http.MediaType;
@@ -22,6 +21,7 @@
2221
import javax.inject.Inject;
2322
import java.net.URI;
2423
import java.net.URISyntaxException;
24+
import java.util.List;
2525
import java.util.Optional;
2626
import java.util.UUID;
2727
import java.util.concurrent.atomic.AtomicBoolean;
@@ -85,7 +85,7 @@ HttpResponse<String> happiness(String currentEmotion, String surveyKey) {
8585

8686
try {
8787
LOG.info("redirecting to /happiness/comment");
88-
return HttpResponse.redirect(new URI("/happiness/comment?surveyKey="+surveyKey));
88+
return HttpResponse.temporaryRedirect(new URI("/happiness/comment?surveyKey="+surveyKey));
8989
} catch (URISyntaxException e) {
9090
e.printStackTrace();
9191
LOG.error("unable to redirect to /happiness/comment " + e.getMessage());
@@ -95,8 +95,7 @@ HttpResponse<String> happiness(String currentEmotion, String surveyKey) {
9595
LOG.warn("This key is not valid: " + surveyKey);
9696
}
9797

98-
return HttpResponse.ok("Hello, your current emotion of " + currentEmotion + "!" +
99-
" is duly noted.");
98+
return HttpResponse.ok("This key has already been used.");
10099
}
101100

102101
@Get("comment")
@@ -110,13 +109,12 @@ public HttpResponse displayComments(String surveyKey) {
110109
@Post("userComments")
111110
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
112111
@View("thankyou")
113-
public HttpResponse sendThankYouWithCommentBlock
114-
(@Value("userComments") String userComments,
115-
@Value("surveyKey") String surveyKey) {
112+
public HttpResponse sendThankYouWithCommentBlock (String userComments, String surveyKey) {
116113

117114
LOG.info("The user has commented: " + userComments);
118115
LOG.info("With surveyKey: " + surveyKey);
119116
// put comment into the db using the survey key
117+
120118
boolean commentSaved = saveUserComment(surveyKey, userComments);
121119
LOG.info("commentSaved: " + commentSaved);
122120

@@ -165,6 +163,17 @@ boolean saveResponse(String currentEmotion, String surveyKey) {
165163
return responseAdded;
166164
}
167165

166+
private boolean checkForComment(String surveyKey) {
167+
168+
LOG.info("Validating comment " + surveyKey);
169+
List<UserComments> userComments = userCommentsRepo.findComments(surveyKey);
170+
171+
boolean isPresent = false;
172+
isPresent = !userComments.isEmpty();
173+
return isPresent;
174+
175+
}
176+
168177
boolean saveUserComment(String surveyKey, String comments) {
169178

170179
boolean commentsAdded = false;

send-surveys/src/main/java/com/objectcomputing/pulsesurvey/repositories/UserCommentsRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.objectcomputing.pulsesurvey.model.UserComments;
44
import edu.umd.cs.findbugs.annotations.NonNull;
5+
import io.micronaut.data.annotation.Query;
56
import io.micronaut.data.jdbc.annotation.JdbcRepository;
67
import io.micronaut.data.model.query.builder.sql.Dialect;
78
import io.micronaut.data.repository.CrudRepository;
@@ -20,4 +21,7 @@ public interface UserCommentsRepository extends CrudRepository<UserComments, UUI
2021
@Override
2122
<S extends UserComments> S save(@Valid @NotNull @NonNull S entity);
2223

24+
@Query("select * from usercomments where responsekey=:key")
25+
List<UserComments> findComments(String key);
26+
2327
}

send-surveys/src/main/resources/views/thankyou.hbs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,6 @@
1010
<link rel="stylesheet" type="text/css" href="/css/main.css"/>
1111
<link rel="icon" href="images/favicon.png" />
1212

13-
<!-- <style>-->
14-
<!-- * {-->
15-
<!-- box-sizing: border-box;-->
16-
<!-- }-->
17-
18-
<!-- .wrapper {-->
19-
<!-- display: flex;-->
20-
<!-- justify-content: center;-->
21-
<!-- align-self: center;-->
22-
<!--&lt;!&ndash; flex-direction: column;&ndash;&gt;-->
23-
<!-- }-->
24-
25-
<!-- body {-->
26-
<!-- background-color: #2559a7;-->
27-
<!-- }-->
28-
29-
<!-- .blue-background {-->
30-
<!-- padding: 1vh 2vw 1vh 2vw;-->
31-
<!-- background-color: #2559a7;-->
32-
<!-- align-self: center;-->
33-
<!-- justify-content: center;-->
34-
<!-- }-->
35-
36-
<!-- .thank-you {-->
37-
<!-- padding: 2vh 2vw;-->
38-
<!-- font-size: 5vw;-->
39-
<!-- font-family: 'Roboto', Verdana, sans-serif;-->
40-
<!-- font-weight: 600;-->
41-
<!-- color: #ffffff;-->
42-
<!-- align-self: center;-->
43-
<!-- justify-content: center;-->
44-
<!-- }-->
45-
46-
<!-- </style>-->
47-
4813
</head>
4914

5015
<body>

0 commit comments

Comments
 (0)