Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/plugins/zentao/tasks/execution_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ package tasks
import (
"encoding/json"
"fmt"
"net/http"
"net/url"

"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"net/http"
"net/url"
)

const RAW_EXECUTION_TABLE = "zentao_api_executions"
Expand Down
21 changes: 21 additions & 0 deletions backend/plugins/zentao/tasks/execution_summary_dev_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import (
"fmt"
"net/http"

"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/zentao/models"
)

const RAW_EXECUTION_SUMMARY_DEV_TABLE = "zentao_api_execution_summary_dev"
Expand All @@ -33,6 +35,25 @@ var _ plugin.SubTaskEntryPoint = CollectExecutionSummaryDev

func CollectExecutionSummaryDev(taskCtx plugin.SubTaskContext) errors.Error {
data := taskCtx.GetData().(*ZentaoTaskData)
db := taskCtx.GetDal()

// load stories id from db
clauses := []dal.Clause{
dal.From(&models.ZentaoExecutionSummary{}),
dal.Where(
"project = ? AND connection_id = ?",
data.Options.ProjectId, data.Options.ConnectionId,
),
}
count, err := db.Count(clauses...)
if err != nil {
return err
}
// if there are already data in db, skip this task
if count > 0 {
return nil
}

collector, err := api.NewApiCollector(api.ApiCollectorArgs{
RawDataSubTaskArgs: api.RawDataSubTaskArgs{
Ctx: taskCtx,
Expand Down