SteamWar/SpigotCore
Archiviert
13
0

Minimize SQL queries

Dieser Commit ist enthalten in:
Lixfel 2020-12-15 21:03:08 +01:00
Ursprung aebd4dde1b
Commit 26c67801d0

Datei anzeigen

@ -102,15 +102,10 @@ public class Schematic {
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
try{
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, Rank, SchemFormat FROM Schematic WHERE SchemOwner = ? ORDER BY SchemName", schemOwner);
ResultSet schematic = SQL.select("SELECT s.SchemID, s.SchemName, s.SchemOwner, s.Item, s.SchemType, s.Rank, s.SchemFormat FROM Schematic s LEFT JOIN SchemMember sm ON sm.SchemName = s.SchemName AND sm.SchemOwner = s.SchemOwner WHERE s.SchemOwner = ? OR sm.Member = ? ORDER BY s.SchemName", schemOwner, schemOwner);
List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){
while(schematic.next())
schematics.add(new Schematic(schematic));
}
List<SchematicMember> addedSchems = SchematicMember.getAccessibleSchems(schemOwner);
for(SchematicMember schem : addedSchems){
schematics.add(getSchemFromDB(schem.getSchemName(), schem.getSchemOwner()));
}
return schematics;
}catch(SQLException e){
throw new SecurityException("Failed listing schematics", e);