Merge branch 'chatlog-timestamp' into 'dev'

Fixed !146 Chatlog should be orderer by timestamp

See merge request morningstar/Arcturus-Community!151
This commit is contained in:
skeletor 2020-05-08 06:31:17 -04:00
commit d0b673952a

View File

@ -207,7 +207,7 @@ public class ModToolManager {
public ArrayList<ModToolChatLog> getUserChatlog(int userId) {
ArrayList<ModToolChatLog> chatlogs = new ArrayList<>();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE user_from_id = ? ORDER BY timestamp DESC LIMIT 150")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE user_from_id = ? ORDER BY chatlogs_room.timestamp DESC LIMIT 150")) {
statement.setInt(1, userId);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
@ -224,7 +224,7 @@ public class ModToolManager {
public ArrayList<ModToolChatLog> getMessengerChatlog(int userOneId, int userTwoId) {
ArrayList<ModToolChatLog> chatLogs = new ArrayList<>();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, chatlogs_private.* FROM chatlogs_private INNER JOIN users ON users.id = user_from_id WHERE (user_from_id = ? AND user_to_id = ?) OR (user_from_id = ? AND user_to_id = ?) ORDER BY timestamp DESC LIMIT 50")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, chatlogs_private.* FROM chatlogs_private INNER JOIN users ON users.id = user_from_id WHERE (user_from_id = ? AND user_to_id = ?) OR (user_from_id = ? AND user_to_id = ?) ORDER BY chatlogs_private.timestamp DESC LIMIT 50")) {
statement.setInt(1, userOneId);
statement.setInt(2, userTwoId);
statement.setInt(3, userTwoId);