You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/03/22 03:34:34 UTC

(incubator-answer) branch feat/1.3.0/review updated: feat(dashboard): update dashboard report to review count

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch feat/1.3.0/review
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


The following commit(s) were added to refs/heads/feat/1.3.0/review by this push:
     new ab350d02 feat(dashboard): update dashboard report to review count
ab350d02 is described below

commit ab350d02972679f17436fee389dd8fee77d8a2fa
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Fri Mar 22 11:34:25 2024 +0800

    feat(dashboard): update dashboard report to review count
---
 cmd/wire_gen.go                                 |  2 +-
 internal/service/dashboard/dashboard_service.go | 22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/cmd/wire_gen.go b/cmd/wire_gen.go
index dacce90c..a2027d28 100644
--- a/cmd/wire_gen.go
+++ b/cmd/wire_gen.go
@@ -213,7 +213,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,
 	notificationCommon := notificationcommon.NewNotificationCommon(dataData, notificationRepo, userCommon, activityRepo, followRepo, objService, notificationQueueService, userExternalLoginRepo, siteInfoCommonService)
 	notificationService := notification.NewNotificationService(dataData, notificationRepo, notificationCommon, revisionService, userRepo, reportRepo, reviewService)
 	notificationController := controller.NewNotificationController(notificationService, rankService)
-	dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configService, siteInfoCommonService, serviceConf, dataData)
+	dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configService, siteInfoCommonService, serviceConf, reviewService, revisionRepo, dataData)
 	dashboardController := controller.NewDashboardController(dashboardService)
 	uploaderService := uploader.NewUploaderService(serviceConf, siteInfoCommonService)
 	uploadController := controller.NewUploadController(uploaderService)
diff --git a/internal/service/dashboard/dashboard_service.go b/internal/service/dashboard/dashboard_service.go
index 0d36cd6a..d4a52860 100644
--- a/internal/service/dashboard/dashboard_service.go
+++ b/internal/service/dashboard/dashboard_service.go
@@ -28,6 +28,8 @@ import (
 	"net/url"
 	"time"
 
+	"github.com/apache/incubator-answer/internal/service/review"
+	"github.com/apache/incubator-answer/internal/service/revision"
 	"github.com/apache/incubator-answer/pkg/converter"
 	"xorm.io/xorm/schemas"
 
@@ -58,6 +60,8 @@ type dashboardService struct {
 	configService   *config.ConfigService
 	siteInfoService siteinfo_common.SiteInfoCommonService
 	serviceConfig   *service_config.ServiceConfig
+	reviewService   *review.ReviewService
+	revisionRepo    revision.RevisionRepo
 	data            *data.Data
 }
 
@@ -71,6 +75,8 @@ func NewDashboardService(
 	configService *config.ConfigService,
 	siteInfoService siteinfo_common.SiteInfoCommonService,
 	serviceConfig *service_config.ServiceConfig,
+	reviewService *review.ReviewService,
+	revisionRepo revision.RevisionRepo,
 	data *data.Data,
 ) DashboardService {
 	return &dashboardService{
@@ -83,6 +89,8 @@ func NewDashboardService(
 		configService:   configService,
 		siteInfoService: siteInfoService,
 		serviceConfig:   serviceConfig,
+		reviewService:   reviewService,
+		revisionRepo:    revisionRepo,
 		data:            data,
 	}
 }
@@ -187,11 +195,23 @@ func (ds *dashboardService) userCount(ctx context.Context) int64 {
 }
 
 func (ds *dashboardService) reportCount(ctx context.Context) int64 {
+	reviewCount, err := ds.reviewService.GetReviewPendingCount(ctx)
+	if err != nil {
+		log.Errorf("get review count failed: %s", err)
+	}
 	reportCount, err := ds.reportRepo.GetReportCount(ctx)
 	if err != nil {
 		log.Errorf("get report count failed: %s", err)
 	}
-	return reportCount
+	countUnreviewedRevision, err := ds.revisionRepo.CountUnreviewedRevision(ctx, []int{
+		constant.ObjectTypeStrMapping[constant.AnswerObjectType],
+		constant.ObjectTypeStrMapping[constant.QuestionObjectType],
+		constant.ObjectTypeStrMapping[constant.TagObjectType],
+	})
+	if err != nil {
+		log.Errorf("get revision count failed: %s", err)
+	}
+	return reviewCount + reportCount + countUnreviewedRevision
 }
 
 // count vote