render power data in table format

This commit is contained in:
Eric Hulburd
2016-02-10 16:11:56 -06:00
parent b14c266de3
commit 9996dfc54e
26 changed files with 424 additions and 141 deletions

View File

@@ -44,8 +44,6 @@ var House = DB.sequelize.define(NAME, {
power_data.forEach((power_datum)=>{
var day = house.timeToDateString(power_datum.time),
energy_datum = energy_data.get(day) || {production: 0, consumption: 0, day: day, house_id: house.id};
console.log(power_datum.time)
console.log(day)
energy_datum.production += power_datum.production;
energy_datum.consumption += power_datum.consumption;
energy_data.set(day, energy_datum);
@@ -62,10 +60,10 @@ var House = DB.sequelize.define(NAME, {
associate: ()=>{
House.hasMany(DB.PowerDatum, {as: 'PowerData'});
},
getPowerDataByTime: (start_date, end_date)=>{
getPowerDataByTime: (dates)=>{
var params = {
where: {time: {}},
attributes: ['time', 'consumption', 'production']
attributes: ['id', 'time', 'consumption', 'production']
};
if (start_date) params.where.time.$gt = moment.utc(start_date).toDate();
if (end_date) params.where.time.$lt = moment.utc(end_date).toDate();