Add setReviewed method to build repository

This commit is contained in:
xGamingDudex 2016-05-31 22:18:40 +02:00
parent 99027258ee
commit 1141a05310

View File

@ -93,7 +93,7 @@ public class MavericksRepository
try (Connection conn = DBPool.getAccount().getConnection())
{
String filter = onlyUnreviewed ? "WHERE Reviewed=0 " : "";
PreparedStatement stmt = conn.prepareStatement("SELECT (SELECT uuid FROM accounts WHERE accounts.id=mavericksMasterBuildersBuilds.accountId),BuildTheme,Points,Place,Date,Schematic FROM mavericksMasterBuildersBuilds " + filter + " ORDER BY Points LIMIT " + limit + " OFFSET " + offset);
PreparedStatement stmt = conn.prepareStatement("SELECT (SELECT uuid FROM accounts WHERE accounts.id=" + TABLE + ".accountId),BuildTheme,Points,Place,Date,Schematic FROM " + TABLE + " " + filter + " ORDER BY Points LIMIT " + limit + " OFFSET " + offset);
ResultSet set = stmt.executeQuery();
List<MavericksBuildWrapper> list = new ArrayList<>();
@ -115,5 +115,25 @@ public class MavericksRepository
}
});
}
public CompletableFuture<Boolean> setReviewed(long dateStamp, boolean reviewed)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection conn = DBPool.getAccount().getConnection())
{
PreparedStatement stmt = conn.prepareStatement("UPDATE " + TABLE + " SET Reviewed=? WHERE Date=?");
stmt.setInt(1, reviewed? 1 : 0);
stmt.setLong(2, dateStamp);
return stmt.executeUpdate() > 0;
}
catch(SQLException e)
{
throw new RuntimeException(e);
}
});
}
}