From 2fc294e8cb2c3aaa2f1ea0e37b7d1d804f6212fe Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 20 Mar 2008 17:48:54 +0000 Subject: [PATCH] Database Opt git-svn-id: file:///home/jan/tmp/wetterstation/trunk@245 dd492736-c11a-0410-ad51-8c26713eaf7f --- cronjob/chart/image_file/image_data.c | 2 +- cronjob/checksensor/checksensor.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cronjob/chart/image_file/image_data.c b/cronjob/chart/image_file/image_data.c index 0f3accd..805b9a5 100644 --- a/cronjob/chart/image_file/image_data.c +++ b/cronjob/chart/image_file/image_data.c @@ -326,7 +326,7 @@ pix_list_ptr get_pix_list(int c_width){ } /* Anfrage zusammenbauen */ - snprintf(query, BUFFSIZE, "SELECT round(date_part('epoch', current_timestamp))::int4 AS now, round(date_part('epoch', timestamp))::int4 AS times, %s AS val FROM %s WHERE sens_id=%d AND timestamp > (current_timestamp - INTERVAL '%d seconds') ORDER BY times ASC", img_cfg.table_field, table, img_cfg.sens_id, img_cfg.show_interval ); + snprintf(query, BUFFSIZE, "SELECT round(date_part('epoch', current_timestamp))::int4 AS now, round(date_part('epoch', timestamp))::int4 AS times, %s AS val FROM %s WHERE sens_id=%d AND timestamp > (select (current_timestamp - INTERVAL '%d seconds')) ORDER BY times ASC", img_cfg.table_field, table, img_cfg.sens_id, img_cfg.show_interval ); /* Anfrage stellen */ res = pg_check_exec(conn, query, 1); diff --git a/cronjob/checksensor/checksensor.c b/cronjob/checksensor/checksensor.c index 4d07e62..a39f586 100644 --- a/cronjob/checksensor/checksensor.c +++ b/cronjob/checksensor/checksensor.c @@ -164,7 +164,7 @@ static int count_data_by_sensor_id(PGconn *connection, int sens_id){ table = get_type_table_by_id(connection, sens_id); - snprintf(query_buff, BUFFSIZE, "SELECT count(sens_id) as num FROM %s WHERE sens_id=%d AND timestamp>(current_timestamp - INTERVAL '%d hours')",table, sens_id, global_opts.interval); + snprintf(query_buff, BUFFSIZE, "SELECT count(sens_id) as num FROM %s WHERE sens_id=%d AND timestamp>(select (current_timestamp - INTERVAL '%d hours'))",table, sens_id, global_opts.interval); count_res = pg_check_exec(connection, query_buff); if(PQntuples(count_res) < 1)