online stats replacement, design changes.

This commit is contained in:
Michael Wain 2024-02-22 03:02:42 +03:00
parent ff0fbe06ac
commit 162d287e78
9 changed files with 88 additions and 100 deletions

View File

@ -80,9 +80,7 @@ public class LongPoll {
}
private LongPollResult process(Long userId, LongPollConfig config) {
userService.updateOnline(userId);
Integer onlineCount = userService.countByIsOnline();
Integer onlineCount = map.size();
List<Chat> results;
List<UserResult> users = new ArrayList<>();
List<RoomResult> clientRooms = config.getRooms();
@ -92,6 +90,7 @@ public class LongPoll {
results = chatService.getAfterLastChatId(config.getLast_chat_id());
// Chat part
if( !results.isEmpty() ) {
users = results.stream()
.map(Chat::getUserId)
@ -118,6 +117,8 @@ public class LongPoll {
c.setMessage(message);
}).collect(Collectors.toList());
}
// Rooms part
if( !clientRooms.isEmpty() ) {
List<RoomResult> rooms = roomService.getAllActive().stream()
.map( r -> new RoomResult(r.getId(), r.getPlayerCount(), roomPlayerService.findByRoomId(r.getId()).stream()
@ -156,6 +157,7 @@ public class LongPoll {
.collect(Collectors.toList());
}
// Friends part
if( !clientFriends.isEmpty() ) {
List<UserResult> userResults = friendService.getFriendsOfUserId(userId)
.stream()

View File

@ -1,20 +0,0 @@
package com.alterdekim.game.component;
import com.alterdekim.game.service.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class OnlineStatus {
@Autowired
private UserServiceImpl userService;
@Scheduled(fixedRate = 50000)
private void resetOnlineStatus() {
userService.setAllOffline();
}
}

View File

@ -28,9 +28,6 @@ public class User {
@Column(nullable=false)
private String password;
@Column(columnDefinition = "boolean default false")
private Boolean isOnline;
@ManyToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@JoinTable(
name="users_roles",

View File

@ -11,16 +11,4 @@ import org.springframework.transaction.annotation.Transactional;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
User findByUsername(String username);
@Transactional
@Modifying
@Query(value = "UPDATE User u SET u.isOnline = true WHERE u.id = :uuid")
void setOnline(@Param(value = "uuid") Long id);
@Transactional
@Modifying
@Query(value = "UPDATE User u SET u.isOnline = false")
void setAllOffline();
Integer countByIsOnline(boolean isOnline);
}

View File

@ -69,17 +69,5 @@ public class UserServiceImpl implements UserService {
role.setName("ROLE_ADMIN");
return roleRepository.save(role);
}
public void updateOnline(Long userId) {
userRepository.setOnline(userId);
}
public void setAllOffline() {
userRepository.setAllOffline();
}
public Integer countByIsOnline() {
return userRepository.countByIsOnline(true);
}
}

View File

@ -22,7 +22,7 @@
padding-bottom: .1px;
width: 100%;
min-height: 1px;
background-color: #fff;
background-color: var(--dive-white);
}
.container {
@ -60,7 +60,7 @@
.mission-one {
margin-top: 10px;
border-top: 1px solid #e9eaec;
border-top: 1px solid var(--dive-light-grey-second);
padding: 10px;
}
@ -108,7 +108,7 @@
}
.title > span {
color: #a7adb5;
color: var(--dive-light-blue-grey);
font-size: 14px;
}
@ -129,14 +129,14 @@
.carousel-title-text {
font-size: 19px;
font-weight: 700;
color: #fff;
color: var(--dive-white);
}
.carousel-body-text {
margin-top: 10px;
font-size: 14px;
line-height: 20px;
color: #fff;
color: var(--dive-white);
}
.carousel-item-body {
@ -157,19 +157,19 @@
display: inline-flex;
align-items: center;
margin-right: 5px;
color: #989aa4;
color: var(--dive-light-blue-grey-second);
transform: translateY(1px);
}
.chat-history-user {
padding: 0 6px;
text-decoration: none;
background-color: #b9bac1;
background-color: var(--dive-light-blue-grey-third);
border-radius: 5px;
}
.chat-history-user>._nick {
color: #fff;
color: var(--dive-white);
font-weight: 600;
}
@ -197,7 +197,7 @@
flex-flow: column nowrap;
position: relative;
border-top: 1px solid;
border-color: #e6e6e6;
border-color: var(--dive-light-grey);
}
.games-room-one-body {
@ -240,12 +240,12 @@
}
.games-room-one-body-members-one-nick > a {
color: #656d78;
color: var(--dive-weird-blue-grey);
font-size: 14px;
}
.games-room-one-body-members-one-nick > span {
color: #656d78;
color: var(--dive-weird-blue-grey);
font-size: 14px;
text-decoration: none;
}
@ -295,7 +295,7 @@ body.modal-open > :not(.modal) {
}
.game-creation-modal-modes {
background-color: #f7f7f7;
background-color: var(--dive-light-grey-third);
flex-shrink: 0;
border-radius: 5px 0 0 5px;
padding: 10px 15px 10px 10px;
@ -313,7 +313,7 @@ body.modal-open > :not(.modal) {
border-radius: 5px;
padding: 20px 0;
width: 375px;
background-color: #fff;
background-color: var(--dive-white);
box-shadow: 0 0 25px rgba(0,0,0,.1);
}
@ -327,11 +327,11 @@ body.modal-open > :not(.modal) {
}
.game-creation-modal-modes-one._regular._selected {
background: #8cc152;
background: var(--dive-grass-green);
}
.game-creation-modal-modes-one._selected {
color: #fff;
color: var(--dive-white);
}
.game-creation-modal-modes-one {
@ -379,8 +379,8 @@ body.modal-open > :not(.modal) {
}
.form-check-input:checked {
background-color: #37bc9d;
border-color: #37bc9d;
background-color: var(--dive-primary-color);
border-color: var(--dive-primary-color);
}
#players-count-range, .players-range-value {
@ -389,7 +389,7 @@ body.modal-open > :not(.modal) {
}
.form-range::-webkit-slider-thumb {
background-color: #37bc9d;
background-color: var(--dive-primary-color);
}
.reply-button {
@ -409,6 +409,6 @@ body.modal-open > :not(.modal) {
.friend-one > ion-icon {
font-size: 18px;
color: #37bc9d;
color: var(--dive-primary-color);
cursor: pointer;
}

View File

@ -1,30 +1,30 @@
.navbar-brand-custom {
color: #ffffff;
color: var(--dive-white);
}
.navbar-brand-custom:hover {
color: #ffffff;
color: var(--dive-white);
}
.navbar {
background-color: #37bc9d;
background-color: var(--dive-primary-color);
}
.btn-outline-primary {
border-color: transparent;
color: #fff;
color: var(--dive-white);
}
.btn-primary {
background-color: rgba(255,255,255,.85);
color: #37bc9d;
color: var(--dive-primary-color);
border-color: rgba(255,255,255,.85);
}
.btn-primary:hover {
background-color: #ffffff;
border-color: #ffffff;
color: #37bc9d;
background-color: var(--dive-white);
border-color: var(--dive-white);
color: var(--dive-primary-color);
}
.btn-outline-primary:hover {
@ -34,26 +34,26 @@
.page-title {
font: 700 3.5em Montserrat;
color: #fff;
color: var(--dive-white);
}
.page-title-small {
margin-top: .7em;
font: 500 1.32em/1.4em Montserrat;
color: #fff;
color: var(--dive-white);
}
.main-billboard {
background-color: #37bc9d;
background-color: var(--dive-primary-color);
height: 700px;
text-align: center;
padding-top: 50px;
}
.main-button {
color: #5b5d67;
background-color: #fff;
border-color: #fff;
color: var(--dive-dark-grey-second);
background-color: var(--dive-white);
border-color: var(--dive-white);
font: 600 1.5rem Montserrat;
padding: 0 0.9em;
height: 2.1em;
@ -62,7 +62,7 @@
}
.main-button:hover {
color: #5b5d67;
color: var(--dive-dark-grey-second);
background-color: rgba(255, 255, 255, 0.85);
border-color: rgba(255, 255, 255, 0.85);
font: 600 1.5rem Montserrat;
@ -82,7 +82,7 @@
margin-bottom: 1.25em;
margin-left: 0px;
font: 700 3.25em Montserrat;
color: #26272b;
color: var(--dive-dark-grey-third);
text-align: center;
}

View File

@ -1,17 +1,34 @@
:root {
--dive-white: #fff;
--dive-grey: #f4f4f5;
--dive-dark-grey: #e6e9ed;
--dive-dark-grey-second: #5b5d67;
--dive-dark-grey-third: #26272b;
--dive-light-blue-grey: #a7adb5;
--dive-light-blue-grey-second: #989aa4;
--dive-light-blue-grey-third: #b9bac1;
--dive-light-grey: #e6e6e6;
--dive-weird-blue-grey: #656d78;
--dive-light-grey-second: #e9eaec;
--dive-light-grey-third: #f7f7f7;
--dive-grass-green: #8cc152;
--dive-primary-color: #37bc9d;
}
.navbar {
background-color: #fff;
background-color: var(--dive-white);
}
html, body {
font-family: 'Montserrat', sans-serif;
background-color: #f4f4f5;
background-color: var(--dive-grey);
font-size: 0.875rem;
}
footer {
bottom: 0;
width: 100%;
background-color: #e6e9ed;
background-color: var(--dive-dark-grey);
}
@ -25,21 +42,28 @@ footer {
.btn-outline-primary {
border-color: transparent;
color: #5b5d67;
color: var(--dive-dark-grey-second);
}
.btn-primary {
background-color: #37bc9d;
color: #fff;
border-color: #37bc9d;
--bs-btn-active-bg: #37bc9d;
background-color: var(--dive-primary-color);
color: var(--dive-white);
border-color: var(--dive-primary-color);
--bs-btn-active-bg: var(--dive-primary-color);
}
.btn-primary:active {
background-color: #37bc9d;
color: #fff;
border-color: #37bc9d;
--bs-btn-active-bg: #37bc9d;
background-color: var(--dive-primary-color);
color: var(--dive-white);
border-color: var(--dive-primary-color);
--bs-btn-active-bg: var(--dive-primary-color);
}
.btn-outline-primary:active {
background-color: var(--dive-primary-color);
color: var(--dive-white);
border-color: var(--dive-primary-color);
--bs-btn-active-bg: var(--dive-primary-color);
}
.btn-primary:hover {

View File

@ -28,9 +28,18 @@
</a>
</li>
<li class="nav-item">
<a href="/profile/" class="navbar-btn">
<img class="navbar-profile-img" src="https://avatars.githubusercontent.com/u/102559365?v=4"/>
</a>
<div class="dropdown">
<a class="navbar-btn dropdown-toggle" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
<img class="navbar-profile-img" src="https://avatars.githubusercontent.com/u/102559365?v=4">
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item">username</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="/profile/">Profile</a></li>
<li><a class="dropdown-item" href="/settings/">Settings</a></li>
<li><a class="dropdown-item" href="/logout">Logout</a></li>
</ul>
</div>
</li>
</ul>
</th:block>