Add back in the bootstrap handler since I realized it is still useful to provide some amount of history at first install immediately

This commit is contained in:
David Dworken
2022-04-28 11:05:56 -07:00
parent da30659f64
commit 8a018b71b8
2 changed files with 30 additions and 0 deletions

View File

@ -85,6 +85,23 @@ func apiSubmitHandler(w http.ResponseWriter, r *http.Request) {
}
}
func apiEBootstrapHandler(w http.ResponseWriter, r *http.Request) {
userId := r.URL.Query().Get("user_id")
deviceId := r.URL.Query().Get("device_id")
updateUsageData(userId, deviceId)
tx := GLOBAL_DB.Where("user_id = ?", userId)
var historyEntries []*shared.EncHistoryEntry
result := tx.Find(&historyEntries)
if result.Error != nil {
panic(fmt.Errorf("DB query error: %v", result.Error))
}
resp, err := json.Marshal(historyEntries)
if err != nil {
panic(err)
}
w.Write(resp)
}
func apiQueryHandler(w http.ResponseWriter, r *http.Request) {
userId := r.URL.Query().Get("user_id")
deviceId := r.URL.Query().Get("device_id")