Example #1
0
File: zj.go Project: qgweb/new
// 域名找回信息获取
func (this *ZjPut) VisitorData(out chan interface{}, in chan int8) {
	var datacount = 0
	defer func() {
		// 统计数据 zhejiang_put , other_1461016800, 11111
		lib.StatisticsData("dsource_stats", "zj_"+this.Timestamp+"_visitor",
			convert.ToString(datacount), "")
	}()
	m, err := lib.GetMongoObj()
	if err != nil {
		log.Error(err)
		in <- 1
		return
	}
	defer m.Close()

	qconf := mongodb.MongodbQueryConf{}
	qconf.Db = "data_source"
	qconf.Table = "zhejiang_visitor"
	qconf.Query = mongodb.MM{}
	m.Query(qconf, func(info map[string]interface{}) {
		ad := convert.ToString(info["ad"])
		ua := encrypt.DefaultMd5.Encode(encrypt.DefaultBase64.Decode(convert.ToString(info["ua"])))
		aids := convert.ToString(info["aids"])
		datacount++
		out <- fmt.Sprintf("%s\t%s\t%s", ad, ua, aids)
	})
	log.Info("访客ok")
	in <- 1
}
Example #2
0
File: other.go Project: qgweb/new
func (this *UserTrack) otherData(out chan interface{}, in chan int8) {
	var (
		eghour = timestamp.GetHourTimestamp(-1)
		bghour = timestamp.GetHourTimestamp(-25)
	)
	conf := mongodb.MongodbQueryConf{}
	conf.Db = "data_source"
	conf.Table = "useraction"
	conf.Query = mongodb.MM{"timestamp": mongodb.MM{"$gte": bghour, "$lte": eghour}, "domainId": "0"}
	this.mg_big.Query(conf, func(info map[string]interface{}) {
		ua := "ua"
		ad := convert.ToString(info["AD"])
		if u, ok := info["UA"]; ok {
			ua = convert.ToString(u)
		}
		cids := make([]string, 0, len(info["tag"].([]interface{})))
		for _, v := range info["tag"].([]interface{}) {
			if tags, ok := v.(map[string]interface{}); ok {
				if strings.TrimSpace(convert.ToString(tags["tagId"])) != "" {
					cids = append(cids, convert.ToString(tags["tagId"]))
				}
			}
		}
		out <- fmt.Sprintf("%s\t%s\t%s", ad, ua, strings.Join(cids, ","))
	})
	in <- 1
}
Example #3
0
File: other.go Project: qgweb/new
func (this *UserTrack) getBigCat() {
	conf := mongodb.MongodbQueryConf{}
	conf.Db = "data_source"
	conf.Table = "taocat"
	conf.Query = mongodb.MM{"type": "0"}
	conf.Select = mongodb.MM{"bid": 1, "cid": 1}
	this.mg.Query(conf, func(info map[string]interface{}) {
		this.bigCategoryMap[convert.ToString(info["cid"])] = convert.ToString(info["bid"])
	})
}
Example #4
0
File: url.go Project: qgweb/new
func (this *Domain) cleanPutTable() {
	qconf := mongodb.MongodbQueryConf{}
	qconf.Db = "data_source"
	qconf.Table = "urltrack_put"
	qconf.Index = []string{"cids.id"}
	this.mg.Drop(qconf)
	this.mg.Create(qconf)
	this.mg.EnsureIndex(qconf)
	qconf.Index = []string{"adua"}
	this.mg.EnsureIndex(qconf)
}
Example #5
0
func (this *TaobaoESStore) initCategory() {
	q := mongodb.MongodbQueryConf{}
	q.Db = "xu_precise"
	q.Table = "taocat"
	q.Select = mongodb.MM{"name": 1, "cid": 1, "_id": 0}
	q.Query = mongodb.MM{"type": "0"}
	this.catMap = make(map[string]string)
	this.store.Query(q, func(info map[string]interface{}) {
		this.catMap[info["cid"].(string)] = info["name"].(string)
	})
}
Example #6
0
File: ad-geo.go Project: qgweb/new
func getGeop(w http.ResponseWriter, r *http.Request) {
	ad := strings.TrimSpace(r.URL.Query().Get("ad"))
	mlink, err := db.Get()
	lon := ""
	lat := ""

	if err != nil {
		log.Error(err)
		w.Write([]byte(""))
		return
	}

	defer mlink.Close()

	if ad == "" {
		w.WriteHeader(404)
		w.Write([]byte(""))
		return
	}

	qconf := mongodb.MongodbQueryConf{}
	qconf.Db = "lonlat_data"
	qconf.Table = "tbl_map"
	qconf.Select = mongodb.MM{"lon": 1, "lat": 1}
	qconf.Query = mongodb.MM{"ad": ad}
	info, err := mlink.One(qconf)
	if err != nil {
		log.Error(err)
		w.Write([]byte(""))
		return
	}

	if v, ok := info["lon"]; ok {
		lon = convert.ToString(v)
	}
	if v, ok := info["lat"]; ok {
		lat = convert.ToString(v)
	}
	w.Write([]byte(fmt.Sprintf("%s,%s", lon, lat)))
}
Example #7
0
File: other.go Project: qgweb/new
func (this *UserTrack) cleanPutTable() {
	qconf := mongodb.MongodbQueryConf{}
	qconf.Db = "data_source"
	qconf.Table = "useraction_put"
	qconf.Index = []string{"tag.tagId"}
	this.mg.Drop(qconf)
	this.mg.Create(qconf)
	this.mg.EnsureIndex(qconf)
	qconf.Index = []string{"adua"}
	this.mg.EnsureIndex(qconf)
	qconf.Index = []string{"AD"}
	this.mg.EnsureIndex(qconf)

	qconf = mongodb.MongodbQueryConf{}
	qconf.Db = "data_source"
	qconf.Table = "useraction_put_big"
	qconf.Index = []string{"tag.tagId"}
	this.mg_big.Drop(qconf)
	this.mg_big.Create(qconf)
	this.mg_big.EnsureIndex(qconf)
	qconf.Index = []string{"adua"}
	this.mg_big.EnsureIndex(qconf)
	qconf.Index = []string{"AD"}
	this.mg_big.EnsureIndex(qconf)
}