mirror of
https://github.com/lucaspalomodevelop/Party.git
synced 2026-03-13 00:07:21 +00:00
170 wegen dingens
This commit is contained in:
parent
98bca3d461
commit
83699a92c2
@ -1,4 +1,4 @@
|
||||
from pymongo import MongoClient, DESCENDING, ASCENDING
|
||||
from pymongo import MongoClient
|
||||
from datetime import datetime
|
||||
|
||||
class Chat:
|
||||
@ -17,7 +17,7 @@ class Chat:
|
||||
|
||||
@classmethod
|
||||
def getAllMessages(self)-> list[dict]:
|
||||
messages = self.collection.find().sort('timestamp', DESCENDING)
|
||||
messages = self.collection.find().sort('timestamp', 1)
|
||||
return list(messages)
|
||||
|
||||
@classmethod
|
||||
@ -34,19 +34,11 @@ class Chat:
|
||||
messages = list(self.collection.find()
|
||||
.skip(skip)
|
||||
.limit(count)
|
||||
.sort('timestamp', DESCENDING))
|
||||
.sort('timestamp', 1))
|
||||
print(messages)
|
||||
|
||||
return messages
|
||||
|
||||
@classmethod
|
||||
def sortMessages(self, messages: list[dict], order: str) -> list[dict]:
|
||||
if order == 'asc':
|
||||
return sorted(messages, key=lambda message: message['timestamp'])
|
||||
elif order == 'desc':
|
||||
return sorted(messages, key=lambda message: message['timestamp'], reverse=True)
|
||||
else:
|
||||
return messages
|
||||
|
||||
@classmethod
|
||||
def convertToMessage(self, content: str, author: str, timestamp: str) -> dict:
|
||||
message = {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
function getNChatMessages(socket, count, skip) {
|
||||
socket.emit('chat-get-messages', { count: 100, skip: 0 }, (data) => {
|
||||
socket.emit('chat-get-messages', { count: 170, skip: 0 }, (data) => {
|
||||
sessionStorage['alreadyLoadedMessages'] += 100;
|
||||
let message_array = [];
|
||||
// dont fucking touch this
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user