Metrics and logs - MongoDB Submission (#43)
Adds MongoDB-backed submission for survey statistics/metrics and introduces MongoDB ObjectID-based participant/task identifiers to support upserts and linking metrics to a participant. It introduces breaking changes to the exsisting json stat and metric files. Delete the old ones Changes: Add internal/storage/MongoStorage and wire pm survey submit / pm start to submit local .pm/*.json files to MongoDB. Extend stats/metrics models to include MongoDB _id / participant_id fields and add participant ID propagation into task metrics. Update app initialization to generate ObjectIDs for new participants and expose GetParticipantID() via StatsService.
This commit is contained in:
@@ -1,24 +1,40 @@
|
||||
package models
|
||||
|
||||
import "os"
|
||||
|
||||
type Config struct {
|
||||
DbUri string
|
||||
AutoInit bool
|
||||
RootCmd string
|
||||
AppDir string
|
||||
WebAddress string
|
||||
BeadsDBPath string
|
||||
IssuePrefix string
|
||||
StatisticsStoragePath string
|
||||
ActionLogger func(string)
|
||||
StatisticsStoragePath string
|
||||
}
|
||||
|
||||
var BaseConfig = Config{
|
||||
DbUri: "",
|
||||
AutoInit: false,
|
||||
RootCmd: "pm",
|
||||
IssuePrefix: "pm",
|
||||
WebAddress: ":8080",
|
||||
BeadsDBPath: "./.pm/db.db",
|
||||
AppDir: "./.pm/",
|
||||
StatisticsStoragePath: "./.pm/stats.json",
|
||||
}
|
||||
|
||||
func (c Config) LoadFromEnv() Config {
|
||||
if dbURI, ok := os.LookupEnv("DB_URI"); ok {
|
||||
c.DbUri = dbURI
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (c Config) WithDbUri(uri string) Config {
|
||||
c.DbUri = uri
|
||||
return c
|
||||
}
|
||||
|
||||
func (c Config) WithAutoInit(autoInit bool) Config {
|
||||
c.AutoInit = autoInit
|
||||
return c
|
||||
@@ -34,11 +50,6 @@ func (c Config) WithWebAddress(webAddress string) Config {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c Config) WithBeadsDBPath(beadsDBPath string) Config {
|
||||
c.BeadsDBPath = beadsDBPath
|
||||
return c
|
||||
}
|
||||
|
||||
func (c Config) WithIssuePrefix(issuePrefix string) Config {
|
||||
c.IssuePrefix = issuePrefix
|
||||
return c
|
||||
|
||||
Reference in New Issue
Block a user