1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Added total time to pages Issue #22

This commit is contained in:
Zack Scholl
2016-02-11 09:26:02 -05:00
parent 1490929655
commit e6e5d701e6
11 changed files with 31 additions and 25 deletions

10
db.go
View File

@@ -77,13 +77,14 @@ func hasPassword(title string) (bool, error) {
return hasPassword, nil
}
func getCurrentText(title string, version int) (string, []versionsInfo, bool) {
func getCurrentText(title string, version int) (string, []versionsInfo, bool, time.Duration) {
title = strings.ToLower(title)
var vi []versionsInfo
totalTime := time.Now().Sub(time.Now())
isCurrent := true
currentText := ""
if !open {
return currentText, vi, isCurrent
return currentText, vi, isCurrent, totalTime
}
err := db.View(func(tx *bolt.Tx) error {
var err error
@@ -107,13 +108,14 @@ func getCurrentText(title string, version int) (string, []versionsInfo, bool) {
currentText = rebuildTextsToDiffN(p, version)
isCurrent = false
}
vi = getImportantVersions(p)
vi, totalTime = getImportantVersions(p)
log.Println(totalTime)
return nil
})
if err != nil {
fmt.Printf("Could not get WikiData: %s", err)
}
return currentText, vi, isCurrent
return currentText, vi, isCurrent, totalTime
}
func (p *WikiData) load(title string) error {