From 26c67801d0512384980929405f210d17994c1a90 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 15 Dec 2020 21:03:08 +0100 Subject: [PATCH] Minimize SQL queries --- SpigotCore_Main/src/de/steamwar/sql/Schematic.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java index 91ba849..08770ea 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java @@ -102,15 +102,10 @@ public class Schematic { public static List 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 schematics = new ArrayList<>(); - while(schematic.next()){ + while(schematic.next()) schematics.add(new Schematic(schematic)); - } - List 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);