Changed the initialization of the countries slice

This commit is contained in:
ditatompel 2024-06-08 00:53:28 +07:00
parent 054a4809dd
commit 70372e58ab
No known key found for this signature in database
GPG key ID: 31D3D06D77950979

View file

@ -329,15 +329,17 @@ func (r *MoneroRepo) NetFees() []NetFee {
return netFees
}
// Countries represents list of countries
type Countries struct {
TotalNodes int `json:"total_nodes" db:"total_nodes"`
CC string `json:"cc" db:"country"` // country code
Name string `json:"name" db:"country_name"`
}
// Get list of countries (count by nodes)
func (r *MoneroRepo) Countries() ([]Countries, error) {
countries := []Countries{}
err := r.db.Select(&countries, `
var c []Countries
err := r.db.Select(&c, `
SELECT
COUNT(id) AS total_nodes,
country,
@ -348,5 +350,5 @@ func (r *MoneroRepo) Countries() ([]Countries, error) {
country
ORDER BY
country ASC`)
return countries, err
return c, err
}