Added column to track the number of times a battle video is watched.

This commit is contained in:
Greg Edwards
2014-07-14 19:47:53 -04:00
parent 05acceaacb
commit cc14cbc6d2
4 changed files with 16 additions and 8 deletions

View File

@@ -263,7 +263,7 @@ namespace PkmnFoundations.GlobalTerminalService
}
long serial = BitConverter.ToInt64(data, 0x140);
BattleVideoRecord4 record = DataAbstract.Instance.BattleVideoGet4(serial);
BattleVideoRecord4 record = DataAbstract.Instance.BattleVideoGet4(serial, true);
if (record == null)
{
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);

View File

@@ -224,7 +224,7 @@ namespace PkmnFoundations.GlobalTerminalService
}
long serial = BitConverter.ToInt64(data, 0x140);
BattleVideoRecord5 record = DataAbstract.Instance.BattleVideoGet5(serial);
BattleVideoRecord5 record = DataAbstract.Instance.BattleVideoGet5(serial, true);
if (record == null)
{
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);

View File

@@ -91,7 +91,7 @@ namespace PkmnFoundations.Data
public abstract long BattleVideoUpload4(BattleVideoRecord4 record);
public abstract BattleVideoHeader4[] BattleVideoSearch4(ushort species, BattleVideoRankings4 ranking, BattleVideoMetagames4 metagame, byte country, byte region, int count);
public abstract BattleVideoRecord4 BattleVideoGet4(long serial);
public abstract BattleVideoRecord4 BattleVideoGet4(long serial, bool incrementViews = false);
#endregion
#region Global Terminal 5
@@ -103,7 +103,7 @@ namespace PkmnFoundations.Data
public abstract long BattleVideoUpload5(BattleVideoRecord5 record);
public abstract BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoRankings5 ranking, BattleVideoMetagames5 metagame, byte country, byte region, int count);
public abstract BattleVideoRecord5 BattleVideoGet5(long serial);
public abstract BattleVideoRecord5 BattleVideoGet5(long serial, bool incrementViews = false);
#endregion
}
}

View File

@@ -1057,12 +1057,16 @@ namespace PkmnFoundations.Data
return new BattleVideoHeader4(reader.GetInt32(0), reader.GetInt64(1), data);
}
public override BattleVideoRecord4 BattleVideoGet4(long serial)
public override BattleVideoRecord4 BattleVideoGet4(long serial, bool incrementViews = false)
{
String update = incrementViews ? "UPDATE TerminalBattleVideos4 " +
"SET Views = Views + 1 WHERE SerialNumber = @serial; "
: "";
using (MySqlConnection db = CreateConnection())
{
db.Open();
MySqlDataReader reader = (MySqlDataReader)db.ExecuteReader("SELECT pid, " +
MySqlDataReader reader = (MySqlDataReader)db.ExecuteReader(update + "SELECT pid, " +
"SerialNumber, Header, Data FROM TerminalBattleVideos4 " +
"WHERE SerialNumber = @serial",
new MySqlParameter("@serial", serial));
@@ -1403,12 +1407,16 @@ namespace PkmnFoundations.Data
return new BattleVideoHeader5(reader.GetInt32(0), reader.GetInt64(1), data);
}
public override BattleVideoRecord5 BattleVideoGet5(long serial)
public override BattleVideoRecord5 BattleVideoGet5(long serial, bool incrementViews = false)
{
String update = incrementViews ? "UPDATE TerminalBattleVideos5 " +
"SET Views = Views + 1 WHERE SerialNumber = @serial; "
: "";
using (MySqlConnection db = CreateConnection())
{
db.Open();
MySqlDataReader reader = (MySqlDataReader)db.ExecuteReader("SELECT pid, " +
MySqlDataReader reader = (MySqlDataReader)db.ExecuteReader(update + "SELECT pid, " +
"SerialNumber, Header, Data FROM TerminalBattleVideos5 " +
"WHERE SerialNumber = @serial",
new MySqlParameter("@serial", serial));