add asset trends in statistics & analysis (#314)
This commit is contained in:
@@ -275,6 +275,12 @@ type TransactionStatisticTrendsRequest struct {
|
||||
UseTransactionTimezone bool `form:"use_transaction_timezone"`
|
||||
}
|
||||
|
||||
// TransactionStatisticAssetTrendsRequest represents all parameters of transaction statistic asset trends request
|
||||
type TransactionStatisticAssetTrendsRequest struct {
|
||||
StartTime int64 `form:"start_time"`
|
||||
EndTime int64 `form:"end_time"`
|
||||
}
|
||||
|
||||
// TransactionAmountsRequest represents all parameters of transaction amounts request
|
||||
type TransactionAmountsRequest struct {
|
||||
Query string `form:"query"`
|
||||
@@ -403,6 +409,21 @@ type TransactionStatisticTrendsResponseItem struct {
|
||||
Items []*TransactionStatisticResponseItem `json:"items"`
|
||||
}
|
||||
|
||||
// TransactionStatisticAssetTrendsResponseItem represents the data within each statistic interval
|
||||
type TransactionStatisticAssetTrendsResponseItem struct {
|
||||
Year int32 `json:"year"`
|
||||
Month int32 `json:"month"`
|
||||
Day int32 `json:"day"`
|
||||
Items []*TransactionStatisticAssetTrendsResponseDataItem `json:"items"`
|
||||
}
|
||||
|
||||
// TransactionStatisticAssetTrendsResponseDataItem represents an asset trends data item
|
||||
type TransactionStatisticAssetTrendsResponseDataItem struct {
|
||||
AccountId int64 `json:"accountId,string"`
|
||||
AccountOpeningBalance int64 `json:"accountOpeningBalance"`
|
||||
AccountClosingBalance int64 `json:"accountClosingBalance"`
|
||||
}
|
||||
|
||||
// TransactionAmountsResponseItem represents an item of transaction amounts
|
||||
type TransactionAmountsResponseItem struct {
|
||||
StartTime int64 `json:"startTime"`
|
||||
@@ -600,6 +621,32 @@ func (s TransactionStatisticTrendsResponseItemSlice) Less(i, j int) bool {
|
||||
return s[i].Month < s[j].Month
|
||||
}
|
||||
|
||||
// TransactionStatisticAssetTrendsResponseItemSlice represents the slice data structure of TransactionStatisticAssetTrendsResponseItem
|
||||
type TransactionStatisticAssetTrendsResponseItemSlice []*TransactionStatisticAssetTrendsResponseItem
|
||||
|
||||
// Len returns the count of items
|
||||
func (s TransactionStatisticAssetTrendsResponseItemSlice) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Swap swaps two items
|
||||
func (s TransactionStatisticAssetTrendsResponseItemSlice) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
// Less reports whether the first item is less than the second one
|
||||
func (s TransactionStatisticAssetTrendsResponseItemSlice) Less(i, j int) bool {
|
||||
if s[i].Year != s[j].Year {
|
||||
return s[i].Year < s[j].Year
|
||||
}
|
||||
|
||||
if s[i].Month != s[j].Month {
|
||||
return s[i].Month < s[j].Month
|
||||
}
|
||||
|
||||
return s[i].Day < s[j].Day
|
||||
}
|
||||
|
||||
// TransactionAmountsResponseItemAmountInfoSlice represents the slice data structure of TransactionAmountsResponseItemAmountInfo
|
||||
type TransactionAmountsResponseItemAmountInfoSlice []*TransactionAmountsResponseItemAmountInfo
|
||||
|
||||
|
||||
@@ -164,6 +164,61 @@ func TestTransactionStatisticTrendsResponseItemSliceLess(t *testing.T) {
|
||||
assert.Equal(t, int32(9), transactionTrendsSlice[4].Month)
|
||||
}
|
||||
|
||||
func TestTransactionStatisticAssetTrendsResponseItemSliceLess(t *testing.T) {
|
||||
var transactionTrendsSlice TransactionStatisticAssetTrendsResponseItemSlice
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticAssetTrendsResponseItem{
|
||||
Year: 2024,
|
||||
Month: 9,
|
||||
Day: 1,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticAssetTrendsResponseItem{
|
||||
Year: 2024,
|
||||
Month: 9,
|
||||
Day: 2,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticAssetTrendsResponseItem{
|
||||
Year: 2024,
|
||||
Month: 10,
|
||||
Day: 1,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticAssetTrendsResponseItem{
|
||||
Year: 2022,
|
||||
Month: 10,
|
||||
Day: 1,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticAssetTrendsResponseItem{
|
||||
Year: 2023,
|
||||
Month: 1,
|
||||
Day: 1,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticAssetTrendsResponseItem{
|
||||
Year: 2024,
|
||||
Month: 2,
|
||||
Day: 2,
|
||||
})
|
||||
|
||||
sort.Sort(transactionTrendsSlice)
|
||||
|
||||
assert.Equal(t, int32(2022), transactionTrendsSlice[0].Year)
|
||||
assert.Equal(t, int32(10), transactionTrendsSlice[0].Month)
|
||||
assert.Equal(t, int32(1), transactionTrendsSlice[0].Day)
|
||||
assert.Equal(t, int32(2023), transactionTrendsSlice[1].Year)
|
||||
assert.Equal(t, int32(1), transactionTrendsSlice[1].Month)
|
||||
assert.Equal(t, int32(1), transactionTrendsSlice[1].Day)
|
||||
assert.Equal(t, int32(2024), transactionTrendsSlice[2].Year)
|
||||
assert.Equal(t, int32(2), transactionTrendsSlice[2].Month)
|
||||
assert.Equal(t, int32(2), transactionTrendsSlice[2].Day)
|
||||
assert.Equal(t, int32(2024), transactionTrendsSlice[3].Year)
|
||||
assert.Equal(t, int32(9), transactionTrendsSlice[3].Month)
|
||||
assert.Equal(t, int32(1), transactionTrendsSlice[3].Day)
|
||||
assert.Equal(t, int32(2024), transactionTrendsSlice[4].Year)
|
||||
assert.Equal(t, int32(9), transactionTrendsSlice[4].Month)
|
||||
assert.Equal(t, int32(2), transactionTrendsSlice[4].Day)
|
||||
assert.Equal(t, int32(2024), transactionTrendsSlice[5].Year)
|
||||
assert.Equal(t, int32(10), transactionTrendsSlice[5].Month)
|
||||
assert.Equal(t, int32(1), transactionTrendsSlice[5].Day)
|
||||
}
|
||||
|
||||
func TestTransactionAmountsResponseItemAmountInfoSliceLess(t *testing.T) {
|
||||
var amountInfoSlice TransactionAmountsResponseItemAmountInfoSlice
|
||||
amountInfoSlice = append(amountInfoSlice, &TransactionAmountsResponseItemAmountInfo{
|
||||
|
||||
@@ -43,6 +43,8 @@ var ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES = map[string]UserApplicationClo
|
||||
"statistics.defaultCategoricalChartDataRangeType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultTrendChartType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultTrendChartDataRangeType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultAssetTrendsChartType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultAssetTrendsChartDataRangeType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
}
|
||||
|
||||
// UserApplicationCloudSetting represents user application cloud setting stored in database
|
||||
|
||||
Reference in New Issue
Block a user