change up database configuration to use discrete values for parameters, rather than the raw DSN (database/base.go computes the DSN)

This commit is contained in:
2026-03-12 16:59:19 -06:00
parent 2cc0d0f94d
commit a91202a57e
6 changed files with 54 additions and 42 deletions
+3 -9
View File
@@ -15,7 +15,6 @@ import (
"strings"
"sync"
"git.erbosoft.com/amy/amsterdam/config"
"github.com/biter777/countries"
)
@@ -26,7 +25,7 @@ var cachedCountryList []countries.CountryCode = nil
var countryListMutex sync.Mutex
// AmCountryList is a wrapper around countries.All() that sorts it by country name.
func AmCountryList() []countries.CountryCode {
func AmCountryList(prioritize string) []countries.CountryCode {
countryListMutex.Lock()
defer countryListMutex.Unlock()
if cachedCountryList == nil {
@@ -34,9 +33,9 @@ func AmCountryList() []countries.CountryCode {
slices.SortFunc(countryList, func(a countries.CountryCode, b countries.CountryCode) int {
return strings.Compare(a.Info().Name, b.Info().Name)
})
if config.GlobalConfig.Rendering.CountryList.Prioritize != "" {
if prioritize != "" {
for i, c := range countryList {
if c.Info().Alpha2 == config.GlobalConfig.Rendering.CountryList.Prioritize {
if c.Info().Alpha2 == prioritize {
newList := make([]countries.CountryCode, len(countryList))
newList[0] = c
copy(newList[1:], countryList[:i])
@@ -49,8 +48,3 @@ func AmCountryList() []countries.CountryCode {
}
return cachedCountryList
}
// init preloads the country list.
func init() {
go AmCountryList()
}