show insights explorer count on data management page
This commit is contained in:
@@ -101,6 +101,13 @@ func (a *DataManagementsApi) DataStatisticsHandler(c *core.WebContext) (any, *er
|
||||
return nil, errs.ErrOperationFailed
|
||||
}
|
||||
|
||||
totalInsightsExplorerCount, err := a.insightsExploreres.GetTotalInsightsExplorersCountByUid(c, uid)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf(c, "[data_managements.DataStatisticsHandler] failed to get total insights explorer count for user \"uid:%d\", because %s", uid, err.Error())
|
||||
return nil, errs.ErrOperationFailed
|
||||
}
|
||||
|
||||
totalTransactionTemplateCount, err := a.templates.GetTotalNormalTemplateCountByUid(c, uid)
|
||||
|
||||
if err != nil {
|
||||
@@ -121,6 +128,7 @@ func (a *DataManagementsApi) DataStatisticsHandler(c *core.WebContext) (any, *er
|
||||
TotalTransactionTagCount: totalTransactionTagCount,
|
||||
TotalTransactionCount: totalTransactionCount,
|
||||
TotalTransactionPictureCount: totalTransactionPictureCount,
|
||||
TotalInsightsExplorerCount: totalInsightsExplorerCount,
|
||||
TotalTransactionTemplateCount: totalTransactionTemplateCount,
|
||||
TotalScheduledTransactionCount: totalScheduledTransactionCount,
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ type DataStatisticsResponse struct {
|
||||
TotalTransactionTagCount int64 `json:"totalTransactionTagCount,string"`
|
||||
TotalTransactionCount int64 `json:"totalTransactionCount,string"`
|
||||
TotalTransactionPictureCount int64 `json:"totalTransactionPictureCount,string"`
|
||||
TotalInsightsExplorerCount int64 `json:"totalInsightsExplorerCount,string"`
|
||||
TotalTransactionTemplateCount int64 `json:"totalTransactionTemplateCount,string"`
|
||||
TotalScheduledTransactionCount int64 `json:"totalScheduledTransactionCount,string"`
|
||||
}
|
||||
|
||||
@@ -30,6 +30,17 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// GetTotalInsightsExplorersCountByUid returns total insights explorers count of user
|
||||
func (s *InsightsExplorerService) GetTotalInsightsExplorersCountByUid(c core.Context, uid int64) (int64, error) {
|
||||
if uid <= 0 {
|
||||
return 0, errs.ErrUserIdInvalid
|
||||
}
|
||||
|
||||
count, err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).Count(&models.InsightsExplorer{})
|
||||
|
||||
return count, err
|
||||
}
|
||||
|
||||
// GetAllInsightsExplorerNamesByUid returns all insights explorer models of user without data
|
||||
func (s *InsightsExplorerService) GetAllInsightsExplorerNamesByUid(c core.Context, uid int64) ([]*models.InsightsExplorer, error) {
|
||||
if uid <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user