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)
|
||||
}
|
||||
|
||||
// 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()
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -30,19 +31,20 @@ const (
|
||||
*/
|
||||
type Matter struct {
|
||||
Base
|
||||
Puuid string `json:"puuid" gorm:"type:char(36);index:idx_puuid"`
|
||||
UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_uu"`
|
||||
Username string `json:"username" gorm:"type:varchar(45) not null"`
|
||||
Dir bool `json:"dir" gorm:"type:tinyint(1) not null;default:0"`
|
||||
Name string `json:"name" gorm:"type:varchar(255) not null"`
|
||||
Md5 string `json:"md5" gorm:"type:varchar(45)"`
|
||||
Size int64 `json:"size" gorm:"type:bigint(20) 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"`
|
||||
Times int64 `json:"times" gorm:"type:bigint(20) not null;default:0"`
|
||||
Parent *Matter `json:"parent" gorm:"-"`
|
||||
Children []*Matter `json:"-" gorm:"-"`
|
||||
Prop string `json:"prop" gorm:"type:varchar(1024) not null;default:'{}'"`
|
||||
Puuid string `json:"puuid" gorm:"type:char(36);index:idx_puuid"`
|
||||
UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_uu"`
|
||||
Username string `json:"username" gorm:"type:varchar(45) not null"`
|
||||
Dir bool `json:"dir" gorm:"type:tinyint(1) not null;default:0"`
|
||||
Name string `json:"name" gorm:"type:varchar(255) not null"`
|
||||
Md5 string `json:"md5" gorm:"type:varchar(45)"`
|
||||
Size int64 `json:"size" gorm:"type:bigint(20) 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"`
|
||||
Times int64 `json:"times" gorm:"type:bigint(20) not null;default:0"`
|
||||
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
|
||||
}
|
||||
|
@ -351,16 +351,17 @@ func (this *MatterService) createNonDirMatter(dirMatter *Matter, filename string
|
||||
|
||||
//write to db.
|
||||
matter := &Matter{
|
||||
Puuid: dirMatter.Uuid,
|
||||
UserUuid: user.Uuid,
|
||||
Username: user.Username,
|
||||
Dir: false,
|
||||
Name: filename,
|
||||
Md5: "",
|
||||
Size: fileSize,
|
||||
Privacy: privacy,
|
||||
Path: fileRelativePath,
|
||||
Prop: EMPTY_JSON_MAP,
|
||||
Puuid: dirMatter.Uuid,
|
||||
UserUuid: user.Uuid,
|
||||
Username: user.Username,
|
||||
Dir: false,
|
||||
Name: filename,
|
||||
Md5: "",
|
||||
Size: fileSize,
|
||||
Privacy: privacy,
|
||||
Path: fileRelativePath,
|
||||
Prop: EMPTY_JSON_MAP,
|
||||
VisitTime: time.Now(),
|
||||
}
|
||||
matter = this.matterDao.Create(matter)
|
||||
|
||||
@ -520,12 +521,13 @@ func (this *MatterService) createDirectory(request *http.Request, dirMatter *Mat
|
||||
|
||||
//create in db
|
||||
matter = &Matter{
|
||||
Puuid: dirMatter.Uuid,
|
||||
UserUuid: user.Uuid,
|
||||
Username: user.Username,
|
||||
Dir: true,
|
||||
Name: name,
|
||||
Path: relativePath,
|
||||
Puuid: dirMatter.Uuid,
|
||||
UserUuid: user.Uuid,
|
||||
Username: user.Username,
|
||||
Dir: true,
|
||||
Name: name,
|
||||
Path: relativePath,
|
||||
VisitTime: time.Now(),
|
||||
}
|
||||
|
||||
matter = this.matterDao.Create(matter)
|
||||
@ -701,16 +703,17 @@ func (this *MatterService) copy(request *http.Request, srcMatter *Matter, destDi
|
||||
if srcMatter.Dir {
|
||||
|
||||
newMatter := &Matter{
|
||||
Puuid: destDirMatter.Uuid,
|
||||
UserUuid: srcMatter.UserUuid,
|
||||
Username: srcMatter.Username,
|
||||
Dir: srcMatter.Dir,
|
||||
Name: name,
|
||||
Md5: "",
|
||||
Size: srcMatter.Size,
|
||||
Privacy: srcMatter.Privacy,
|
||||
Path: destDirMatter.Path + "/" + name,
|
||||
Prop: EMPTY_JSON_MAP,
|
||||
Puuid: destDirMatter.Uuid,
|
||||
UserUuid: srcMatter.UserUuid,
|
||||
Username: srcMatter.Username,
|
||||
Dir: srcMatter.Dir,
|
||||
Name: name,
|
||||
Md5: "",
|
||||
Size: srcMatter.Size,
|
||||
Privacy: srcMatter.Privacy,
|
||||
Path: destDirMatter.Path + "/" + name,
|
||||
Prop: EMPTY_JSON_MAP,
|
||||
VisitTime: time.Now(),
|
||||
}
|
||||
|
||||
newMatter = this.matterDao.Create(newMatter)
|
||||
@ -733,16 +736,17 @@ func (this *MatterService) copy(request *http.Request, srcMatter *Matter, destDi
|
||||
util.CopyFile(srcAbsolutePath, destAbsolutePath)
|
||||
|
||||
newMatter := &Matter{
|
||||
Puuid: destDirMatter.Uuid,
|
||||
UserUuid: srcMatter.UserUuid,
|
||||
Username: srcMatter.Username,
|
||||
Dir: srcMatter.Dir,
|
||||
Name: name,
|
||||
Md5: "",
|
||||
Size: srcMatter.Size,
|
||||
Privacy: srcMatter.Privacy,
|
||||
Path: destDirMatter.Path + "/" + name,
|
||||
Prop: EMPTY_JSON_MAP,
|
||||
Puuid: destDirMatter.Uuid,
|
||||
UserUuid: srcMatter.UserUuid,
|
||||
Username: srcMatter.Username,
|
||||
Dir: srcMatter.Dir,
|
||||
Name: name,
|
||||
Md5: "",
|
||||
Size: srcMatter.Size,
|
||||
Privacy: srcMatter.Privacy,
|
||||
Path: destDirMatter.Path + "/" + name,
|
||||
Prop: EMPTY_JSON_MAP,
|
||||
VisitTime: time.Now(),
|
||||
}
|
||||
newMatter = this.matterDao.Create(newMatter)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user