Browse Source

del test mode

jiantao 4 years ago
parent
commit
287ed95bd7
5 changed files with 5 additions and 59 deletions
  1. 0 4
      ads_handler.go
  2. 0 1
      adslib/config.go
  3. 0 17
      adslib/device/device.go
  4. 5 7
      adslib/graylog/graylog.go
  5. 0 30
      adslib/redis_data/redis_data.go

+ 0 - 4
ads_handler.go

@@ -171,10 +171,6 @@ func adsHandler(c *gin.Context) {
171
 		device.SetAdsTagLog(advertiser, request.ReqSource, "DS_FREQ_1", cityCode)
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
 	//### 检查是否是ip黑名单
174
 	//### 检查是否是ip黑名单
179
 	isIpBlack, err := ads_checker.CheckBlackIp(ip)
175
 	isIpBlack, err := ads_checker.CheckBlackIp(ip)
180
 	if err != nil {
176
 	if err != nil {

+ 0 - 1
adslib/config.go

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

+ 0 - 17
adslib/device/device.go

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

+ 5 - 7
adslib/graylog/graylog.go

@@ -8,6 +8,8 @@ import (
8
 	"miads/adslib/utils"
8
 	"miads/adslib/utils"
9
 	"net/url"
9
 	"net/url"
10
 	"time"
10
 	"time"
11
+
12
+	log "github.com/sirupsen/logrus"
11
 )
13
 )
12
 
14
 
13
 var grayLog *gelf.Gelf
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
 	grayLog.Log(string(logStr))
30
 	grayLog.Log(string(logStr))
29
-
30
-	if adslib.GetConf().TestMode {
31
-		return
32
-	}
33
 }
31
 }
34
 
32
 
35
 func LogApi(shortMsg string, desc string, extraDesc string, reqSource string) {
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
 func SetDistributeActionNum(advertiser string, action string, bannerid int) {
164
 func SetDistributeActionNum(advertiser string, action string, bannerid int) {
165
-	if adslib.GetConf().TestMode {
166
-		return
167
-	}
168
-
169
 	if advertiser == "" {
165
 	if advertiser == "" {
170
 		return
166
 		return
171
 	}
167
 	}
@@ -204,9 +200,6 @@ func GetDeviceIpReport(deviceId string, ip string) (bool, error) {
204
 
200
 
205
 // 设置设备+ip上报的时间点
201
 // 设置设备+ip上报的时间点
206
 func SetDeviceIpReport(deviceid string, ip string) {
202
 func SetDeviceIpReport(deviceid string, ip string) {
207
-	if adslib.GetConf().TestMode {
208
-		return
209
-	}
210
 	conn := ads_redis.RedisConn.Get()
203
 	conn := ads_redis.RedisConn.Get()
211
 	defer conn.Close()
204
 	defer conn.Close()
212
 
205
 
@@ -216,9 +209,6 @@ func SetDeviceIpReport(deviceid string, ip string) {
216
 
209
 
217
 // 设置总请求到广告的次数
210
 // 设置总请求到广告的次数
218
 func SetAdsRequestNum(advertiser string, bannerId int) {
211
 func SetAdsRequestNum(advertiser string, bannerId int) {
219
-	if adslib.GetConf().TestMode {
220
-		return
221
-	}
222
 	if advertiser == "" {
212
 	if advertiser == "" {
223
 		return
213
 		return
224
 	}
214
 	}
@@ -234,9 +224,6 @@ func SetAdsRequestNum(advertiser string, bannerId int) {
234
 }
224
 }
235
 
225
 
236
 func SetAdsRealRequestNum(advertiser string) {
226
 func SetAdsRealRequestNum(advertiser string) {
237
-	if adslib.GetConf().TestMode {
238
-		return
239
-	}
240
 	if advertiser == "" {
227
 	if advertiser == "" {
241
 		return
228
 		return
242
 	}
229
 	}
@@ -277,9 +264,6 @@ func GetMinScriptOrderByAdv(advertiser string) (int64, error) {
277
 
264
 
278
 // 设置来源的曝光次数
265
 // 设置来源的曝光次数
279
 func SetReqSourceView(adv string, reqSource string, source string) {
266
 func SetReqSourceView(adv string, reqSource string, source string) {
280
-	if adslib.GetConf().TestMode {
281
-		return
282
-	}
283
 	conn := ads_redis.RedisConn.Get()
267
 	conn := ads_redis.RedisConn.Get()
284
 	defer conn.Close()
268
 	defer conn.Close()
285
 
269
 
@@ -329,10 +313,6 @@ func GetFinishedDispatchCount(orderId int64, dispatchType string, curTime time.T
329
 // 增加已经投放的量
313
 // 增加已经投放的量
330
 // dispatchType: "click", "show"
314
 // dispatchType: "click", "show"
331
 func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
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
 	conn := ads_redis.RedisConn.Get()
316
 	conn := ads_redis.RedisConn.Get()
337
 	defer conn.Close()
317
 	defer conn.Close()
338
 
318
 
@@ -371,10 +351,6 @@ func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTi
371
 // 增加当前分钟已经投放的量
351
 // 增加当前分钟已经投放的量
372
 // dispatchType: "click", "show"
352
 // dispatchType: "click", "show"
373
 func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
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
 	conn := ads_redis.RedisConn.Get()
354
 	conn := ads_redis.RedisConn.Get()
379
 	defer conn.Close()
355
 	defer conn.Close()
380
 
356
 
@@ -391,9 +367,6 @@ func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incr
391
 // 设置总计划投放数量
367
 // 设置总计划投放数量
392
 // dispatchType: "click", "show"
368
 // dispatchType: "click", "show"
393
 func SetPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime time.Time) {
369
 func SetPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime time.Time) {
394
-	if adslib.GetConf().TestMode {
395
-		return
396
-	}
397
 	conn := ads_redis.RedisConn.Get()
370
 	conn := ads_redis.RedisConn.Get()
398
 	defer conn.Close()
371
 	defer conn.Close()
399
 
372
 
@@ -404,9 +377,6 @@ func SetPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime t
404
 // 设置订单计划投放数量
377
 // 设置订单计划投放数量
405
 // dispatchType: "click", "show"
378
 // dispatchType: "click", "show"
406
 func SetOrderPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime time.Time) {
379
 func SetOrderPlanDispatchCount(orderId int64, dispatchType string, cnt int, curTime time.Time) {
407
-	if adslib.GetConf().TestMode {
408
-		return
409
-	}
410
 	conn := ads_redis.RedisConn.Get()
380
 	conn := ads_redis.RedisConn.Get()
411
 	defer conn.Close()
381
 	defer conn.Close()
412
 
382