2021-09-26 10:30:51 +05:00
|
|
|
package tasks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.dev.pztrn.name/periodicator/internal/gitlab"
|
|
|
|
)
|
|
|
|
|
2021-09-29 07:35:31 +05:00
|
|
|
// PrintCreationTSes prints tasks creation timestamps.
|
|
|
|
func PrintCreationTSes(client *gitlab.Client, tasks []Config) {
|
|
|
|
for _, task := range tasks {
|
2021-11-21 17:38:31 +05:00
|
|
|
taskData := &BaseTask{
|
2021-09-29 07:35:31 +05:00
|
|
|
client: client,
|
|
|
|
projectID: task.ProjectID,
|
|
|
|
title: task.Title,
|
|
|
|
body: task.Body,
|
|
|
|
tags: task.Tags,
|
|
|
|
executionStartTimestamp: task.ExecutionStart.GetTimestamp(),
|
|
|
|
cron: task.Cron,
|
|
|
|
dueIn: task.DueIn,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get similar tasks.
|
|
|
|
// ToDo: refactor?
|
2021-11-21 17:38:31 +05:00
|
|
|
issues, err := taskData.getIssues()
|
2021-09-29 07:35:31 +05:00
|
|
|
if err != nil {
|
|
|
|
panic("Error while getting issues from Gitlab: " + err.Error())
|
|
|
|
}
|
|
|
|
|
2021-11-21 17:38:31 +05:00
|
|
|
taskData.log(taskData.getNextCreationTimestamp(taskData.getLastCreationTimestamp(issues)).String())
|
2021-09-29 07:35:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-26 10:30:51 +05:00
|
|
|
// Process processes passed tasks.
|
|
|
|
func Process(client *gitlab.Client, tasks []Config) {
|
|
|
|
for _, task := range tasks {
|
2021-11-21 17:38:31 +05:00
|
|
|
taskData := &BaseTask{
|
2021-09-26 10:30:51 +05:00
|
|
|
client: client,
|
|
|
|
projectID: task.ProjectID,
|
|
|
|
title: task.Title,
|
|
|
|
body: task.Body,
|
|
|
|
tags: task.Tags,
|
|
|
|
executionStartTimestamp: task.ExecutionStart.GetTimestamp(),
|
|
|
|
cron: task.Cron,
|
|
|
|
dueIn: task.DueIn,
|
|
|
|
}
|
|
|
|
|
2021-11-21 17:38:31 +05:00
|
|
|
taskData.Run()
|
2021-09-26 10:30:51 +05:00
|
|
|
}
|
|
|
|
}
|