Exemplo n.º 1
0
Arquivo: radio.go Projeto: jsli/ota
func (c Radio) LogVisitorByIP() revel.Result {
	rdal, err := models.NewRedisDal()
	if err != nil {
		return nil
	}
	defer rdal.Close()
	ip := policy.FilterIp(c.Request.RemoteAddr)
	rdal.Incr(ip)
	return nil
}
Exemplo n.º 2
0
Arquivo: stat.go Projeto: jsli/ota
func (c Stat) Self() revel.Result {
	rdal, err := models.NewRedisDal()
	if err != nil {
		return c.RenderJson(err)
	}
	defer rdal.Close()
	ip := policy.FilterIp(c.Request.RemoteAddr)
	counter, err := rdal.Get(ip)
	if err != nil {
		return c.RenderJson(err)
	}

	result := models.StatSelfResult{}
	result.IP = ip
	result.Counter, _ = strconv.Atoi(counter)

	return c.RenderJson(result)
}
Exemplo n.º 3
0
Arquivo: stat.go Projeto: jsli/ota
func (c Stat) All() revel.Result {
	rdal, err := models.NewRedisDal()
	if err != nil {
		return c.RenderJson(err)
	}
	defer rdal.Close()

	result := models.StatAllResult{}
	result.Detail = make(map[string]int)
	keys, err := rdal.Keys("*")
	if err != nil {
		return c.RenderJson(err)
	}
	for _, key := range keys {
		count, _ := rdal.Get(key)
		count_i, _ := strconv.Atoi(count)
		result.Detail[key] = count_i
		result.TotalCount += count_i
	}
	return c.RenderJson(result)
}