added pool db processing
This commit is contained in:
parent
566503956d
commit
e8978413a5
@ -101,6 +101,15 @@ const (
|
||||
DATA_TRANSACTIONS = 1024 + iota
|
||||
)
|
||||
|
||||
const (
|
||||
// List of voucher symbols in the top pools context.
|
||||
DATA_POOL_NAMES = 2048 + iota
|
||||
// List of symbols in the top pools context.
|
||||
DATA_POOL_SYMBOLS
|
||||
// List of contact addresses in the top pools context
|
||||
DATA_POOL_ADDRESSES
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla().WithDomain("urdt-common")
|
||||
)
|
||||
|
33
store/pools.go
Normal file
33
store/pools.go
Normal file
@ -0,0 +1,33 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
)
|
||||
|
||||
// PoolsMetadata helps organize data fields
|
||||
type PoolsMetadata struct {
|
||||
PoolNames string
|
||||
PoolSymbols string
|
||||
PoolContractAdrresses string
|
||||
}
|
||||
|
||||
// ProcessPools converts pools into formatted strings
|
||||
func ProcessPools(pools []dataserviceapi.PoolDetails) PoolsMetadata {
|
||||
var data PoolsMetadata
|
||||
var poolNames, poolSymbols, poolContractAdrresses []string
|
||||
|
||||
for i, p := range pools {
|
||||
poolNames = append(poolNames, fmt.Sprintf("%d:%s", i+1, p.PoolName))
|
||||
poolSymbols = append(poolSymbols, fmt.Sprintf("%d:%s", i+1, p.PoolSymbol))
|
||||
poolContractAdrresses = append(poolContractAdrresses, fmt.Sprintf("%d:%s", i+1, p.PoolContractAdrress))
|
||||
}
|
||||
|
||||
data.PoolNames = strings.Join(poolNames, "\n")
|
||||
data.PoolSymbols = strings.Join(poolSymbols, "\n")
|
||||
data.PoolContractAdrresses = strings.Join(poolContractAdrresses, "\n")
|
||||
|
||||
return data
|
||||
}
|
Loading…
Reference in New Issue
Block a user