task.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/library/conf/env"
  6. "go-common/library/log"
  7. )
  8. // taskAddMonitor add monitor task
  9. func (s *Service) taskAddMonitor() {
  10. if err := s.AddMonitor(context.TODO()); err != nil {
  11. log.Error("task.taskAddMonitor error(%v)", err)
  12. }
  13. }
  14. // taskAddCache add cache task
  15. func (s *Service) taskAddCache() {
  16. if err := s.RanksCache(context.Background()); err != nil {
  17. log.Error("task.RanksCache error(%v)", err)
  18. }
  19. if err := s.AppsCache(context.Background()); err != nil {
  20. log.Error("task.AppsCache error(%v)", err)
  21. }
  22. }
  23. // taskRankWechatReport send rank report to wechat group task
  24. func (s *Service) taskRankWechatReport() {
  25. if env.DeployEnv != env.DeployEnvProd || time.Now().Weekday() == time.Sunday || time.Now().Weekday() == time.Saturday {
  26. return
  27. }
  28. if err := s.RankWechatReport(context.TODO()); err != nil {
  29. log.Error("task.taskRankWechatReport error(%v)", err)
  30. }
  31. }
  32. // taskWeeklyWechatReport send Weekly report and reset redis every Friday 19:00
  33. func (s *Service) taskWeeklyWechatReport() {
  34. if env.DeployEnv == env.DeployEnvProd && time.Now().Weekday() == time.Friday {
  35. if err := s.SummaryWechatReport(context.TODO()); err != nil {
  36. log.Error("task.taskWeeklyWechatReport error(%v)", err)
  37. }
  38. if err := s.dao.SetAppCovCache(context.TODO()); err != nil {
  39. log.Error("task.taskWeeklyWechatReport error(%v)", err)
  40. }
  41. }
  42. }