SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Minimize SQL queries' (#74) from speedupSchemListing into master

Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Lixfel 2020-12-19 09:17:25 +01:00
Commit 120e51a3a7

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);