Index: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.3.war
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.3.war
===================================================================
--- hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.3.war	(revision 0)
+++ hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.3.war	(revision 43)

Property changes on: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.3.war
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: hci/trunk/eneraptor-web-app/application.properties
===================================================================
--- hci/trunk/eneraptor-web-app/application.properties	(revision 42)
+++ hci/trunk/eneraptor-web-app/application.properties	(revision 43)
@@ -3,7 +3,7 @@
 app.grails.version=1.3.6
 app.name=eneraptor-web-app
 app.servlet.version=2.4
-app.version=0.2
+app.version=0.3
 plugins.flot=0.2.2
 plugins.hibernate=1.3.6
 plugins.navigation=1.1.1
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp	(revision 42)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp	(revision 43)
@@ -28,7 +28,7 @@
 				<br /><br />
 			
 				<label for="timeFrameType">Time frame type</label>
-				<select name="timeFrameType" id="timeFrameType" >
+				<select name="timeFrameType" id="timeFrameType" >				
 					<option onclick="changeTimeFrameType('day')" value="day" selected="${timeFrameType == 'day'}">Daily</option>
 					<option onclick="changeTimeFrameType('month')" value="month" selected="${timeFrameType == 'month'}">Monthly</option>
 					<option onclick="changeTimeFrameType('year')" value="year" selected="${timeFrameType == 'year'}">Yearly</option>
Index: hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy	(revision 42)
+++ hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy	(revision 43)
@@ -97,6 +97,7 @@
 	def showGraph = {
 		
 		def graphToShow = EneGraph.get(params['graphId'])
+		String query
 		
 		List data = new ArrayList()
 		def results
@@ -103,17 +104,34 @@
 		def db_sql = new Sql(dataSource)
 		
 		if(graphToShow.timeFrameType == "day") {
-			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
+			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
 				data << [it.dt.getTime(), it.vl]
 			}
 		} else if (graphToShow.timeFrameType == "month") {
-			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
+			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
 				data << [it.dt.getTime(), it.vl]
 			}
 		} else if (graphToShow.timeFrameType == "year") {
-			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
+			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
 				data << [it.dt.getTime(), it.vl]
 			}
+		} else if (graphToShow.timeFrameType == "custom") {
+			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
+			query = ""
+			for(int i = 0; i < graphToShow.innerSections;i++) {
+				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
+				def currDate = new Date((long)currDateMillis)
+				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
+				def currDateStart = new Date((long)currDateStartMillis)
+				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
+				def currDateStop = new Date((long)currDateStopMillis)
+				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "')) "
+				if (i < (graphToShow.innerSections-1) ) query += "union "
+			}
+			query += "order by dt asc"
+			db_sql.eachRow(query) {
+				data << [it.dt.getTime(), it.vl]
+			}
 		}
 		
 		[data:data]
