Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
9b53ad748b
Commit
588d3c9dda
@ -97,11 +97,6 @@ public class Event {
|
||||
return schemType;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getSchemType() {
|
||||
return schemType.toDB();
|
||||
}
|
||||
|
||||
private boolean now() {
|
||||
Instant now = Instant.now();
|
||||
return now.isAfter(start.toInstant()) && now.isBefore(end.toInstant());
|
||||
|
@ -41,7 +41,7 @@ public class Fight {
|
||||
public static List<Fight> getPage(int page, int elementsPerPage) {
|
||||
List<Fight> fights = getPage.listSelect(page * elementsPerPage, elementsPerPage);
|
||||
|
||||
List<FightPlayer> fightPlayers = FightPlayer.batchGet(fights.stream().map(f -> f.fightID).toArray(Integer[]::new));
|
||||
List<FightPlayer> fightPlayers = FightPlayer.batchGet(fights.stream().map(f -> f.fightID));
|
||||
for(Fight fight : fights) {
|
||||
fight.initPlayers(fightPlayers);
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ import de.steamwar.sql.internal.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class FightPlayer {
|
||||
@ -56,10 +57,9 @@ public class FightPlayer {
|
||||
create.update(fightID, userID, blue ? 1 : 2, kit, kills, isOut);
|
||||
}
|
||||
|
||||
public static List<FightPlayer> batchGet(Integer[] fightIds) {
|
||||
if(fightIds.length == 0)
|
||||
return Collections.emptyList();
|
||||
|
||||
return batchGet.listSelect((Object) fightIds);
|
||||
public static List<FightPlayer> batchGet(Stream<Integer> fightIds) {
|
||||
try (SelectStatement<FightPlayer> batch = new SelectStatement<>(table, "SELECT * FROM FightPlayer WHERE FightID IN (" + fightIds.map(Object::toString).collect(Collectors.joining(", ")) + ")")) {
|
||||
return batch.listSelect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SteamwarUser {
|
||||
|
||||
@ -47,7 +48,6 @@ public class SteamwarUser {
|
||||
private static final SelectStatement<SteamwarUser> byDiscord = table.selectFields("DiscordId");
|
||||
private static final SelectStatement<SteamwarUser> byTeam = table.selectFields("Team");
|
||||
private static final SelectStatement<SteamwarUser> getServerTeam = new SelectStatement<>(table, "SELECT * FROM UserData WHERE UserGroup != 'Member' AND UserGroup != 'YouTuber'");
|
||||
private static final SelectStatement<SteamwarUser> batchGet = new SelectStatement<>(table, "SELECT * FROM UserData WHERE id IN ?");
|
||||
|
||||
private static final Statement updateName = table.update(Table.PRIMARY, "UserName");
|
||||
private static final Statement updateLocale = table.update(Table.PRIMARY, "Locale", "ManualLocale");
|
||||
@ -135,7 +135,9 @@ public class SteamwarUser {
|
||||
if(ids.isEmpty())
|
||||
return;
|
||||
|
||||
batchGet.listSelect((Object) ids.toArray());
|
||||
try (SelectStatement<SteamwarUser> batch = new SelectStatement<>(table, "SELECT * FROM UserData WHERE id IN (" + ids.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) {
|
||||
batch.listSelect();
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
@ -63,7 +63,7 @@ public class Tutorial {
|
||||
|
||||
@Getter
|
||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||
private final int id;
|
||||
private final int tutorialId;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final int creator;
|
||||
@ -81,14 +81,14 @@ public class Tutorial {
|
||||
private final double stars;
|
||||
|
||||
public void release() {
|
||||
release.update(1, id);
|
||||
release.update(1, tutorialId);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(id);
|
||||
delete.update(tutorialId);
|
||||
}
|
||||
|
||||
public void rate(int user, int rating) {
|
||||
rate.update(id, user, rating);
|
||||
rate.update(tutorialId, user, rating);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ public final class SqlTypeMapper<T> {
|
||||
new SqlTypeMapper<>(String.class, "TEXT", ResultSet::getString, PreparedStatement::setString);
|
||||
new SqlTypeMapper<>(Timestamp.class, "TIMESTAMP", ResultSet::getTimestamp, PreparedStatement::setTimestamp);
|
||||
new SqlTypeMapper<>(InputStream.class, "BLOB", ResultSet::getBinaryStream, PreparedStatement::setBinaryStream);
|
||||
new SqlTypeMapper<>(Integer[].class, null, (rs, identifier) -> { throw new SecurityException("Arrays cannot be used as type (recursive select)"); }, (st, index, value) -> st.setArray(index, st.getConnection().createArrayOf("INTEGER", value)));
|
||||
}
|
||||
|
||||
private static <T> void primitiveMapper(Class<T> primitive, Class<T> wrapped, String sqlType, SQLReader<T> reader, SQLWriter<T> writer) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren