diff --git a/gts/MasterPage.master b/gts/MasterPage.master
index 5a368706..b4f3895d 100644
--- a/gts/MasterPage.master
+++ b/gts/MasterPage.master
@@ -31,6 +31,8 @@
DNS: 75.127.5.215
Pokémon available for offer.
+
+ battle videos.
diff --git a/gts/MasterPage.master.cs b/gts/MasterPage.master.cs
index 1f75658c..81a3f472 100644
--- a/gts/MasterPage.master.cs
+++ b/gts/MasterPage.master.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using PkmnFoundations.Data;
namespace PkmnFoundations.GTS
{
@@ -11,9 +12,35 @@ namespace PkmnFoundations.GTS
{
protected void Page_Load(object sender, EventArgs e)
{
+ // todo: I should store the available pokemon count
+ // on the cache in the same way so the website doesn't
+ // have a dependency on running in the same application
+ // as the gamestats server.
GtsSessionManager manager = GtsSessionManager.FromContext(Context);
int availTotal = manager.AvailablePokemon4 + manager.AvailablePokemon5;
litPokemon.Text = availTotal.ToString();
+
+ ulong bvCount4, bvCount5;
+
+ if (Cache["BattleVideoCount4"] == null ||
+ Cache["BattleVideoCount5"] == null)
+ {
+ bvCount4 = DataAbstract.Instance.BattleVideoCount4();
+ bvCount5 = DataAbstract.Instance.BattleVideoCount5();
+ Cache.Insert("BattleVideoCount4", bvCount4, null,
+ DateTime.Now.AddMinutes(1),
+ System.Web.Caching.Cache.NoSlidingExpiration);
+ Cache.Insert("BattleVideoCount5", bvCount5, null,
+ DateTime.Now.AddMinutes(1),
+ System.Web.Caching.Cache.NoSlidingExpiration);
+ }
+ else
+ {
+ bvCount4 = Convert.ToUInt64(Cache["BattleVideoCount4"]);
+ bvCount5 = Convert.ToUInt64(Cache["BattleVideoCount5"]);
+ }
+
+ litVideos.Text = (bvCount4 + bvCount5).ToString();
}
public String HeaderCssClass
diff --git a/library/Data/DataAbstract.cs b/library/Data/DataAbstract.cs
index 7a9abb7b..90e0f220 100644
--- a/library/Data/DataAbstract.cs
+++ b/library/Data/DataAbstract.cs
@@ -118,6 +118,8 @@ namespace PkmnFoundations.Data
public abstract ulong BattleVideoUpload4(BattleVideoRecord4 record);
public abstract BattleVideoHeader4[] BattleVideoSearch4(ushort species, BattleVideoRankings4 ranking, BattleVideoMetagames4 metagame, byte country, byte region, int count);
public abstract BattleVideoRecord4 BattleVideoGet4(ulong serial, bool incrementViews = false);
+
+ public abstract ulong BattleVideoCount4();
#endregion
#region Global Terminal 5
@@ -130,6 +132,8 @@ namespace PkmnFoundations.Data
public abstract ulong BattleVideoUpload5(BattleVideoRecord5 record);
public abstract BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoRankings5 ranking, BattleVideoMetagames5 metagame, byte country, byte region, int count);
public abstract BattleVideoRecord5 BattleVideoGet5(ulong serial, bool incrementViews = false);
+
+ public abstract ulong BattleVideoCount5();
#endregion
}
}
diff --git a/library/Data/DataMysql.cs b/library/Data/DataMysql.cs
index 6a0e2baa..2d38905e 100644
--- a/library/Data/DataMysql.cs
+++ b/library/Data/DataMysql.cs
@@ -2113,6 +2113,15 @@ namespace PkmnFoundations.Data
return new BattleVideoRecord4(header.PID, header.SerialNumber, header, data);
}
+
+ public override ulong BattleVideoCount4()
+ {
+ using (MySqlConnection db = CreateConnection())
+ {
+ db.Open();
+ return Convert.ToUInt64(db.ExecuteScalar("SELECT Count(*) FROM TerminalBattleVideos4"));
+ }
+ }
#endregion
#region Global Terminal 5
@@ -2463,6 +2472,15 @@ namespace PkmnFoundations.Data
return new BattleVideoRecord5(header.PID, header.SerialNumber, header, data);
}
+
+ public override ulong BattleVideoCount5()
+ {
+ using (MySqlConnection db = CreateConnection())
+ {
+ db.Open();
+ return Convert.ToUInt64(db.ExecuteScalar("SELECT Count(*) FROM TerminalBattleVideos5"));
+ }
+ }
#endregion
}
}