mirror of https://gitee.com/answerdev/answer.git
fix startTime
This commit is contained in:
parent
a29eca4a4d
commit
607573d386
|
@ -3,10 +3,12 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/answerdev/answer/internal/base/conf"
|
"github.com/answerdev/answer/internal/base/conf"
|
||||||
"github.com/answerdev/answer/internal/base/constant"
|
"github.com/answerdev/answer/internal/base/constant"
|
||||||
"github.com/answerdev/answer/internal/cli"
|
"github.com/answerdev/answer/internal/cli"
|
||||||
|
"github.com/answerdev/answer/internal/schema"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/segmentfault/pacman"
|
"github.com/segmentfault/pacman"
|
||||||
"github.com/segmentfault/pacman/contrib/conf/viper"
|
"github.com/segmentfault/pacman/contrib/conf/viper"
|
||||||
|
@ -51,6 +53,7 @@ func runApp() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
constant.Version = Version
|
constant.Version = Version
|
||||||
|
schema.AppStartTime = time.Now()
|
||||||
|
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
if err := app.Run(); err != nil {
|
if err := app.Run(); err != nil {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
var AppStartTime time.Time
|
||||||
|
|
||||||
type DashboardInfo struct {
|
type DashboardInfo struct {
|
||||||
QuestionCount int64 `json:"question_count"`
|
QuestionCount int64 `json:"question_count"`
|
||||||
AnswerCount int64 `json:"answer_count"`
|
AnswerCount int64 `json:"answer_count"`
|
||||||
|
|
|
@ -3,8 +3,10 @@ package dashboard
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/answerdev/answer/internal/base/constant"
|
"github.com/answerdev/answer/internal/base/constant"
|
||||||
"github.com/answerdev/answer/internal/base/reason"
|
"github.com/answerdev/answer/internal/base/reason"
|
||||||
|
@ -124,7 +126,8 @@ func (ds *DashboardService) Statistical(ctx context.Context) (*schema.DashboardI
|
||||||
}
|
}
|
||||||
dashboardInfo.HTTPS = true
|
dashboardInfo.HTTPS = true
|
||||||
dashboardInfo.OccupyingStorageSpace = "1MB"
|
dashboardInfo.OccupyingStorageSpace = "1MB"
|
||||||
dashboardInfo.AppStartTime = "102"
|
startTime := time.Now().Unix() - schema.AppStartTime.Unix()
|
||||||
|
dashboardInfo.AppStartTime = fmt.Sprintf("%d", startTime)
|
||||||
dashboardInfo.TimeZone = siteInfoInterface.TimeZone
|
dashboardInfo.TimeZone = siteInfoInterface.TimeZone
|
||||||
dashboardInfo.VersionInfo.Version = constant.Version
|
dashboardInfo.VersionInfo.Version = constant.Version
|
||||||
dashboardInfo.VersionInfo.RemoteVersion = ds.RemoteVersion(ctx)
|
dashboardInfo.VersionInfo.RemoteVersion = ds.RemoteVersion(ctx)
|
||||||
|
|
Loading…
Reference in New Issue