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