package timer

import (
	"github.com/robfig/cron/v3"

	"code.gitea.io/gitea/modules/log"
	"code.gitea.io/gitea/routers/repo"
)

func LaunchCronJob() {
	log.Trace("Run cron job")

	c := cron.New()

	spec := "*/10 * * * *"
	c.AddFunc(spec, repo.HandleUnDecompressAttachment)

	specCheckBlockChainUserSuccess := "*/10 * * * *"
	c.AddFunc(specCheckBlockChainUserSuccess, repo.HandleBlockChainUnSuccessUsers)

	specCheckRepoBlockChainSuccess := "*/1 * * * *"
	c.AddFunc(specCheckRepoBlockChainSuccess, repo.HandleBlockChainUnSuccessRepos)

	specCheckUnTransformedPRs := "*/1 * * * *"
	c.AddFunc(specCheckUnTransformedPRs, repo.HandleBlockChainMergedPulls)

	specCheckBlockChainCommitSuccess := "*/3 * * * *"
	c.AddFunc(specCheckBlockChainCommitSuccess, repo.HandleBlockChainUnSuccessCommits)
	c.Start()
}
