Add the visit time feature.

This commit is contained in:
lishuang 2020-07-11 22:29:56 +08:00
parent da0e68f95c
commit 0d43439200
4 changed files with 65 additions and 53 deletions

View File

@ -54,11 +54,16 @@ func (this *DashboardService) Bootstrap() {
go core.RunWithRecovery(this.Etl)
}
// handle the dashboard data.
func (this *DashboardService) Etl() {
this.etlOneDay(util.Yesterday())
this.etlOneDay(time.Now())
}
startTime := util.FirstSecondOfDay(util.Yesterday())
endTime := util.LastSecondOfDay(util.Yesterday())
// handle the dashboard data.
func (this *DashboardService) etlOneDay(thenTime time.Time) {
startTime := util.FirstSecondOfDay(thenTime)
endTime := util.LastSecondOfDay(thenTime)
dt := util.ConvertTimeToDateString(startTime)
now := time.Now()
longTimeAgo := time.Now()

View File

@ -348,7 +348,7 @@ func (this *MatterDao) Save(matter *Matter) *Matter {
//download time add 1
func (this *MatterDao) TimesIncrement(matterUuid string) {
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matterUuid).Update("times", gorm.Expr("times + 1"))
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matterUuid).Update(map[string]interface{}{"times": gorm.Expr("times + 1"), "visit_time": time.Now()})
this.PanicError(db.Error)
}

View File

@ -10,6 +10,7 @@ import (
"net/http"
"regexp"
"strings"
"time"
)
const (
@ -43,6 +44,7 @@ type Matter struct {
Parent *Matter `json:"parent" gorm:"-"`
Children []*Matter `json:"-" gorm:"-"`
Prop string `json:"prop" gorm:"type:varchar(1024) not null;default:'{}'"`
VisitTime time.Time `json:"visitTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
}
// set File's table name to be `profiles`
@ -69,6 +71,7 @@ func NewRootMatter(user *User) *Matter {
matter.Path = ""
matter.CreateTime = user.CreateTime
matter.UpdateTime = user.UpdateTime
matter.VisitTime = user.UpdateTime
return matter
}

View File

@ -361,6 +361,7 @@ func (this *MatterService) createNonDirMatter(dirMatter *Matter, filename string
Privacy: privacy,
Path: fileRelativePath,
Prop: EMPTY_JSON_MAP,
VisitTime: time.Now(),
}
matter = this.matterDao.Create(matter)
@ -526,6 +527,7 @@ func (this *MatterService) createDirectory(request *http.Request, dirMatter *Mat
Dir: true,
Name: name,
Path: relativePath,
VisitTime: time.Now(),
}
matter = this.matterDao.Create(matter)
@ -711,6 +713,7 @@ func (this *MatterService) copy(request *http.Request, srcMatter *Matter, destDi
Privacy: srcMatter.Privacy,
Path: destDirMatter.Path + "/" + name,
Prop: EMPTY_JSON_MAP,
VisitTime: time.Now(),
}
newMatter = this.matterDao.Create(newMatter)
@ -743,6 +746,7 @@ func (this *MatterService) copy(request *http.Request, srcMatter *Matter, destDi
Privacy: srcMatter.Privacy,
Path: destDirMatter.Path + "/" + name,
Prop: EMPTY_JSON_MAP,
VisitTime: time.Now(),
}
newMatter = this.matterDao.Create(newMatter)