This commit is contained in:
BlubbFish 2013-07-14 15:26:19 +00:00
parent 9bb977dedb
commit 11c226bfcd
2 changed files with 5 additions and 3 deletions

View File

@ -119,7 +119,7 @@ namespace Matomat.Model
return ret; return ret;
} }
public static Tuple<int, double> GetDrunkProductsSum(User u, Product item, bool lastMonth) public static Tuple<int, double> GetDrunkProductsSum(User u, Product p, bool lastMonth)
{ {
DBQuery query = Factory.getDBO().getQuery(true); DBQuery query = Factory.getDBO().getQuery(true);
query.select("COUNT(*) AS " + Factory.getDBO().quoteName("boddles")); query.select("COUNT(*) AS " + Factory.getDBO().quoteName("boddles"));
@ -127,6 +127,7 @@ namespace Matomat.Model
query.from(Factory.getDBO().quoteName("history", "h")); query.from(Factory.getDBO().quoteName("history", "h"));
query.leftJoin(Factory.getDBO().quoteName("product", "p") + " ON " + Factory.getDBO().quoteName("p.id") + " = " + Factory.getDBO().quoteName("h.prod")); query.leftJoin(Factory.getDBO().quoteName("product", "p") + " ON " + Factory.getDBO().quoteName("p.id") + " = " + Factory.getDBO().quoteName("h.prod"));
query.where(Factory.getDBO().quoteName("h.user") + " = " + Factory.getDBO().quote(u.GetId().ToString())); query.where(Factory.getDBO().quoteName("h.user") + " = " + Factory.getDBO().quote(u.GetId().ToString()));
query.where(Factory.getDBO().quoteName("h.prod") + " = " + Factory.getDBO().quote(p.GetId().ToString()));
if (lastMonth) if (lastMonth)
{ {
query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 30 DAY)"); query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 30 DAY)");
@ -142,7 +143,7 @@ namespace Matomat.Model
return new Tuple<int, double>(int.Parse(row[0].ToString()), double.Parse(row[1].ToString()) / 1000); return new Tuple<int, double>(int.Parse(row[0].ToString()), double.Parse(row[1].ToString()) / 1000);
} }
public static List<int> GetDrunkProductsChart(User u, Product item, bool lastMonth, int days = 30) public static List<int> GetDrunkProductsChart(User u, Product p, bool lastMonth, int days = 30)
{ {
DBQuery query = Factory.getDBO().getQuery(true); DBQuery query = Factory.getDBO().getQuery(true);
query.select(Factory.getDBO().quoteName("h.prod", "product")); query.select(Factory.getDBO().quoteName("h.prod", "product"));
@ -150,6 +151,7 @@ namespace Matomat.Model
query.from(Factory.getDBO().quoteName("history", "h")); query.from(Factory.getDBO().quoteName("history", "h"));
query.order(Factory.getDBO().quoteName("h.time")+" ASC"); query.order(Factory.getDBO().quoteName("h.time")+" ASC");
query.where(Factory.getDBO().quoteName("h.user") + " = " + Factory.getDBO().quote(u.GetId().ToString())); query.where(Factory.getDBO().quoteName("h.user") + " = " + Factory.getDBO().quote(u.GetId().ToString()));
query.where(Factory.getDBO().quoteName("h.prod") + " = " + Factory.getDBO().quote(p.GetId().ToString()));
if (lastMonth) if (lastMonth)
{ {
query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 30 DAY)"); query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 30 DAY)");

View File

@ -17,7 +17,7 @@ namespace Matomat
public static void Main(string[] args) public static void Main(string[] args)
{ {
test(); //test();
InitMainThread(); InitMainThread();
Thread t = new Thread(MainThread); Thread t = new Thread(MainThread);
t.Start(); t.Start();