Ver código fonte

del test mode

jiantao 4 anos atrás
pai
commit
287ed95bd7

+ 0 - 4
ads_handler.go

@@ -171,10 +171,6 @@ func adsHandler(c *gin.Context) {
171 171
 		device.SetAdsTagLog(advertiser, request.ReqSource, "DS_FREQ_1", cityCode)
172 172
 	}
173 173
 
174
-	if adslib.GetConf().TestMode {
175
-		needControl = false
176
-	}
177
-
178 174
 	//### 检查是否是ip黑名单
179 175
 	isIpBlack, err := ads_checker.CheckBlackIp(ip)
180 176
 	if err != nil {

+ 0 - 1
adslib/config.go

@@ -26,7 +26,6 @@ type SvrConf struct {
26 26
 	LogPath            string                                `toml:"log_path"`
27 27
 	RedisHost          string                                `toml:"redis_host"`
28 28
 	RedisPassword      string                                `toml:"redis_password"`
29
-	TestMode           bool                                  `toml:"test_mode"`
30 29
 }
31 30
 type FlogControlItem struct {
32 31
 	Percent  int `toml:"percent"`

+ 0 - 17
adslib/device/device.go

@@ -6,7 +6,6 @@ import (
6 6
 	"github.com/gomodule/redigo/redis"
7 7
 	log "github.com/sirupsen/logrus"
8 8
 	"math/rand"
9
-	"miads/adslib"
10 9
 	"miads/adslib/ads_redis"
11 10
 	"strconv"
12 11
 	"strings"
@@ -25,10 +24,6 @@ func SetAdsTagLog(adv string, reqSource string, key string, cityCode int) {
25 24
 }
26 25
 
27 26
 func setTagLog(key string) {
28
-	if adslib.GetConf().TestMode {
29
-		return
30
-	}
31
-
32 27
 	conn := ads_redis.RedisConn.Get()
33 28
 	defer conn.Close()
34 29
 
@@ -40,10 +35,6 @@ func setTagLog(key string) {
40 35
 
41 36
 // 存储ip上一次请求时间
42 37
 func SetIpReqTime(ip string, reqTime int64) {
43
-	if adslib.GetConf().TestMode {
44
-		return
45
-	}
46
-
47 38
 	conn := ads_redis.RedisConn.Get()
48 39
 	defer conn.Close()
49 40
 
@@ -71,10 +62,6 @@ func GetIpReqTime(ip string) (int64, error) {
71 62
 }
72 63
 
73 64
 func SetMiDeviceConf(key string, d DeviceConf) error {
74
-	if adslib.GetConf().TestMode {
75
-		return nil
76
-	}
77
-
78 65
 	conn := ads_redis.RedisConn.Get()
79 66
 	defer conn.Close()
80 67
 
@@ -123,10 +110,6 @@ func GetMiDeviceConf(ip string, randNum int, specialDeviceNum int) (*DeviceConf,
123 110
 
124 111
 // 设置每天的city_code的值
125 112
 func SetDailyFakeDeviceConfByCityCode(cityCode int, d DeviceConf, dateInt int) error {
126
-	if adslib.GetConf().TestMode {
127
-		return nil
128
-	}
129
-
130 113
 	conn := ads_redis.RedisConn.Get()
131 114
 	defer conn.Close()
132 115
 

+ 5 - 7
adslib/graylog/graylog.go

@@ -8,6 +8,8 @@ import (
8 8
 	"miads/adslib/utils"
9 9
 	"net/url"
10 10
 	"time"
11
+
12
+	log "github.com/sirupsen/logrus"
11 13
 )
12 14
 
13 15
 var grayLog *gelf.Gelf
@@ -22,14 +24,10 @@ func init() {
22 24
 	})
23 25
 }
24 26
 
25
-func Log(log interface{}) {
26
-	logStr, _ := json.Marshal(log)
27
-	fmt.Printf("graylog: %s\n", logStr)
27
+func Log(logData interface{}) {
28
+	logStr, _ := json.Marshal(logData)
29
+	log.Infof("graylog: %s", logStr)
28 30
 	grayLog.Log(string(logStr))
29
-
30
-	if adslib.GetConf().TestMode {
31
-		return
32
-	}
33 31
 }
34 32
 
35 33
 func LogApi(shortMsg string, desc string, extraDesc string, reqSource string) {

+ 0 - 30
adslib/redis_data/redis_data.go

@@ -162,10 +162,6 @@ func GetFlowPercentDuration(advertiser string, action string) *adslib.FlogContro
162 162
 
163 163
 // 设置回调回来的广告动作的次数
164 164
 func SetDistributeActionNum(advertiser string, action string, bannerid int) {
165
-	if adslib.GetConf().TestMode {
166
-		return
167
-	}
168
-
169 165
 	if advertiser == "" {
170 166
 		return
171 167
 	}
@@ -204,9 +200,6 @@ func GetDeviceIpReport(deviceId string, ip string) (bool, error) {
204 200
 
205 201
 // 设置设备+ip上报的时间点
206 202
 func SetDeviceIpReport(deviceid string, ip string) {
207
-	if adslib.GetConf().TestMode {
208
-		return
209
-	}
210 203
 	conn := ads_redis.RedisConn.Get()
211 204
 	defer conn.Close()
212 205
 
@@ -216,9 +209,6 @@ func SetDeviceIpReport(deviceid string, ip string) {
216 209
 
217 210
 // 设置总请求到广告的次数
218 211
 func SetAdsRequestNum(advertiser string, bannerId int) {
219
-	if adslib.GetConf().TestMode {
220
-		return
221
-	}
222 212
 	if advertiser == "" {
223 213
 		return
224 214
 	}
@@ -234,9 +224,6 @@ func SetAdsRequestNum(advertiser string, bannerId int) {
234 224
 }
235 225
 
236 226
 func SetAdsRealRequestNum(advertiser string) {
237
-	if adslib.GetConf().TestMode {
238
-		return
239
-	}
240 227
 	if advertiser == "" {
241 228
 		return
242 229
 	}
@@ -277,9 +264,6 @@ func GetMinScriptOrderByAdv(advertiser string) (int64, error) {
277 264
 
278 265
 // 设置来源的曝光次数
279 266
 func SetReqSourceView(adv string, reqSource string, source string) {
280
-	if adslib.GetConf().TestMode {
281
-		return
282
-	}
283 267
 	conn := ads_redis.RedisConn.Get()
284 268
 	defer conn.Close()
285 269
 
@@ -329,10 +313,6 @@ func GetFinishedDispatchCount(orderId int64, dispatchType string, curTime time.T
329 313
 // 增加已经投放的量
330 314
 // dispatchType: "click", "show"
331 315
 func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
332
-	if adslib.GetConf().TestMode {
333
-		return 0, nil
334
-	}
335
-
336 316
 	conn := ads_redis.RedisConn.Get()
337 317
 	defer conn.Close()
338 318
 
@@ -371,10 +351,6 @@ func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTi
371 351
 // 增加当前分钟已经投放的量
372 352
 // dispatchType: "click", "show"
373 353
 func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
374
-	if adslib.GetConf().TestMode {
375
-		return 0, nil
376
-	}
377
-
378 354
 	conn := ads_redis.RedisConn.Get()
379 355
 	defer conn.Close()
380 356
 
@@ -391,9 +367,6 @@ func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incr
391 367
 // 设置总计划投放数量
392 368
 // dispatchType: "click", "show"
393 369
 func SetPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime time.Time) {
394
-	if adslib.GetConf().TestMode {
395
-		return
396
-	}
397 370
 	conn := ads_redis.RedisConn.Get()
398 371
 	defer conn.Close()
399 372
 
@@ -404,9 +377,6 @@ func SetPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime t
404 377
 // 设置订单计划投放数量
405 378
 // dispatchType: "click", "show"
406 379
 func SetOrderPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime time.Time) {
407
-	if adslib.GetConf().TestMode {
408
-		return
409
-	}
410 380
 	conn := ads_redis.RedisConn.Get()
411 381
 	defer conn.Close()
412 382