Added conditions for excluding deleted outfits
This commit is contained in:
parent
a7f0556db9
commit
a0d21342a2
@ -35,7 +35,7 @@ public class OutfitController {
|
|||||||
|
|
||||||
public static OutfitModel findRandom() throws SQLException {
|
public static OutfitModel findRandom() throws SQLException {
|
||||||
OutfitModel outfit = new OutfitModel();
|
OutfitModel outfit = new OutfitModel();
|
||||||
try (ResultSet rs = FSDB.get().select("SELECT * FROM outfits ORDERBY random() LIMIT 1")) {
|
try (ResultSet rs = FSDB.get().select("SELECT * FROM outfits WHERE deleted = 0 ORDERBY random() LIMIT 1")) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
outfit = mapObject(rs);
|
outfit = mapObject(rs);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ public class OutfitController {
|
|||||||
|
|
||||||
public static OutfitModel findRandomByTag(String tag) {
|
public static OutfitModel findRandomByTag(String tag) {
|
||||||
OutfitModel outfit = new OutfitModel();
|
OutfitModel outfit = new OutfitModel();
|
||||||
try (ResultSet rs = FSDB.get().select("SELECT * FROM outfits WHERE tag = ? ORDERBY random() LIMIT 1", tag)) {
|
try (ResultSet rs = FSDB.get().select("SELECT * FROM outfits WHERE tag = ? AND deleted = 0 ORDERBY random() LIMIT 1", tag)) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
outfit = mapObject(rs);
|
outfit = mapObject(rs);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public class OutfitController {
|
|||||||
|
|
||||||
public static OutfitModel findRandomBySubmitter(String submitterId) {
|
public static OutfitModel findRandomBySubmitter(String submitterId) {
|
||||||
OutfitModel outfit = new OutfitModel();
|
OutfitModel outfit = new OutfitModel();
|
||||||
try (ResultSet rs = FSDB.get().select("SELECT * FROM outfits WHERE submitter = ? ORDERBY random() LIMIT 1", submitterId)) {
|
try (ResultSet rs = FSDB.get().select("SELECT * FROM outfits WHERE submitter = ? AND deleted = 0 ORDERBY random() LIMIT 1", submitterId)) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
outfit = mapObject(rs);
|
outfit = mapObject(rs);
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class OutfitController {
|
|||||||
|
|
||||||
public static int countOutfits() {
|
public static int countOutfits() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
try (ResultSet rs = FSDB.get().select("SELECT COUNT(*) AS count FROM outfits")) {
|
try (ResultSet rs = FSDB.get().select("SELECT COUNT(*) AS count FROM outfits WHERE deleted = 0")) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
count = rs.getInt("count");
|
count = rs.getInt("count");
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public class OutfitController {
|
|||||||
|
|
||||||
public static int countOutfitsBySubmitter(String submitterId) {
|
public static int countOutfitsBySubmitter(String submitterId) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
try (ResultSet rs = FSDB.get().select("SELECT COUNT(*) AS count FROM outfits WHERE submitter = ?", submitterId)) {
|
try (ResultSet rs = FSDB.get().select("SELECT COUNT(*) AS count FROM outfits WHERE submitter = ? AND deleted = 0", submitterId)) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
count = rs.getInt("count");
|
count = rs.getInt("count");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user