1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package crontab
- import (
- "context"
- "gd_crontab/rpc_apis"
- "gd_crontab/rpc_apis/gd_management"
- "time"
- "github.com/astaxie/beego/orm"
- )
- func deleteAccessOldMinute(o orm.Ormer, nowMinute int64) {
- o.Raw("delete from t_gd_access_log_day where timestamp < ?", nowMinute).Exec()
- }
- func deleteThirdOldMinute(o orm.Ormer, nowMinute int64) {
- o.Raw("delete from t_gd_thirdpart_log_day where timestamp < ?", nowMinute).Exec()
- }
- func deleteProviderOldCount() {
- now := time.Now()
- old := now.AddDate(0, 0, -2)
- date := old.Format("2006-01-02")
- mreq := gd_management.ManagementDelProviderOldCountReq{
- Date: date,
- }
- rpc_apis.Management.ManagementDelProviderOldCount(context.Background(), &mreq)
- }
- /*
- func deleteWarningMailLog() {
- accessDB := warning.GetWarningMongoDb()
- collection := mongo.Session.DB(accessDB).C("mail_log")
- timestamp := time.Now().AddDate(0, 0, -1).Unix()
- collection.RemoveAll(bson.M{"timestamp": bson.M{"$lte": timestamp}})
- }*/
- func DeleteLogDayTask() {
- go func() {
- o := orm.NewOrm()
- t := time.NewTicker(1 * time.Hour)
- for {
- select {
- case <-t.C:
- now := time.Now()
- if now.Hour() == 6 {
- deleteProviderOldCount()
- deleteMinute := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()).AddDate(0, 0, -2).Unix()
- deleteAccessOldMinute(o, deleteMinute)
- deleteThirdOldMinute(o, deleteMinute)
- //deleteWarningMailLog()
- }
- }
- }
- }()
- }
|