|
|
|
@@ -279,11 +279,11 @@ func postDeal(userMetricsList []*UserMetrics) []*UserMetrics { |
|
|
|
return duplicateRemovalUserMetricsList |
|
|
|
} |
|
|
|
|
|
|
|
func QueryMetricsForAll() []*UserMetrics { |
|
|
|
func QueryMetricsForAll(start int64, end int64) []*UserMetrics { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
userMetricsList := make([]*UserMetrics, 0) |
|
|
|
if err := statictisSess.Table(new(UserMetrics)).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 { |
|
|
|
return nil |
|
|
|
} |
|
|
|
@@ -291,11 +291,9 @@ func QueryMetricsForAll() []*UserMetrics { |
|
|
|
return makeResultForMonth(duplicateRemovalUserMetricsList, len(duplicateRemovalUserMetricsList)) |
|
|
|
} |
|
|
|
|
|
|
|
func QueryMetricsForYear() []*UserMetrics { |
|
|
|
currentTimeNow := time.Now() |
|
|
|
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()) |
|
|
|
allUserInfo, count := QueryMetrics(currentYearStartTime.Unix(), currentYearEndTime.Unix()) |
|
|
|
func QueryMetricsForYear(start int64, end int64) []*UserMetrics { |
|
|
|
|
|
|
|
allUserInfo, count := QueryMetrics(start, end) |
|
|
|
|
|
|
|
return makeResultForMonth(allUserInfo, count) |
|
|
|
} |
|
|
|
@@ -792,7 +790,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
|
|
|
|
cond := "type != 1 and is_active=true" |
|
|
|
cond := "type != 1" |
|
|
|
count, err := sess.Where(cond).Count(new(User)) |
|
|
|
if err != nil { |
|
|
|
log.Info("query user error. return.") |
|
|
|
@@ -814,8 +812,6 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
|
log.Info("i=" + fmt.Sprint(i) + " userName=" + userRecord.Name) |
|
|
|
dateRecord.CountDate = CountDate.Unix() |
|
|
|
|
|
|
|
statictisSess.Delete(&dateRecord) |
|
|
|
|
|
|
|
dateRecord.Email = userRecord.Email |
|
|
|
dateRecord.RegistDate = userRecord.CreatedUnix |
|
|
|
dateRecord.Name = userRecord.Name |
|
|
|
@@ -873,6 +869,10 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
|
if getUserActivate(dateRecord) > 0 { |
|
|
|
addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID) |
|
|
|
} |
|
|
|
if userRecord.IsActive { |
|
|
|
continue |
|
|
|
} |
|
|
|
statictisSess.Delete(&dateRecord) |
|
|
|
_, err = statictisSess.Insert(&dateRecord) |
|
|
|
if err != nil { |
|
|
|
log.Info("insert daterecord failed." + err.Error()) |
|
|
|
|