ソースを参照

feat:优化sql

wangchuanjin 1 年間 前
コミット
38c0cc66b5
2 ファイル変更5 行追加2 行削除
  1. 1 1
      jyBXBase/rpc/model/newestBidding.go
  2. 4 1
      jyBXSubscribe/rpc/model/push.go

+ 1 - 1
jyBXBase/rpc/model/newestBidding.go

@@ -119,7 +119,7 @@ func (n *NewestInfo) IsHasNewPushData(time int64) bool {
 
 // GetPushHistory
 func (n *NewestInfo) GetPushHistory() (res []*bxbase.NewestList) {
-	findSQL := "select a.infoid,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.attachment_count,a.budget,a.bidamount from %s  a  where a.userid=%d   order by a.id desc limit ?"
+	findSQL := "select a.infoid,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.attachment_count,a.budget,a.bidamount from %s  a  where a.userid=%d and a.date>0  order by a.date desc,a.id desc limit ?"
 	findSQL = fmt.Sprintf(findSQL, n.TableName, n.NewUserId)
 	logx.Info(n.TableName, "-------", n.NewUserId, ",findSQL:", findSQL)
 	t := time.Now()

+ 4 - 1
jyBXSubscribe/rpc/model/push.go

@@ -3,7 +3,6 @@ package model
 import (
 	"encoding/json"
 	"fmt"
-	"github.com/gogf/gf/v2/util/gconv"
 	IC "jyBXSubscribe/rpc/init"
 	ms "jyBXSubscribe/rpc/model/service"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
@@ -14,6 +13,8 @@ import (
 	"sync"
 	"time"
 
+	"github.com/gogf/gf/v2/util/gconv"
+
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
@@ -440,6 +441,8 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			querys = append(querys, fmt.Sprintf(" a.date>=%d", starttime))
 		} else if starttime == 0 && endtime > 0 {
 			querys = append(querys, fmt.Sprintf(" a.date<=%d", endtime))
+		} else {
+			querys = append(querys, " a.date>0")
 		}
 		var regionArr = []string{}
 		if spqp.Area != "" || spqp.City != "" || spqp.District != "" {