Browse Source

热度搜索

kobe6258 7 months ago
parent
commit
d54e7a51cf
2 changed files with 19 additions and 4 deletions
  1. 8 0
      domian/report/report_service.go
  2. 11 4
      models/user/user_source_click_flow.go

+ 8 - 0
domian/report/report_service.go

@@ -16,6 +16,7 @@ import (
 	"eta/eta_mini_ht_api/models/ht"
 	mediaDao "eta/eta_mini_ht_api/models/media"
 	reportDao "eta/eta_mini_ht_api/models/report"
+	userDao "eta/eta_mini_ht_api/models/user"
 	"github.com/google/uuid"
 	"math/rand"
 	"strconv"
@@ -393,6 +394,13 @@ func syncESAndSendMessage(reports []reportDao.Report) (err error) {
 			if !success {
 				logger.Error("更新es失败,reportId::%d,err:%v", report.ID, err)
 			}
+			if report.Status == reportDao.StatusUnPublish {
+				//隐藏热度搜索
+				err = userDao.HiddenFlows(report.ID, userDao.ReportSourceType)
+				if err != nil {
+					logger.Error("隐藏热度搜索失败,reportId::%d,err:%v", report.ID, err)
+				}
+			}
 		} else {
 			insert := ESReport{
 				ReportID:      report.ID,

+ 11 - 4
models/user/user_source_click_flow.go

@@ -17,9 +17,10 @@ type UserSourceClickFlow struct {
 	Mobile         string     `gorm:"column:mobile"`
 	SourceId       int        `gorm:"column:source_id"` // 研报ID
 	SourceType     SourceType `gorm:"column:source_type;type:enum('REPORT','VIDEO','AUDIO')"`
-	ClickTime      time.Time  `gorm:"column:click_time"`      // 点击时间
-	IPAddress      string     `gorm:"column:ip_address"`      // IP地址
-	Location       string     `gorm:"column:location"`        // 地理位置
+	ClickTime      time.Time  `gorm:"column:click_time"` // 点击时间
+	IPAddress      string     `gorm:"column:ip_address"` // IP地址
+	Location       string     `gorm:"column:location"`   // 地理位置
+	Hidden         bool       `gorm:"column:hidden;type:tinyint(1);default:0"`
 	Referer        string     `gorm:"column:referer"`         // 来源页面
 	AdditionalData string     `gorm:"column:additional_data"` // 额外数据
 }
@@ -42,6 +43,12 @@ type CountClickFlowById struct {
 
 func GetTimeDurationReportCountsById(begin string, end string, limit int, sourceType SourceType) (ids []CountClickFlowById, err error) {
 	db := models.Main()
-	err = db.Table(userSourceClickFlows).Select("source_id,count(*) count").Where("source_type=? and DATE(click_time) BETWEEN ? AND ?", sourceType, begin, end).Group("source_id").Order("count desc").Limit(limit).Scan(&ids).Error
+	err = db.Table(userSourceClickFlows).Select("source_id,count(*) count").Where("source_type=? and DATE(click_time) BETWEEN ? AND ? AND hidden =0", sourceType, begin, end).Group("source_id").Order("count desc").Limit(limit).Scan(&ids).Error
+	return
+}
+
+func HiddenFlows(id int, sourceType SourceType) (err error) {
+	db := models.Main()
+	err = db.Table(userSourceClickFlows).Where("source_type=? and source_id =?", sourceType, id).Update("hidden", 1).Error
 	return
 }