diff options
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5store.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5store.go | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go index 9abbaea..efd459e 100644 --- a/src/hub/src/spreadspace.org/sfive/s5store.go +++ b/src/hub/src/spreadspace.org/sfive/s5store.go @@ -268,16 +268,7 @@ func (s sqliteStore) insertDataUpdateClientEntries(cd []clientDataDb, du dataUpd return } -// this function is the biggest pile of copy/pasted crap while sick that is still compilable. -func (s sqliteStore) Append(update StatisticsData) (err error) { - du, cd, src, tags := updateFromStatisticsData(update) - - // s.db.TraceOn("", log.New(os.Stdout, "gorptest: ", log.Lmicroseconds)) - tx, err := s.db.Begin() - if err != nil { - return - } - +func (s sqliteStore) appendItem(du dataUpdateDb, cd []clientDataDb, src sourceDb, tags []tagDb) (err error) { err = s.insertNewTags(tags) if err != nil { return @@ -304,6 +295,39 @@ func (s sqliteStore) Append(update StatisticsData) (err error) { return } + return +} + +// this function is the biggest pile of copy/pasted crap while sick that is still compilable. +func (s sqliteStore) Append(update StatisticsData) (err error) { + tx, err := s.db.Begin() + if err != nil { + return + } + + du, cd, src, tags := updateFromStatisticsData(update) + err = s.appendItem(du, cd, src, tags) + if err != nil { + return + } + + return tx.Commit() +} + +func (s sqliteStore) AppendMany(updates []StatisticsData) (err error) { + tx, err := s.db.Begin() + if err != nil { + return + } + + for _, update := range updates { + du, cd, src, tags := updateFromStatisticsData(update) + err = s.appendItem(du, cd, src, tags) + if err != nil { + return + } + } + return tx.Commit() } |