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