Exemple #1
0
Fichier : js.go Projet : qgweb/new
// 标签数据统计
func (this *JsPut) tagDataStats() {
	fname := convert.ToString(time.Now().UnixNano()) + "_"
	this.kf.IDAdUaSet(fname, func(info map[string]int) {
		for k, v := range info {
			tagid := strings.TrimPrefix(k, fname)
			tagids := strings.Split(tagid, "_")
			// 标签统计数据 tags_stats , url_1461016800, 11111
			lib.StatisticsData("tags_stats", fmt.Sprintf("js_%s_%s_%s", timestamp.GetHourTimestamp(-1), tagids[0], tagids[1]),
				convert.ToString(v), "incr")
		}
	}, true)
}
Exemple #2
0
Fichier : js.go Projet : qgweb/new
// 保存投放轨迹到电信ftp
func (this *JsPut) saveTraceToDianxin() {
	var (
		ftp     = lib.GetConfVal("jiangsu::ftp_path")
		ppath   = lib.GetConfVal("jiangsu::put_path")
		rk      = "account.10046.sha1." + time.Now().Add(-time.Hour).Format("200601021504")
		fname   = ppath + "/" + rk
		adcount = 0
	)

	f, err := os.Create(fname)
	if err != nil {
		log.Error("创建文件失败", err)
		return
	}
	defer f.Close()

	this.kf.AdSet(func(ad string) {
		if v, ok := this.areamap[ad]; ok {
			f.WriteString(ad + "," + v + "\n")
			adcount++
		}
	})
	cmd := exec.Command(ftp, rk)
	str, err := cmd.Output()
	log.Info(string(str), err)

	// 广告数量统计数据 dx_stats , js_1461016800, 11111
	lib.StatisticsData("dx_stats", fmt.Sprintf("js_%s", timestamp.GetHourTimestamp(-1)),
		convert.ToString(adcount), "")
}
Exemple #3
0
Fichier : js.go Projet : qgweb/new
// 保存投放轨迹到投放系统
func (this *JsPut) saveTraceToPutSys() {
	rdb, err := lib.GetPutRedisObj("put_redis_proxy_url")
	if err != nil {
		log.Error("redis连接失败", err)
		return
	}
	go func() {
		for {
			rdb.Receive()
		}
	}()
	//rdb.SelectDb("1")
	adcount := 0
	this.kf.AdUaIdsSet(func(ad string, ua string, aids map[string]int8) {
		key := ad
		if ua != "ua" {
			ua = encrypt.DefaultMd5.Encode(encrypt.DefaultBase64.Decode(ua))
			key = encrypt.DefaultMd5.Encode(ad + "_" + ua)
		}
		for aid, _ := range aids {
			rdb.HSet(key, "advert:"+aid, aid)
		}
		rdb.Expire(key, 5400)
		adcount++
	})
	rdb.Flush()
	rdb.Close()
	// 广告数量统计数据 put_stats , js_1461016800, 11111
	lib.StatisticsData("put_stats", fmt.Sprintf("js_%s", timestamp.GetHourTimestamp(-1)),
		convert.ToString(adcount), "")
}
Exemple #4
0
Fichier : js.go Projet : qgweb/new
func NewJsPut() *JsPut {
	var jp = &JsPut{}
	jp.kf = dbfactory.NewKVFile(fmt.Sprintf("./%s.txt", convert.ToString(time.Now().Unix())))
	jp.putTags = make(map[string]map[string]int)
	jp.initArea()
	jp.initPutAdverts()
	jp.initPutTags("TAGS_3*", "tb_", "mg_")
	jp.initPutTags("TAGS_5*", "url_", "")
	return jp
}
Exemple #5
0
Fichier : js.go Projet : qgweb/new
// 保存广告对应的ad,ua
func (this *JsPut) saveAdvertSet() {
	tname := "advert_tj_js_" + timestamp.GetHourTimestamp(-1) + "_"
	fname := lib.GetConfVal("jiangsu::data_path") + tname
	this.kf.IDAdUaSet(fname, func(info map[string]int) {
		tm := timestamp.GetHourTimestamp(-1)
		for k, v := range info {
			aid := strings.TrimPrefix(k, tname)
			// 广告数量统计数据 advert_stats , js_1461016800_1111, 11111
			lib.StatisticsData("advert_stats", fmt.Sprintf("js_%s_%s", tm, aid),
				convert.ToString(v), "")
		}
	}, false)
}
Exemple #6
0
Fichier : js.go Projet : qgweb/new
// 其他杂项数据获取
func (this *JsPut) otherData(out chan interface{}, in chan int8) {
	var datacount = 0
	defer func() {
		// 统计数据 jiangsu_put , other_1461016800, 11111
		lib.StatisticsData("dsource_stats", "js_"+timestamp.GetHourTimestamp(-1)+"_other",
			convert.ToString(datacount), "")
	}()

	fname := "jiangsu_other_" + timestamp.GetHourTimestamp(-1)
	if err := lib.GetFdbData(fname, func(val string) {
		if v := lib.AddPrefix(val, "mg_"); v != "" {
			datacount++
			out <- v
		}
	}); err != nil {
		in <- 1
		return
	}
	in <- 1
}