summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5store.go26
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5store_test.go2
2 files changed, 25 insertions, 3 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go
index e23c3db..e50daf3 100644
--- a/src/hub/src/spreadspace.org/sfive/s5store.go
+++ b/src/hub/src/spreadspace.org/sfive/s5store.go
@@ -175,13 +175,15 @@ func getFilteredDataUpdateSelect(filter *StatsFilter) (string, map[string]interf
if filter.start != nil {
query += insertAnd(&needsAnd)
- query += " Start >= :filterstart"
+ query += " StartTime >= :filterstart"
parameters["filterstart"] = filter.start
+ needsAnd = true
}
if filter.end != nil {
query += insertAnd(&needsAnd)
- query += " Start < :filterend"
+ query += " StartTime < :filterend"
parameters["filterend"] = filter.end
+ needsAnd = true
}
// TODO other fields
@@ -359,6 +361,26 @@ func (s sqliteStore) GetSource(id int) (res sourceDb, err error) {
return
}
+func (s sqliteStore) GetUpdate(id int) (res dataUpdateDb, err error) {
+ err = s.db.SelectOne(&res, "select * from "+dataUpdatesTn+" where Id = ?", id)
+ return
+}
+
+func (s sqliteStore) GetUpdates(filter *StatsFilter) (res []dataUpdateDb, err error) {
+ sourceSql, parameters := getFilteredDataUpdateSelect(filter)
+ updates, err := s.db.Select(
+ dataUpdateDb{},
+ "select Id, SourceId, StartTime, ClientCount, BytesReceived, BytesSent from "+sourceSql,
+ parameters)
+ if err == nil {
+ res = make([]dataUpdateDb, len(updates))
+ for i := range updates {
+ res[i] = *updates[i].(*dataUpdateDb)
+ }
+ }
+ return
+}
+
func (s sqliteStore) CountUpdateEntries(filter *StatsFilter) (count int64, err error) {
sourceSql, parameters := getFilteredDataUpdateSelect(filter)
count, err = s.db.SelectInt("select count(*) from "+sourceSql, parameters)
diff --git a/src/hub/src/spreadspace.org/sfive/s5store_test.go b/src/hub/src/spreadspace.org/sfive/s5store_test.go
index ce4ce0f..2bf862e 100644
--- a/src/hub/src/spreadspace.org/sfive/s5store_test.go
+++ b/src/hub/src/spreadspace.org/sfive/s5store_test.go
@@ -9,7 +9,7 @@ func TestGetFilter(t *testing.T) {
queryStartTime := time.Date(2015, time.December, 24, 1, 1, 1, 0, time.UTC)
filterStruct := StatsFilter{start: &queryStartTime}
fe, np := getFilteredDataUpdateSelect(&filterStruct)
- if fe != "(select * from DataUpdates where Start >= :filterstart)" {
+ if fe != "(select * from DataUpdates where StartTime >= :filterstart)" {
t.Errorf("get filter sql failed: fe: %v", fe)
}
if !queryStartTime.Equal(*np["filterstart"].(*time.Time)) {