This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch feat#5841-3
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/feat#5841-3 by this push:
new 226a38df0 fix: ci and uint-test
226a38df0 is described below
commit 226a38df086a96032baad41f0b67a2cfdc059a86
Author: abeizn <[email protected]>
AuthorDate: Fri Sep 8 14:05:44 2023 +0800
fix: ci and uint-test
---
backend/core/models/migrationscripts/20230907_add_full_sync.go | 2 ++
backend/helpers/pluginhelper/api/api_collector.go | 4 ++--
backend/helpers/pluginhelper/api/api_collector_test.go | 1 +
backend/helpers/pluginhelper/api/api_collector_with_state.go | 4 ++--
backend/helpers/pluginhelper/api/graphql_collector.go | 4 ++--
backend/plugins/circleci/api/blueprint200.go | 4 ++--
backend/plugins/circleci/impl/impl.go | 4 ++--
7 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/backend/core/models/migrationscripts/20230907_add_full_sync.go
b/backend/core/models/migrationscripts/20230907_add_full_sync.go
index 403e68892..293ac69a9 100644
--- a/backend/core/models/migrationscripts/20230907_add_full_sync.go
+++ b/backend/core/models/migrationscripts/20230907_add_full_sync.go
@@ -5,7 +5,9 @@ this work for additional information regarding copyright
ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
+
http://www.apache.org/licenses/LICENSE-2.0
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/backend/helpers/pluginhelper/api/api_collector.go
b/backend/helpers/pluginhelper/api/api_collector.go
index 7d29d8b49..f4472075d 100644
--- a/backend/helpers/pluginhelper/api/api_collector.go
+++ b/backend/helpers/pluginhelper/api/api_collector.go
@@ -162,8 +162,8 @@ func (collector *ApiCollector) Execute() errors.Error {
}
isIncremental := collector.args.Incremental
- taskContext := collector.args.Ctx.TaskContext()
- if taskContext.SyncPolicy().FullSync {
+ syncPolicy := collector.args.Ctx.TaskContext().SyncPolicy()
+ if syncPolicy != nil && syncPolicy.FullSync {
isIncremental = false
}
// flush data if not incremental collection
diff --git a/backend/helpers/pluginhelper/api/api_collector_test.go
b/backend/helpers/pluginhelper/api/api_collector_test.go
index 4007fe603..414b3369b 100644
--- a/backend/helpers/pluginhelper/api/api_collector_test.go
+++ b/backend/helpers/pluginhelper/api/api_collector_test.go
@@ -85,6 +85,7 @@ func TestFetchPageUndetermined(t *testing.T) {
mockApi.On("WaitAsync").Return(nil)
mockApi.On("GetAfterFunction", mock.Anything).Return(nil)
mockApi.On("SetAfterFunction", mock.Anything).Return()
+ mockApi.On("SetSyncPolicy", mock.Anything).Return()
mockApi.On("Release").Return()
collector, err := NewApiCollector(ApiCollectorArgs{
diff --git a/backend/helpers/pluginhelper/api/api_collector_with_state.go
b/backend/helpers/pluginhelper/api/api_collector_with_state.go
index e2ae8f987..43f48f689 100644
--- a/backend/helpers/pluginhelper/api/api_collector_with_state.go
+++ b/backend/helpers/pluginhelper/api/api_collector_with_state.go
@@ -74,9 +74,9 @@ func (m *ApiCollectorStateManager) IsIncremental() bool {
prevSyncTime := m.LatestState.LatestSuccessStart
prevTimeAfter := m.LatestState.TimeAfter
currTimeAfter := m.TimeAfter
- fullSync := m.Ctx.TaskContext().SyncPolicy().FullSync
+ syncPolicy := m.Ctx.TaskContext().SyncPolicy()
- if fullSync {
+ if syncPolicy != nil && syncPolicy.FullSync {
return false
}
if prevSyncTime == nil {
diff --git a/backend/helpers/pluginhelper/api/graphql_collector.go
b/backend/helpers/pluginhelper/api/graphql_collector.go
index 3a4cc571f..bf750409e 100644
--- a/backend/helpers/pluginhelper/api/graphql_collector.go
+++ b/backend/helpers/pluginhelper/api/graphql_collector.go
@@ -139,8 +139,8 @@ func (collector *GraphqlCollector) Execute() errors.Error {
divider := NewBatchSaveDivider(collector.args.Ctx,
collector.args.BatchSize, collector.table, collector.params)
isIncremental := collector.args.Incremental
- taskContext := collector.args.Ctx.TaskContext()
- if taskContext.SyncPolicy().FullSync {
+ syncPolicy := collector.args.Ctx.TaskContext().SyncPolicy()
+ if syncPolicy != nil && syncPolicy.FullSync {
isIncremental = false
}
// flush data if not incremental collection
diff --git a/backend/plugins/circleci/api/blueprint200.go
b/backend/plugins/circleci/api/blueprint200.go
index 0e0536dac..9f5a8d55b 100644
--- a/backend/plugins/circleci/api/blueprint200.go
+++ b/backend/plugins/circleci/api/blueprint200.go
@@ -38,7 +38,7 @@ func MakeDataSourcePipelinePlanV200(
subtaskMetas []plugin.SubTaskMeta,
connectionId uint64,
bpScopes []*coreModels.BlueprintScope,
- syncPolicy *coreModels.BlueprintSyncPolicy,
+ syncPolicy *coreModels.SyncPolicy,
) (coreModels.PipelinePlan, []plugin.Scope, errors.Error) {
plan := make(coreModels.PipelinePlan, len(bpScopes))
plan, err := makeDataSourcePipelinePlanV200(subtaskMetas, plan,
bpScopes, connectionId, syncPolicy)
@@ -58,7 +58,7 @@ func makeDataSourcePipelinePlanV200(
plan coreModels.PipelinePlan,
bpScopes []*coreModels.BlueprintScope,
connectionId uint64,
- syncPolicy *coreModels.BlueprintSyncPolicy,
+ syncPolicy *coreModels.SyncPolicy,
) (coreModels.PipelinePlan, errors.Error) {
for i, bpScope := range bpScopes {
stage := plan[i]
diff --git a/backend/plugins/circleci/impl/impl.go
b/backend/plugins/circleci/impl/impl.go
index 225ecb324..27b58dcb3 100644
--- a/backend/plugins/circleci/impl/impl.go
+++ b/backend/plugins/circleci/impl/impl.go
@@ -89,9 +89,9 @@ func (p Circleci) SubTaskMetas() []plugin.SubTaskMeta {
func (p Circleci) MakeDataSourcePipelinePlanV200(
connectionId uint64,
scopes []*coreModels.BlueprintScope,
- syncPolicy coreModels.BlueprintSyncPolicy,
+ syncPolicy *coreModels.SyncPolicy,
) (pp coreModels.PipelinePlan, sc []plugin.Scope, err errors.Error) {
- return api.MakeDataSourcePipelinePlanV200(p.SubTaskMetas(),
connectionId, scopes, &syncPolicy)
+ return api.MakeDataSourcePipelinePlanV200(p.SubTaskMetas(),
connectionId, scopes, syncPolicy)
}
func (p Circleci) PrepareTaskData(taskCtx plugin.TaskContext, options
map[string]interface{}) (interface{}, errors.Error) {