Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

128 organizer would like to vote too #275

Merged
merged 37 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2ccea6e
styling of the Session Page
Feb 22, 2023
6397d8d
voting as Admin is possible, Backend done, Frontend Restart Voting ne…
Mar 8, 2023
6d1fb9b
styled the session admin card, fixxed a voting Problem, restart is no…
Mar 9, 2023
0103315
fixxed the bug where the host Estimation didnt reset and also the hos…
Mar 14, 2023
aec6a3c
The admin Card wont be highlighted everytime
Mar 17, 2023
94f6c8e
fixxed the problem where the admin vote didnt reset
Mar 20, 2023
27ae44f
Issue now works as inteded only Tests missing
SponsoredByPuma Mar 24, 2023
b1523d1
Finished the backend tests
SponsoredByPuma Mar 27, 2023
1738640
add the feature to the documentation
SponsoredByPuma Mar 31, 2023
5f31011
add button on the prepare Page, changed the design on the button
SponsoredByPuma Apr 21, 2023
dde0e0a
updated the docs
SponsoredByPuma Apr 21, 2023
08696a4
buttons stay on pressed
SponsoredByPuma Apr 28, 2023
2fe53d6
fixxed a bug where the host couldnt go to estimate finished + reforma…
SponsoredByPuma May 8, 2023
76eca0e
removed Voting buttons from session page
SponsoredByPuma May 19, 2023
ae79d89
fixed format
SponsoredByPuma May 19, 2023
d14f37d
Merge branch 'main' into 128-organizer-would-like-to-vote-too
SponsoredByPuma May 19, 2023
bf07a14
Google Java Format
May 19, 2023
4c39534
fixed merging conflicts
SponsoredByPuma May 31, 2023
a83dc5a
Google Java Format
May 31, 2023
46185a4
Merge branch 'main' into 128-organizer-would-like-to-vote-too
SponsoredByPuma Oct 5, 2023
719c9c5
Merge remote-tracking branch 'origin/main' into 128-organizer-would-l…
SponsoredByPuma Oct 5, 2023
61fcdd2
updated the unknown locales to english + typo
SponsoredByPuma Oct 5, 2023
6a58474
Merge remote-tracking branch 'origin/128-organizer-would-like-to-vote…
SponsoredByPuma Oct 5, 2023
4be9879
update member estimate finished
SponsoredByPuma Oct 5, 2023
651222a
update backend test
SponsoredByPuma Oct 5, 2023
5964706
Google Java Format
Oct 5, 2023
34ec39b
updated docs
SponsoredByPuma Oct 5, 2023
b307cde
Merge remote-tracking branch 'origin/128-organizer-would-like-to-vote…
SponsoredByPuma Oct 5, 2023
8d507db
Merge remote-tracking branch 'origin/main' into 128-organizer-would-l…
SponsoredByPuma Oct 18, 2023
e8d009b
resolved merge conflicts
SponsoredByPuma Oct 18, 2023
0cd634e
fix AnalyticsControllerTest by adding hostVoting parameters
SponsoredByPuma Oct 18, 2023
e4a8749
Google Java Format
Oct 18, 2023
0c314aa
Merge remote-tracking branch 'origin/main' into 128-organizer-would-l…
SponsoredByPuma Oct 25, 2023
fa55aff
resolved merge conflicts, add styling to new components
SponsoredByPuma Oct 25, 2023
215a531
removed translations
SponsoredByPuma Oct 26, 2023
a82c831
removed translations
SponsoredByPuma Oct 26, 2023
1d8c654
reverted wrong translation
SponsoredByPuma Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public ResponseEntity<Map<String, Object>> createSession(
null,
accessToken,
null,
LocalDate.now());
LocalDate.now(),
false,
null);
databaseService.saveSession(session);
val responseMap = Map.of("session", session, "adminCookie", session.getAdminCookie());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public void joinMember(MemberPrincipal principal) {
webSocketService.sendTimerStartMessageToUser(
session, session.getTimerTimestamp(), principal.getMemberID());
}
webSocketService.sendUpdatedHostVotingToMember(session, principal.getMemberID());
if (session.getHostVoting() && session.getSessionState().equals(SessionState.VOTING_FINISHED)) {
webSocketService.sendMembersAdminVote(session);
}
webSocketService.sendNotification(
session,
new Notification(
Expand All @@ -96,7 +100,7 @@ public void removeMember(Principal principal) {
new Notification(
NotificationType.MEMBER_LEFT,
new MemberPayload(((MemberPrincipal) principal).getMemberID())));
boolean votingCompleted = checkIfAllMembersVoted(session.getMembers());
boolean votingCompleted = checkIfAllMembersVoted(session.getMembers(), session);
if (votingCompleted) {
votingFinished(
new AdminPrincipal(
Expand Down Expand Up @@ -150,14 +154,16 @@ public void getMemberUpdate(AdminPrincipal principal) {
}

@MessageMapping("/startVoting")
public void startEstimation(AdminPrincipal principal) {
public void startEstimation(AdminPrincipal principal, @Payload Boolean stateOfHostVoting) {
LOGGER.debug("--> startEstimation()");
val session =
ControllerUtils.getSessionOrThrowResponse(databaseService, principal.getSessionID())
.updateSessionState(SessionState.START_VOTING)
.resetCurrentHighlights()
.setHostVoting(stateOfHostVoting)
.setTimerTimestamp(Utils.getTimestampISO8601(new Date()));
databaseService.saveSession(session);
webSocketService.sendMembersHostVoting(session);
webSocketService.sendSessionStateToMembers(session);
webSocketService.sendTimerStartMessage(session, session.getTimerTimestamp());
LOGGER.debug("<-- startEstimation()");
Expand All @@ -172,11 +178,28 @@ public void votingFinished(AdminPrincipal principal) {
.selectHighlightedMembers()
.resetTimerTimestamp();
databaseService.saveSession(session);
if (session.getHostVoting()) {
webSocketService.sendMembersAdminVote(session);
}
webSocketService.sendMembersUpdate(session);
webSocketService.sendSessionStateToMembers(session);
LOGGER.debug("<-- votingFinished()");
}

@MessageMapping("/vote/admin")
public synchronized void processVoteAdmin(@Payload String vote, AdminPrincipal admin) {
LOGGER.debug("--> processVoteAdmin()");
val session =
ControllerUtils.getSessionOrThrowResponse(databaseService, admin.getSessionID())
.setHostEstimation(vote);
// webSocketService.sendMembersUpdate(session);
databaseService.saveSession(session);
if (checkIfAllMembersVoted(session.getMembers(), session)) {
votingFinished(new AdminPrincipal(admin.getSessionID(), admin.getAdminID()));
}
LOGGER.debug("<-- processVoteAdmin()");
}

@MessageMapping("/vote")
public synchronized void processVote(@Payload String vote, MemberPrincipal member) {
LOGGER.debug("--> processVote()");
Expand All @@ -186,7 +209,7 @@ public synchronized void processVote(@Payload String vote, MemberPrincipal membe
webSocketService.sendMembersUpdate(session);
databaseService.saveSession(session);

boolean votingCompleted = checkIfAllMembersVoted(session.getMembers());
boolean votingCompleted = checkIfAllMembersVoted(session.getMembers(), session);
if (votingCompleted) {
votingFinished(
new AdminPrincipal(
Expand All @@ -196,22 +219,31 @@ public synchronized void processVote(@Payload String vote, MemberPrincipal membe
LOGGER.debug("<-- processVote()");
}

private boolean checkIfAllMembersVoted(List<Member> members) {
return members.stream().filter(m -> m.getCurrentEstimation() == null).count() == 0;
private boolean checkIfAllMembersVoted(List<Member> members, Session session) {
if (session.getHostVoting() == false) {
return members.stream().filter(m -> m.getCurrentEstimation() == null).count() == 0;
}
return members.stream().filter(m -> m.getCurrentEstimation() == null).count() == 0
&& null != session.getHostEstimation()
&& !"".equals(session.getHostEstimation().getHostEstimation());
}

@MessageMapping("/restart")
public synchronized void restartVote(AdminPrincipal principal) {
public synchronized void restartVote(
AdminPrincipal principal, @Payload Boolean stateOfHostVoting) {
LOGGER.debug("--> restartVote()");
val session =
ControllerUtils.getSessionOrThrowResponse(databaseService, principal.getSessionID())
.updateSessionState(SessionState.START_VOTING)
.resetEstimations()
.setHostVoting(stateOfHostVoting)
.setTimerTimestamp(Utils.getTimestampISO8601(new Date()));
databaseService.saveSession(session);
webSocketService.sendMembersUpdate(session);
webSocketService.sendMembersHostVoting(session);
webSocketService.sendSessionStateToMembers(session);
webSocketService.sendTimerStartMessage(session, session.getTimerTimestamp());
webSocketService.sendMembersAdminVote(session);
LOGGER.debug("<-- restartVote()");
}

Expand Down
15 changes: 15 additions & 0 deletions backend/src/main/java/io/diveni/backend/model/AdminVote.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.diveni.backend.model;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode
@AllArgsConstructor
public class AdminVote {

private String hostEstimation;
}
Loading
Loading