// GetPrefixesForUser returns a list of all prefixes for the given user, factoring in schools and custom settings.
GetPrefixesForUser returns a list of all prefixes for the given user, factoring in schools and custom settings.
// GetPrefixesForUser returns a list of all prefixes for the given user factoring in schools and custom settings .
func GetPrefixesForUser(user *User) ([]Prefix, error) {
	prefixes := DefaultPrefixes
	for _, school := range user.Schools {
		if school.Enabled {
			prefixes = append(prefixes, school.School.Prefixes()...)
		}
	}
	rows, err := DB.Query("SELECT id, background, color, words, isTimedEvent FROM prefixes WHERE userId = ?", user.ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	for rows.Next() {
		resp := Prefix{}
		timedEventInt := -1
		wordsListString := ""
		rows.Scan(&resp.ID, &resp.Background, &resp.Color, &wordsListString, &timedEventInt)
		err := json.Unmarshal([]byte(wordsListString), &resp.Words)
		if err != nil {
			return nil, err
		}
		resp.TimedEvent = (timedEventInt == 1)
		prefixes = append(prefixes, resp)
	}
	return prefixes, nil
}
func GetPrefixesForUser ( user * User ) ( [ ] Prefix , error ) { prefixes := DefaultPrefixes for _ , school := range user . Schools { if school . Enabled { prefixes = append ( prefixes , school . School . Prefixes ( ) ... ) } } rows , err := DB . Query ( " " , user . ID ) if err != nil { return nil , err } defer rows . Close ( ) for rows . Next ( ) { resp := Prefix { } timedEventInt := - 1 wordsListString := " " rows . Scan ( & resp . ID , & resp . Background , & resp . Color , & wordsListString , & timedEventInt ) err := json . Unmarshal ( [ ] byte ( wordsListString ) , & resp . Words ) if err != nil { return nil , err } resp . TimedEvent = ( timedEventInt == 1 ) prefixes = append ( prefixes , resp ) } return prefixes , nil }
GetPrefixesForUser returns a list of all prefixes for the given user, factoring in schools and custom settings.
GetPrefixesForUser returns a list of all prefixes for the given user factoring in schools and custom settings .
// check for school prefixes we want to add // load user settings