|
@@ -232,7 +232,7 @@ func getLastCountDate() int64 { |
|
|
return pageStartTime.Unix() |
|
|
return pageStartTime.Unix() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]UserMetrics, int64) { |
|
|
|
|
|
|
|
|
func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]*UserMetrics, int64) { |
|
|
|
|
|
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
statictisSess := xStatistic.NewSession() |
|
|
defer statictisSess.Close() |
|
|
defer statictisSess.Close() |
|
@@ -242,7 +242,7 @@ func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]UserMet |
|
|
log.Info("query error." + err.Error()) |
|
|
log.Info("query error." + err.Error()) |
|
|
return nil, 0 |
|
|
return nil, 0 |
|
|
} |
|
|
} |
|
|
userMetricsList := make([]UserMetrics, 0) |
|
|
|
|
|
|
|
|
userMetricsList := make([]*UserMetrics, 0) |
|
|
//.Limit(pageSize, page*pageSize) |
|
|
//.Limit(pageSize, page*pageSize) |
|
|
if err := statictisSess.Table(new(UserMetrics)).Where(cond).OrderBy("count_date desc"). |
|
|
if err := statictisSess.Table(new(UserMetrics)).Where(cond).OrderBy("count_date desc"). |
|
|
Find(&userMetricsList); err != nil { |
|
|
Find(&userMetricsList); err != nil { |
|
@@ -252,10 +252,10 @@ func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]UserMet |
|
|
return userMetricsList, allCount |
|
|
return userMetricsList, allCount |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func QueryMetrics(start int64, end int64) ([]UserMetrics, int) { |
|
|
|
|
|
|
|
|
func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { |
|
|
statictisSess := xStatistic.NewSession() |
|
|
statictisSess := xStatistic.NewSession() |
|
|
defer statictisSess.Close() |
|
|
defer statictisSess.Close() |
|
|
userMetricsList := make([]UserMetrics, 0) |
|
|
|
|
|
|
|
|
userMetricsList := make([]*UserMetrics, 0) |
|
|
if err := statictisSess.Table(new(UserMetrics)).Where("count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end)).OrderBy("count_date desc"). |
|
|
if err := statictisSess.Table(new(UserMetrics)).Where("count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end)).OrderBy("count_date desc"). |
|
|
Find(&userMetricsList); err != nil { |
|
|
Find(&userMetricsList); err != nil { |
|
|
return nil, 0 |
|
|
return nil, 0 |
|
@@ -264,7 +264,7 @@ func QueryMetrics(start int64, end int64) ([]UserMetrics, int) { |
|
|
return userMetricsList, len(userMetricsList) |
|
|
return userMetricsList, len(userMetricsList) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func postDeal(userMetricsList []UserMetrics) { |
|
|
|
|
|
|
|
|
func postDeal(userMetricsList []*UserMetrics) { |
|
|
for _, userMetrics := range userMetricsList { |
|
|
for _, userMetrics := range userMetricsList { |
|
|
dateTime := time.Unix(userMetrics.CountDate, 0) |
|
|
dateTime := time.Unix(userMetrics.CountDate, 0) |
|
|
userMetrics.DisplayDate = dateTime.Format("2006-01-02") |
|
|
userMetrics.DisplayDate = dateTime.Format("2006-01-02") |
|
@@ -273,10 +273,10 @@ func postDeal(userMetricsList []UserMetrics) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func QueryMetricsForAll() []UserMetrics { |
|
|
|
|
|
|
|
|
func QueryMetricsForAll() []*UserMetrics { |
|
|
statictisSess := xStatistic.NewSession() |
|
|
statictisSess := xStatistic.NewSession() |
|
|
defer statictisSess.Close() |
|
|
defer statictisSess.Close() |
|
|
userMetricsList := make([]UserMetrics, 0) |
|
|
|
|
|
|
|
|
userMetricsList := make([]*UserMetrics, 0) |
|
|
if err := statictisSess.Table(new(UserMetrics)).OrderBy("count_date desc"). |
|
|
if err := statictisSess.Table(new(UserMetrics)).OrderBy("count_date desc"). |
|
|
Find(&userMetricsList); err != nil { |
|
|
Find(&userMetricsList); err != nil { |
|
|
return nil |
|
|
return nil |
|
@@ -284,7 +284,7 @@ func QueryMetricsForAll() []UserMetrics { |
|
|
return makeResultForMonth(userMetricsList, len(userMetricsList)) |
|
|
return makeResultForMonth(userMetricsList, len(userMetricsList)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func QueryMetricsForYear() []UserMetrics { |
|
|
|
|
|
|
|
|
func QueryMetricsForYear() []*UserMetrics { |
|
|
currentTimeNow := time.Now() |
|
|
currentTimeNow := time.Now() |
|
|
currentYearEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) |
|
|
currentYearEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) |
|
|
currentYearStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) |
|
|
currentYearStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) |
|
@@ -293,14 +293,14 @@ func QueryMetricsForYear() []UserMetrics { |
|
|
return makeResultForMonth(allUserInfo, count) |
|
|
return makeResultForMonth(allUserInfo, count) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func makeResultForMonth(allUserInfo []UserMetrics, count int) []UserMetrics { |
|
|
|
|
|
monthMap := make(map[string]UserMetrics) |
|
|
|
|
|
|
|
|
func makeResultForMonth(allUserInfo []*UserMetrics, count int) []*UserMetrics { |
|
|
|
|
|
monthMap := make(map[string]*UserMetrics) |
|
|
if count > 0 { |
|
|
if count > 0 { |
|
|
for _, userMetrics := range allUserInfo { |
|
|
for _, userMetrics := range allUserInfo { |
|
|
dateTime := time.Unix(userMetrics.CountDate, 0) |
|
|
dateTime := time.Unix(userMetrics.CountDate, 0) |
|
|
month := fmt.Sprint(dateTime.Year()) + "-" + fmt.Sprint(int(dateTime.Month())) |
|
|
month := fmt.Sprint(dateTime.Year()) + "-" + fmt.Sprint(int(dateTime.Month())) |
|
|
if _, ok := monthMap[month]; !ok { |
|
|
if _, ok := monthMap[month]; !ok { |
|
|
var monthUserMetrics UserMetrics |
|
|
|
|
|
|
|
|
var monthUserMetrics *UserMetrics |
|
|
monthUserMetrics.DisplayDate = month |
|
|
monthUserMetrics.DisplayDate = month |
|
|
monthUserMetrics.ActivateRegistUser = userMetrics.ActivateRegistUser |
|
|
monthUserMetrics.ActivateRegistUser = userMetrics.ActivateRegistUser |
|
|
monthUserMetrics.NotActivateRegistUser = userMetrics.NotActivateRegistUser |
|
|
monthUserMetrics.NotActivateRegistUser = userMetrics.NotActivateRegistUser |
|
@@ -322,7 +322,7 @@ func makeResultForMonth(allUserInfo []UserMetrics, count int) []UserMetrics { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
result := make([]UserMetrics, 0) |
|
|
|
|
|
|
|
|
result := make([]*UserMetrics, 0) |
|
|
for _, value := range monthMap { |
|
|
for _, value := range monthMap { |
|
|
result = append(result, value) |
|
|
result = append(result, value) |
|
|
} |
|
|
} |
|
@@ -892,7 +892,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
useMetrics.TotalActivateRegistUser = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) |
|
|
useMetrics.TotalActivateRegistUser = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) |
|
|
useMetrics.TotalHasActivityUser = getMapKeyStringValue("TotalHasActivityUser", userMetrics) |
|
|
useMetrics.TotalHasActivityUser = getMapKeyStringValue("TotalHasActivityUser", userMetrics) |
|
|
|
|
|
|
|
|
count, err = sess.Count(new(User)) |
|
|
|
|
|
|
|
|
count, err = sess.Where("type=0").Count(new(User)) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("query user error. return.") |
|
|
log.Info("query user error. return.") |
|
|
} |
|
|
} |
|
|