Example #1
0
File: radio.go Project: 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
}
Example #2
0
File: stat.go Project: 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)
}
Example #3
0
File: stat.go Project: 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)
}