Add the visit time feature.
This commit is contained in:
parent
da0e68f95c
commit
0d43439200
@ -54,11 +54,16 @@ func (this *DashboardService) Bootstrap() {
|
|||||||
go core.RunWithRecovery(this.Etl)
|
go core.RunWithRecovery(this.Etl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle the dashboard data.
|
|
||||||
func (this *DashboardService) Etl() {
|
func (this *DashboardService) Etl() {
|
||||||
|
this.etlOneDay(util.Yesterday())
|
||||||
|
this.etlOneDay(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
startTime := util.FirstSecondOfDay(util.Yesterday())
|
// handle the dashboard data.
|
||||||
endTime := util.LastSecondOfDay(util.Yesterday())
|
func (this *DashboardService) etlOneDay(thenTime time.Time) {
|
||||||
|
|
||||||
|
startTime := util.FirstSecondOfDay(thenTime)
|
||||||
|
endTime := util.LastSecondOfDay(thenTime)
|
||||||
dt := util.ConvertTimeToDateString(startTime)
|
dt := util.ConvertTimeToDateString(startTime)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
longTimeAgo := time.Now()
|
longTimeAgo := time.Now()
|
||||||
|
@ -348,7 +348,7 @@ func (this *MatterDao) Save(matter *Matter) *Matter {
|
|||||||
|
|
||||||
//download time add 1
|
//download time add 1
|
||||||
func (this *MatterDao) TimesIncrement(matterUuid string) {
|
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)
|
this.PanicError(db.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -30,19 +31,20 @@ const (
|
|||||||
*/
|
*/
|
||||||
type Matter struct {
|
type Matter struct {
|
||||||
Base
|
Base
|
||||||
Puuid string `json:"puuid" gorm:"type:char(36);index:idx_puuid"`
|
Puuid string `json:"puuid" gorm:"type:char(36);index:idx_puuid"`
|
||||||
UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_uu"`
|
UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_uu"`
|
||||||
Username string `json:"username" gorm:"type:varchar(45) not null"`
|
Username string `json:"username" gorm:"type:varchar(45) not null"`
|
||||||
Dir bool `json:"dir" gorm:"type:tinyint(1) not null;default:0"`
|
Dir bool `json:"dir" gorm:"type:tinyint(1) not null;default:0"`
|
||||||
Name string `json:"name" gorm:"type:varchar(255) not null"`
|
Name string `json:"name" gorm:"type:varchar(255) not null"`
|
||||||
Md5 string `json:"md5" gorm:"type:varchar(45)"`
|
Md5 string `json:"md5" gorm:"type:varchar(45)"`
|
||||||
Size int64 `json:"size" gorm:"type:bigint(20) not null;default:0"`
|
Size int64 `json:"size" gorm:"type:bigint(20) not null;default:0"`
|
||||||
Privacy bool `json:"privacy" gorm:"type:tinyint(1) not null;default:0"`
|
Privacy bool `json:"privacy" gorm:"type:tinyint(1) not null;default:0"`
|
||||||
Path string `json:"path" gorm:"type:varchar(1024);index:idx_p"`
|
Path string `json:"path" gorm:"type:varchar(1024);index:idx_p"`
|
||||||
Times int64 `json:"times" gorm:"type:bigint(20) not null;default:0"`
|
Times int64 `json:"times" gorm:"type:bigint(20) not null;default:0"`
|
||||||
Parent *Matter `json:"parent" gorm:"-"`
|
Parent *Matter `json:"parent" gorm:"-"`
|
||||||
Children []*Matter `json:"-" gorm:"-"`
|
Children []*Matter `json:"-" gorm:"-"`
|
||||||
Prop string `json:"prop" gorm:"type:varchar(1024) not null;default:'{}'"`
|
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`
|
// set File's table name to be `profiles`
|
||||||
@ -69,6 +71,7 @@ func NewRootMatter(user *User) *Matter {
|
|||||||
matter.Path = ""
|
matter.Path = ""
|
||||||
matter.CreateTime = user.CreateTime
|
matter.CreateTime = user.CreateTime
|
||||||
matter.UpdateTime = user.UpdateTime
|
matter.UpdateTime = user.UpdateTime
|
||||||
|
matter.VisitTime = user.UpdateTime
|
||||||
|
|
||||||
return matter
|
return matter
|
||||||
}
|
}
|
||||||
|
@ -351,16 +351,17 @@ func (this *MatterService) createNonDirMatter(dirMatter *Matter, filename string
|
|||||||
|
|
||||||
//write to db.
|
//write to db.
|
||||||
matter := &Matter{
|
matter := &Matter{
|
||||||
Puuid: dirMatter.Uuid,
|
Puuid: dirMatter.Uuid,
|
||||||
UserUuid: user.Uuid,
|
UserUuid: user.Uuid,
|
||||||
Username: user.Username,
|
Username: user.Username,
|
||||||
Dir: false,
|
Dir: false,
|
||||||
Name: filename,
|
Name: filename,
|
||||||
Md5: "",
|
Md5: "",
|
||||||
Size: fileSize,
|
Size: fileSize,
|
||||||
Privacy: privacy,
|
Privacy: privacy,
|
||||||
Path: fileRelativePath,
|
Path: fileRelativePath,
|
||||||
Prop: EMPTY_JSON_MAP,
|
Prop: EMPTY_JSON_MAP,
|
||||||
|
VisitTime: time.Now(),
|
||||||
}
|
}
|
||||||
matter = this.matterDao.Create(matter)
|
matter = this.matterDao.Create(matter)
|
||||||
|
|
||||||
@ -520,12 +521,13 @@ func (this *MatterService) createDirectory(request *http.Request, dirMatter *Mat
|
|||||||
|
|
||||||
//create in db
|
//create in db
|
||||||
matter = &Matter{
|
matter = &Matter{
|
||||||
Puuid: dirMatter.Uuid,
|
Puuid: dirMatter.Uuid,
|
||||||
UserUuid: user.Uuid,
|
UserUuid: user.Uuid,
|
||||||
Username: user.Username,
|
Username: user.Username,
|
||||||
Dir: true,
|
Dir: true,
|
||||||
Name: name,
|
Name: name,
|
||||||
Path: relativePath,
|
Path: relativePath,
|
||||||
|
VisitTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
matter = this.matterDao.Create(matter)
|
matter = this.matterDao.Create(matter)
|
||||||
@ -701,16 +703,17 @@ func (this *MatterService) copy(request *http.Request, srcMatter *Matter, destDi
|
|||||||
if srcMatter.Dir {
|
if srcMatter.Dir {
|
||||||
|
|
||||||
newMatter := &Matter{
|
newMatter := &Matter{
|
||||||
Puuid: destDirMatter.Uuid,
|
Puuid: destDirMatter.Uuid,
|
||||||
UserUuid: srcMatter.UserUuid,
|
UserUuid: srcMatter.UserUuid,
|
||||||
Username: srcMatter.Username,
|
Username: srcMatter.Username,
|
||||||
Dir: srcMatter.Dir,
|
Dir: srcMatter.Dir,
|
||||||
Name: name,
|
Name: name,
|
||||||
Md5: "",
|
Md5: "",
|
||||||
Size: srcMatter.Size,
|
Size: srcMatter.Size,
|
||||||
Privacy: srcMatter.Privacy,
|
Privacy: srcMatter.Privacy,
|
||||||
Path: destDirMatter.Path + "/" + name,
|
Path: destDirMatter.Path + "/" + name,
|
||||||
Prop: EMPTY_JSON_MAP,
|
Prop: EMPTY_JSON_MAP,
|
||||||
|
VisitTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
newMatter = this.matterDao.Create(newMatter)
|
newMatter = this.matterDao.Create(newMatter)
|
||||||
@ -733,16 +736,17 @@ func (this *MatterService) copy(request *http.Request, srcMatter *Matter, destDi
|
|||||||
util.CopyFile(srcAbsolutePath, destAbsolutePath)
|
util.CopyFile(srcAbsolutePath, destAbsolutePath)
|
||||||
|
|
||||||
newMatter := &Matter{
|
newMatter := &Matter{
|
||||||
Puuid: destDirMatter.Uuid,
|
Puuid: destDirMatter.Uuid,
|
||||||
UserUuid: srcMatter.UserUuid,
|
UserUuid: srcMatter.UserUuid,
|
||||||
Username: srcMatter.Username,
|
Username: srcMatter.Username,
|
||||||
Dir: srcMatter.Dir,
|
Dir: srcMatter.Dir,
|
||||||
Name: name,
|
Name: name,
|
||||||
Md5: "",
|
Md5: "",
|
||||||
Size: srcMatter.Size,
|
Size: srcMatter.Size,
|
||||||
Privacy: srcMatter.Privacy,
|
Privacy: srcMatter.Privacy,
|
||||||
Path: destDirMatter.Path + "/" + name,
|
Path: destDirMatter.Path + "/" + name,
|
||||||
Prop: EMPTY_JSON_MAP,
|
Prop: EMPTY_JSON_MAP,
|
||||||
|
VisitTime: time.Now(),
|
||||||
}
|
}
|
||||||
newMatter = this.matterDao.Create(newMatter)
|
newMatter = this.matterDao.Create(newMatter)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user