From 7a1e1fd8d8175494100ec42f180574e241aa2b69 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Tue, 10 Oct 2017 22:38:15 -0700 Subject: [PATCH] Fix validator bugs --- config/postgres.sql | 4 ++++ ops/aggregation_validator.go | 2 +- postgres/trade_service.go | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/postgres.sql b/config/postgres.sql index 6360fd0..0037009 100644 --- a/config/postgres.sql +++ b/config/postgres.sql @@ -20,6 +20,10 @@ CREATE TABLE confirmations ( type CHAR(1) NOT NULL, last_id INTEGER NOT NULL DEFAULT 0); +CREATE UNIQUE INDEX confirmations_product_type_index ON confirmations ( + product, + type); + CREATE TABLE aggregations ( id SERIAL PRIMARY KEY, interval integer NOT NULL, diff --git a/ops/aggregation_validator.go b/ops/aggregation_validator.go index 36d7a02..c67e079 100644 --- a/ops/aggregation_validator.go +++ b/ops/aggregation_validator.go @@ -50,7 +50,7 @@ func (a *AggregationValidator) Stop() { func (a *AggregationValidator) emitProducts() { for _, p := range a.Products { - go a.validate(p) + a.validate(p) } } diff --git a/postgres/trade_service.go b/postgres/trade_service.go index 6064070..039e8b9 100644 --- a/postgres/trade_service.go +++ b/postgres/trade_service.go @@ -29,7 +29,7 @@ const ( trade_product = `SELECT DISTINCT product FROM trades;` trade_after_all = `SELECT id,` + trade_columns + `FROM trades WHERE product = $1 ` + `AND trade_id >= $2 ORDER BY trade_id ASC;` - trade_where = `SELECT id, ` + trade_columns + `WHERE` + trade_where = `SELECT id,` + trade_columns + `FROM trades WHERE` ) type TradeService struct { @@ -163,7 +163,7 @@ func (s *TradeService) TradesWhere(sql string, params ...interface{}) ([]tacitus s.client.logQuery(stmt, params...) - rows, err := s.client.db.Query(stmt, params) + rows, err := s.client.db.Query(stmt, params...) if err != nil { s.client.logError(stmt, err, params...)