summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Grüneis <gimpf@gimpf.org>2014-10-19 14:51:10 +0200
committerMarkus Grüneis <gimpf@gimpf.org>2014-10-19 14:52:26 +0200
commitd1e7460a9cda28b99c9c2644b6e178066d323c0d (patch)
treedab3a367d2e561d3d80c46b67cbec49952a3fc7f
parenthub: remove obsolete shell scripts (diff)
hub: fix storing client-specific data
-rw-r--r--dat/sample.json1
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5store.go3
2 files changed, 3 insertions, 1 deletions
diff --git a/dat/sample.json b/dat/sample.json
index de582d2..ed327fc 100644
--- a/dat/sample.json
+++ b/dat/sample.json
@@ -6,3 +6,4 @@
{"data": {"bytes-sent": 6226, "client-count": 1}, "start-time": "2013-10-21T15:00:00Z", "duration-ms": 300000}
{"data": {"bytes-sent": 0, "client-count": 0}, "start-time": "2013-10-21T15:10:00Z", "duration-ms": 300000}
{"data": {"bytes-sent": 8970, "client-count": 1}, "start-time": "2013-10-21T15:15:00Z", "duration-ms": 300000}
+{"data": {"bytes-sent": 413535, "clients": [{"ip": "85.238.166.201", "bytes-sent": 413535, "user-agent": "blah"}], "client-count": 1}, "start-time": "2013-10-24T05:18:28Z", "duration-ms": 5000}
diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go
index 6a6990e..89b449f 100644
--- a/src/hub/src/spreadspace.org/sfive/s5store.go
+++ b/src/hub/src/spreadspace.org/sfive/s5store.go
@@ -129,6 +129,7 @@ func initDb() *gorp.DbMap {
checkErr(err, "sql.Open failed")
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}
+ // dbmap.TraceOn("[gorp]", log.New(os.Stdout, "myapp:", log.Lmicroseconds))
dbmap.AddTableWithName(tagDb{}, TagsTn).SetKeys(true, "Id").ColMap("Name").SetUnique(true)
dbmap.AddTableWithName(sourceTagsDb{}, SourceTagsTn).SetKeys(false, "TagId", "SourceId")
@@ -286,7 +287,7 @@ func (s sqliteStore) insertDataUpdateEntry(src sourceDb, du *dataUpdateDb) (err
func (s sqliteStore) insertDataUpdateClientEntries(cd []clientDataDb, du dataUpdateDb) (err error) {
for i := range cd {
cd[i].DataUpdatesId = du.Id
- err = s.db.Insert(&cd)
+ err = s.db.Insert(&cd[i])
if err != nil {
return
}