示例#1
0
//UpdateTheBoxes is a url handler
func UpdateTheBoxes(rw http.ResponseWriter, r *http.Request) {
	go mytools.Log("Access", fmt.Sprint("/UpdateTheBoxes Request from ", r.RemoteAddr, " at ", time.Now()))
	mytools.WebDebug(rw, "Getting Clan Member List")
	members := boxcheckerbackend.GetClanMembers()
	mytools.WebDebug(rw, "Getting boxes")
	boxcheckerbackend.GetBoxes(members)
	mytools.WebDebug(rw, "Counting boxes")
	boxcheckerbackend.CountLastMonthBoxes(members)
	mytools.WebDebug(rw, "Updating activity dates")
	boxcheckerbackend.UpdateLastActive(members)
}
示例#2
0
// Scheduler automates the updating of boxes.  Runs forever and sleeps a minute at a Time
// and when the date changes trigger the update process.
func Scheduler() {

	today := time.Now().Local().Format("2006-01-02 00:00:00")
	hours, minutes, _ := time.Now().Clock()
	for {
		if today != time.Now().Local().Format("2006-01-02 00:00:00") {
			mytools.Debug("Performing Update")
			mytools.Log("Scheduler", fmt.Sprint("Performing update at", hours))
			members := boxcheckerbackend.GetClanMembers()
			boxcheckerbackend.GetBoxes(members)
			boxcheckerbackend.CountLastMonthBoxes(members)
			today = time.Now().Local().Format("2006-01-02 00:00:00")
		}

		if minutes == 0 {
			//mytools.Debug(fmt.Sprint("Hourly Scheduler Heartbeat at ", hours))
			go mytools.Log("Scheduler", fmt.Sprint("Hourly Scheduler Heartbeat at ", hours))
		}
		time.Sleep(time.Minute)
	}
}