Beispiel #1
0
Datei: c.go Projekt: qgweb/new
// 域名生效
func (this CproData) DomainEffect(id string) error {
	var (
		mem  = db.GetMemcacheConn()
		msql = db.GetMysqlConn()
		key  = "DOMAIN_COOKIE_" + id
	)

	it, err := mem.Get(key)
	if err != nil && err != memcache.ErrCacheMiss {
		return err
	}

	if it == nil {
		r, err := msql.Raw("update nxu_group_pkg set is_effective=?,effective_time=? where id=?", 1,
			timestamp.GetTimestamp(), id).Exec()
		if err != nil {
			return err
		}
		if n, err := r.RowsAffected(); err == nil && n > 0 {
			mem.Set(&memcache.Item{Key: key, Value: []byte("1")})
		}
	}

	return nil
}
Beispiel #2
0
func (this *JDESStore) pushTagToMap(cd *CombinationJDData) {
	var (
		db1      = "map_trace"
		db2      = "map_trace_search"
		table    = "map"
		date     = timestamp.GetTimestamp(fmt.Sprintf("%s %s:%s:%s", cd.Date, cd.Clock, "00", "00"))
		id       = encrypt.DefaultMd5.Encode(date + cd.Ad + encrypt.DefaultBase64.Encode(cd.Ua))
		tagNames = this.getTagNames(cd.Ginfos)
		brands   = this.getBrands(cd.Ginfos)
		geo      = GetLonLat(cd.Ad, this.geohost)
	)

	info := map[string]interface{}{
		"ad":        cd.Ad,
		"ua":        encrypt.DefaultBase64.Encode(cd.Ua),
		"timestamp": date,
		"jd_tags":   tagNames,
		"jd_brand":  brands,
		"geo":       geo,
	}

	if geo != "" {
		//this.client.Update().Index(db1).Type(table).Id(id).Doc(info).DocAsUpsert(true).Do()
		//this.client.Update().Index(db2).Type(table).Id(id).Doc(info).DocAsUpsert(true).Do()
		this.bulk.Add(elastic.NewBulkUpdateRequest().Index(db1).Type(table).Id(id).Doc(info).DocAsUpsert(true))
		this.bulk.Add(elastic.NewBulkUpdateRequest().Index(db2).Type(table).Id(id).Doc(info).DocAsUpsert(true))
	}
}
Beispiel #3
0
Datei: url.go Projekt: qgweb/new
func newDomain() *Domain {
	d := &Domain{}
	d.hb = common.CommonHbase
	d.fname = "/tmp/" + timestamp.GetTimestamp() + ".txt"
	d.kvf = common.NewKVFile(d.fname)
	d.mg = common.CommonDataMongo
	conf := mongodb.MongodbQueryConf{Db: "data_source", Table: "urltrack_put"}
	d.mgb = mongodb.NewMongodbBufferWriter(d.mg, conf)

	return d
}
Beispiel #4
0
func (this *TaobaoESStore) saveShopTrace(cd *CombinationData) {
	var date = timestamp.GetTimestamp(fmt.Sprintf("%s %s:%s:%s", cd.Date, cd.Clock, "00", "00"))
	var db = this.prefix + "_tb_shop_trace"
	var id = encrypt.DefaultMd5.Encode(date + cd.Ad + cd.Ua)
	var table = "shop"
	var shopids = make([]string, 0, len(cd.Ginfos))
	for _, v := range cd.Ginfos {
		shopids = append(shopids, v.Shop_id)
	}

	//查询是否存在
	res, err := this.client.Search().Index(db).Type(table).Query(elastic.NewIdsQuery(table).Ids(id)).Fields("shop").Do()
	if err != nil {
		log.Error(err)
	}

	if res == nil || res.TotalHits() == 0 {
		//log.Info(this.client.Index().Index(db).Type(table).Id(id).BodyJson(map[string]interface{}{
		//	"ad":        cd.Ad,
		//	"ua":        cd.Ua,
		//	"timestamp": date,
		//	"shop":      shopids,
		//}).Do())
		this.bulk.Add(elastic.NewBulkIndexRequest().Index(db).Type(table).Id(id).Doc(
			map[string]interface{}{
				"ad":        cd.Ad,
				"ua":        cd.Ua,
				"timestamp": date,
				"shop":      shopids,
			}))
	} else {
		oshopids := res.Hits.Hits[0].Fields["shop"].([]interface{})
		var tmpMap = make(map[string]byte)
		for _, vv := range oshopids {
			tmpMap[vv.(string)] = 1
		}
		for _, vv := range shopids {
			tmpMap[vv] = 1
		}

		nshopids := make([]string, 0, len(tmpMap))
		for k, _ := range tmpMap {
			nshopids = append(nshopids, k)
		}

		//log.Info(this.client.Update().Index(db).Type(table).Doc(map[string]interface{}{
		//	"shop": nshopids,
		//}).Id(id).Do())
		this.bulk.Add(elastic.NewBulkUpdateRequest().Index(db).Type(table).Doc(map[string]interface{}{
			"shop": nshopids,
		}).Id(id))
	}
}
Beispiel #5
0
func newUserTrack() *UserTrack {
	d := &UserTrack{}
	d.hb = common.CommonHbase
	d.fname = "/tmp/" + timestamp.GetTimestamp() + ".txt"
	d.kvf = common.NewKVFile(d.fname)
	d.mg = common.CommonDataMongo
	conf := mongodb.MongodbQueryConf{Db: "data_source", Table: "useraction_put"}
	d.mgb = mongodb.NewMongodbBufferWriter(d.mg, conf)
	conf = mongodb.MongodbQueryConf{Db: "data_source", Table: "useraction_put_big"}
	d.mg_big, _ = d.mg.Get()
	d.mgb_big = mongodb.NewMongodbBufferWriter(d.mg_big, conf)
	d.bigCategoryMap = make(map[string]string)
	d.getBigCat()
	return d
}
Beispiel #6
0
func (this *JDESStore) saveAdTrace(cd *CombinationJDData) {
	var date = timestamp.GetTimestamp(fmt.Sprintf("%s %s:%s:%s", cd.Date, cd.Clock, "00", "00"))
	var id = encrypt.DefaultMd5.Encode(date + cd.Ad + cd.Ua)
	var db = this.prefix + "_jd_ad_trace"
	var table = "ad"
	var cids = make([]string, 0, len(cd.Ginfos))

	for _, v := range cd.Ginfos {
		cids = append(cids, v.Tagid)
	}
	//log.Info(this.client.Index().Index(db).Type(table).Id(id).BodyJson(map[string]interface{}{
	//	"ad":        cd.Ad,
	//	"ua":        cd.Ua,
	//	"timestamp": date,
	//	"cids":      cids,
	//}).Do())
	this.bulk.Add(elastic.NewBulkIndexRequest().Index(db).Type(table).Id(id).Doc(map[string]interface{}{
		"ad":        cd.Ad,
		"ua":        cd.Ua,
		"timestamp": date,
		"cids":      cids,
	}))
}