From afc23aec5bf43301b28fe12ba3d1e59922887c12 Mon Sep 17 00:00:00 2001 From: kristinaspring Date: Fri, 22 Mar 2019 10:08:54 -0700 Subject: [PATCH] Moved limit in method calls (#25) --- db/executer.go | 2 +- deploy/docker-compose/docFiles/gungnir.yaml | 1 + deploy/docker-compose/setup_db.sh | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db/executer.go b/db/executer.go index 16ac85e..fd65c64 100644 --- a/db/executer.go +++ b/db/executer.go @@ -54,7 +54,7 @@ type dbDecorator struct { } func (b *dbDecorator) find(out *[]Record, limit int, where ...interface{}) error { - db := b.Order("birth_date desc").Find(out, where...).Limit(limit) + db := b.Order("birth_date desc").Limit(limit).Find(out, where...) return db.Error } diff --git a/deploy/docker-compose/docFiles/gungnir.yaml b/deploy/docker-compose/docFiles/gungnir.yaml index 579512d..0f07023 100644 --- a/deploy/docker-compose/docFiles/gungnir.yaml +++ b/deploy/docker-compose/docFiles/gungnir.yaml @@ -28,6 +28,7 @@ authHeader: ["YXV0aEhlYWRlcg=="] + getLimit: 2 getRetries: 0 retryInterval: 0s db: diff --git a/deploy/docker-compose/setup_db.sh b/deploy/docker-compose/setup_db.sh index 155963e..7076bee 100644 --- a/deploy/docker-compose/setup_db.sh +++ b/deploy/docker-compose/setup_db.sh @@ -5,4 +5,5 @@ SQL="/cockroach/cockroach.sh sql $HOSTPARAMS" $SQL -e "CREATE USER IF NOT EXISTS roachadmin;" $SQL -e "CREATE DATABASE IF NOT EXISTS devices;" -$SQL -e "GRANT ALL ON DATABASE devices TO roachadmin;" \ No newline at end of file +$SQL -e "GRANT ALL ON DATABASE devices TO roachadmin;" +$SQL -e "CREATE TABLE devices.events (id BIGINT PRIMARY KEY DEFAULT unique_rowid(), type INT NOT NULL, device_id STRING NOT NULL, birth_date BIGINT NOT NULL, death_date BIGINT NOT NULL, data BYTES NOT NULL, INDEX idx_events_id_birth_date (device_id, birth_date DESC), INDEX idx_events_death_date (death_date DESC)) "