Database Opt

git-svn-id: file:///home/jan/tmp/wetterstation/trunk@245 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
jan 2008-03-20 17:48:54 +00:00
parent 8fed47f7a0
commit 2fc294e8cb
2 changed files with 2 additions and 2 deletions

View File

@ -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);

View File

@ -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)