Only log to the database when the report has been closed.

This commit is contained in:
Keir 2015-11-20 23:05:42 +00:00
parent 07b6c7cde7
commit 5bbf5bcce5
2 changed files with 1 additions and 52 deletions

View File

@ -37,7 +37,7 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
/**
* ReportManager hooks into a synchronized network-wide report system
* with methods for updating/fetching/closing reports in real time.
* @author Ty
* @author Ty, iKeirNez
*
*/
public class ReportManager {
@ -129,9 +129,6 @@ public class ReportManager {
// Show user details of the report every x seconds
new ReportHandlerMessageTask(this, report).runTaskTimer(_javaPlugin, 20L * 10, 20L * 10);
int handlerId = getPlayerAccount(reportHandler).getAccountId();
_reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database
}
}
}
@ -164,7 +161,6 @@ public class ReportManager {
{
if (canReport(reportedPlayer))
{
int reporterId = getPlayerAccount(reporter).getAccountId();
Report report = getActiveReport(reportedPlayer.getName());
if (report != null && report.getCategory() == category)
@ -217,7 +213,6 @@ public class ReportManager {
}
}
_reportSqlRepository.logReportSending(report.getReportId(), reporterId, category, reason);
return report;
}

View File

@ -11,26 +11,8 @@ import org.bukkit.plugin.java.JavaPlugin;
public class ReportRepository extends RepositoryBase
{
/*
* *ReportTicket
id, date, accountId reported player, server, accountId of staff who closed, result, reason
ReportSenders
id, date, reportId, accountId of Reporter, Reason for report
ReportHandlers
id, date, reportId, accountId of Staff
This will be used to determine if staff are handling
*/
private static String CREATE_TICKET_TABLE = "CREATE TABLE IF NOT EXISTS reportTickets (reportId INT NOT NULL, eventDate LONG, playerId INT NOT NULL, server VARCHAR(50), closerId INT NOT NULL, result VARCHAR(25), reason VARCHAR(100), PRIMARY KEY (reportId), FOREIGN KEY (playerId) REFERENCES accounts(id), FOREIGN KEY (closerId) REFERENCES accounts(id));";
private static String CREATE_HANDLER_TABLE = "CREATE TABLE IF NOT EXISTS reportHandlers (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, handlerId INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (reportId) REFERENCES reportTickets(reportId), FOREIGN KEY (handlerId) REFERENCES accounts(id) );";
private static String CREATE_REPORTERS_TABLE = "CREATE TABLE IF NOT EXISTS reportSenders (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, reporterId INT NOT NULL, category TINYINT, reason VARCHAR(100), PRIMARY KEY (id), FOREIGN KEY (reportId) REFERENCES reportTickets(reportId), FOREIGN KEY (reporterId) REFERENCES accounts(id));";
private static String INSERT_TICKET = "INSERT INTO reportTickets (reportId, eventDate, playerId, server, closerId, result, reason) VALUES (?, now(), ?, ?, ?, ?, ?);";
private static String INSERT_HANDLER = "INSERT INTO reportHandlers (eventDate, reportId, handlerId) VALUES(now(), ?, ?);";
private static String INSERT_SENDER = "INSERT INTO reportSenders (eventDate, reportId, reporterId, category, reason) VALUES(now(), ?, ?, ?, ?);";
public ReportRepository(JavaPlugin plugin)
{
@ -40,10 +22,7 @@ This will be used to determine if staff are handling
@Override
protected void initialize()
{
// disabled until approved
// executeUpdate(CREATE_TICKET_TABLE);
// executeUpdate(CREATE_HANDLER_TABLE);
// executeUpdate(CREATE_REPORTERS_TABLE);
}
@Override
@ -52,31 +31,6 @@ This will be used to determine if staff are handling
}
public void logReportHandling(final int reportId, final int handlerId)
{
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
@Override
public void run()
{
executeUpdate(INSERT_HANDLER, new ColumnInt("reportId", reportId), new ColumnInt("handlerId", handlerId));
}
}), "Error logging report " + reportId + " as being handled by user " + handlerId + ".");
}
public void logReportSending(final int reportId, final int reporterId, final ReportCategory category, final String reason)
{
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
@Override
public void run()
{
executeUpdate(INSERT_SENDER, new ColumnInt("reportId", reportId), new ColumnInt("reporterId", reporterId),
new ColumnByte("type", (byte) category.getId()), new ColumnVarChar("reason", 100, reason));
}
}), "Error logging report " + reportId + " by user " + reporterId + ".");
}
public void logReport(final int reportId, final int playerId, final String server, final int closerId, final ReportResult result, final String reason)
{
handleDatabaseCall(new DatabaseRunnable(new Runnable()