Exemple #1
0
func parseRow(row connection.Row) (Watcher, error) {
	w := Watcher{}
	var intervalID int32
	var uuid string
	var usersBuf, logs []byte
	err := row.Scan(&w.ID, &uuid, &w.Added, &w.Updated, &intervalID, &logs, &usersBuf)
	err = json.Unmarshal(logs, &w.Logs)
	if err != nil {
		return w, err
	}
	var usersArr []int
	err = json.Unmarshal(usersBuf, &usersArr)
	if err != nil {
		return w, err
	}
	for _, u := range usersArr {
		user, err := users.GetByID(u).One()
		if err != nil {
			continue
		}
		w.Users = append(w.Users, user)
	}
	w.Domain, err = domains.GetByUUID(uuid).One()
	if err != nil {
		return w, err
	}
	w.Interval, err = intervals.GetByID(intervalID).One()
	return w, err
}
Exemple #2
0
func parseRow(row connection.Row) (Notification, error) {
	n := Notification{}
	var userID int
	var messages, archived []byte
	err := row.Scan(&userID, &messages, &n.Updated, &n.Alerts, &archived)
	if err != nil {
		return n, err
	}
	err = json.Unmarshal(archived, &n.Archived)
	if err != nil {
		return n, err
	}
	err = json.Unmarshal(messages, &n.Messages)
	if err != nil {
		return n, err
	}
	n.User, err = users.GetByID(userID).One()
	if err != nil {
	}
	return n, err
}