diff options
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) { |