diff options
author | Markus Grüneis <gimpf@gimpf.org> | 2014-10-24 23:25:10 +0200 |
---|---|---|
committer | Markus Grüneis <gimpf@gimpf.org> | 2014-10-24 23:25:10 +0200 |
commit | 5dde824bc3d7a92e6c8cc9838ff78b3457f5fcf4 (patch) | |
tree | a33951da07df6bd2125cf95ae5133f0af2102070 /src | |
parent | hub: fix default viz directory (diff) |
hub: add LIMIT to GetUpdatesAfter, API filter struct
Diffstat (limited to 'src')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5store.go | 14 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5typesApi.go | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go index efd459e..85a9a1f 100644 --- a/src/hub/src/spreadspace.org/sfive/s5store.go +++ b/src/hub/src/spreadspace.org/sfive/s5store.go @@ -116,7 +116,8 @@ func isEmptyFilter(filter *StatsFilter) bool { filter.format == nil && filter.quality == nil && (filter.tagsAny == nil || len(filter.tagsAny) == 0) && - filter.afterUpdateId == nil { + filter.afterUpdateId == nil && + filter.limit == nil { return true } return false @@ -142,10 +143,12 @@ func getFilteredDataUpdateSelect(filter *StatsFilter) (string, map[string]interf return baseQuery + ")", nil } - query := baseQuery + " where" + query := baseQuery parameters := make(map[string]interface{}) needsAnd := false + query += " WHERE" + if filter.start != nil { query += insertAnd(&needsAnd) query += " StartTime >= :filterstart" @@ -164,6 +167,10 @@ func getFilteredDataUpdateSelect(filter *StatsFilter) (string, map[string]interf parameters["afterUpdateId"] = *filter.afterUpdateId needsAnd = true } + if filter.limit != nil { + query += " LIMIT :limit" + parameters["limit"] = *filter.limit + } // TODO other fields query += ")" @@ -387,7 +394,8 @@ var ( ) func (s sqliteStore) GetUpdatesAfter(id int) (res []StatisticsData, err error) { - sourceSql, parameters := getFilteredDataUpdateSelect(&StatsFilter{afterUpdateId: &id}) + limit := 200 + sourceSql, parameters := getFilteredDataUpdateSelect(&StatsFilter{afterUpdateId: &id, limit: &limit}) sql := "SELECT " + updateColumnSelect + " FROM " + sourceSql updates, err := s.db.Select(dataUpdateQueryResult{}, sql, parameters) s5tl.Printf("sql: %s", sql) diff --git a/src/hub/src/spreadspace.org/sfive/s5typesApi.go b/src/hub/src/spreadspace.org/sfive/s5typesApi.go index bc32eb9..c02e5b2 100644 --- a/src/hub/src/spreadspace.org/sfive/s5typesApi.go +++ b/src/hub/src/spreadspace.org/sfive/s5typesApi.go @@ -64,6 +64,7 @@ type StatsFilter struct { quality *string tagsAny []string afterUpdateId *int + limit *int } func (self *StatisticsData) CopyFromSourceId(id *SourceId) { |