adjust x-chain-activity/tops to also support multiple sourceChains and targetChains
This commit is contained in:
parent
92b432a906
commit
4051ad491f
|
@ -215,12 +215,12 @@ type TransactionDto struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChainActivityTopsQuery struct {
|
type ChainActivityTopsQuery struct {
|
||||||
SourceChain *sdk.ChainID `json:"source_chain"`
|
SourceChain []sdk.ChainID `json:"source_chain"`
|
||||||
TargetChain *sdk.ChainID `json:"target_chain"`
|
TargetChain []sdk.ChainID `json:"target_chain"`
|
||||||
AppId string `json:"app_id"`
|
AppId string `json:"app_id"`
|
||||||
From time.Time `json:"from"`
|
From time.Time `json:"from"`
|
||||||
To time.Time `json:"to"`
|
To time.Time `json:"to"`
|
||||||
Timespan Timespan `json:"timespan"`
|
Timespan Timespan `json:"timespan"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Timespan string
|
type Timespan string
|
||||||
|
|
|
@ -1095,13 +1095,23 @@ func (r *Repository) buildChainActivityQueryTops(q ChainActivityTopsQuery) strin
|
||||||
}
|
}
|
||||||
|
|
||||||
filterTargetChain := ""
|
filterTargetChain := ""
|
||||||
if q.TargetChain != nil {
|
if len(q.TargetChain) > 0 {
|
||||||
filterTargetChain = "|> filter(fn: (r) => r.destination_chain == \"" + strconv.Itoa(int(*q.TargetChain)) + "\")"
|
val := fmt.Sprintf("r.destination_chain == \"%d\"", q.TargetChain[0])
|
||||||
|
buff := ""
|
||||||
|
for _, tc := range q.TargetChain[1:] {
|
||||||
|
buff += fmt.Sprintf("or r.destination_chain == \"%d\" ", tc)
|
||||||
|
}
|
||||||
|
filterTargetChain = fmt.Sprintf("|> filter(fn: (r) => %s %s)", val, buff)
|
||||||
}
|
}
|
||||||
|
|
||||||
filterSourceChain := ""
|
filterSourceChain := ""
|
||||||
if q.SourceChain != nil {
|
if len(q.SourceChain) > 0 {
|
||||||
filterSourceChain = "|> filter(fn: (r) => r.emitter_chain == \"" + strconv.Itoa(int(*q.SourceChain)) + "\")"
|
val := fmt.Sprintf("r.emitter_chain == \"%d\"", q.SourceChain[0])
|
||||||
|
buff := ""
|
||||||
|
for _, tc := range q.SourceChain[1:] {
|
||||||
|
buff += fmt.Sprintf("or r.emitter_chain == \"%d\" ", tc)
|
||||||
|
}
|
||||||
|
filterSourceChain = fmt.Sprintf("|> filter(fn: (r) => %s %s)", val, buff)
|
||||||
}
|
}
|
||||||
|
|
||||||
filterAppId := ""
|
filterAppId := ""
|
||||||
|
|
Loading…
Reference in New Issue