You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "klesh (via GitHub)" <gi...@apache.org> on 2023/02/13 13:18:17 UTC

[GitHub] [incubator-devlake] klesh opened a new pull request, #4408: feat: jira supports timefilter by updated_date

klesh opened a new pull request, #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408

   ### Summary
   
   In order to support time filter by `UpdatedDate`, the following actions were taken:
   
   1. added `UpdatedDatedAfter` to `collector_state` as well as jira `TaskOptions` and `TaskData`
   2. `ApiCollectorStateManager.IsIncremental` was modified to take `UpdatedDateAfter` as the First Factor to consider, or fallback to `CreatedDateAfter` if `UpdatedDateAfter` was not specified. In other words, `UpdatedDateAfter` would override the `CreatedDateAfter` option
   3. JIRA `issue_collector` was modified to follow the principle accordingly
   
   ### Does this close any open issues?
   Closes #4403
   
   ### Screenshots
   
   The initial collection, should respect the `updatedDateAfter` option
   ![1st-collection](https://user-images.githubusercontent.com/61080/218467985-7b8d286d-2365-40a3-adf9-6eb584fa4091.png)
   
   The second collection, should collect no record at all, the `_raw_table` should stay unchanged after collection
   ![2nd-diff-collection-is-working](https://user-images.githubusercontent.com/61080/218467998-8cdadc57-d1bf-4bce-a4c9-c993167ecbbd.png)
   
   Whenever an older issue got updated, it should be collected.
   ![3th-newly-updated-issues-got-collected](https://user-images.githubusercontent.com/61080/218468003-a0a2e9e6-2a0a-40ff-93a8-790598fb86ff.png)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #4408: feat: jira supports timefilter by updated_date

Posted by "likyh (via GitHub)" <gi...@apache.org>.
likyh commented on code in PR #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408#discussion_r1104487721


##########
models/migrationscripts/20230213_add_updated_date_after_to_collector_state.go:
##########
@@ -0,0 +1,48 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+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.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"time"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/helpers/migrationhelper"
+	"github.com/apache/incubator-devlake/plugins/core"
+)
+
+type collectorLatestState20230213 struct {
+	UpdatedDateAfter *time.Time

Review Comment:
   Some Api can only support created filters. Do we use it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh merged pull request #4408: feat: jira supports timefilter by updated_at

Posted by "likyh (via GitHub)" <gi...@apache.org>.
likyh merged PR #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #4408: feat: jira supports timefilter by updated_date

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408#discussion_r1104481013


##########
models/migrationscripts/20230213_add_updated_date_after_to_collector_state.go:
##########
@@ -0,0 +1,48 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+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.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"time"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/helpers/migrationhelper"
+	"github.com/apache/incubator-devlake/plugins/core"
+)
+
+type collectorLatestState20230213 struct {
+	UpdatedDateAfter *time.Time

Review Comment:
   According to Nicholas, we can not choose but follow strict semantics.
   That being said, we have to filter strictly by `updated`, not `created` in the future.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #4408: feat: jira supports timefilter by updated_date

Posted by "likyh (via GitHub)" <gi...@apache.org>.
likyh commented on code in PR #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408#discussion_r1104472948


##########
models/migrationscripts/20230213_add_updated_date_after_to_collector_state.go:
##########
@@ -0,0 +1,48 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+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.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"time"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/helpers/migrationhelper"
+	"github.com/apache/incubator-devlake/plugins/core"
+)
+
+type collectorLatestState20230213 struct {
+	UpdatedDateAfter *time.Time

Review Comment:
   I think `Since` is better because some data source can only support one of `created` or `updated` filter



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #4408: feat: jira supports timefilter by updated_date

Posted by "likyh (via GitHub)" <gi...@apache.org>.
likyh commented on code in PR #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408#discussion_r1104470725


##########
plugins/jira/tasks/issue_collector.go:
##########
@@ -58,24 +58,23 @@ func CollectIssues(taskCtx core.SubTaskContext) errors.Error {
 			Table store raw data
 		*/
 		Table: RAW_ISSUE_TABLE,
-	}, data.CreatedDateAfter)
+	}, data.CreatedDateAfter, data.UpdatedDateAfter)
 	if err != nil {
 		return err
 	}
 
 	// build jql
 	// IMPORTANT: we have to keep paginated data in a consistence order to avoid data-missing, if we sort issues by
 	//  `updated`, issue will be jumping between pages if it got updated during the collection process
-	createdDateAfter := data.CreatedDateAfter
 	jql := "created is not null ORDER BY created ASC"
-	if createdDateAfter != nil {
-		// prepend a time range criteria if `since` was specified, either by user or from database
-		jql = fmt.Sprintf("created >= '%v' AND %v", createdDateAfter.Format("2006/01/02 15:04"), jql)
-	}
 
 	incremental := collectorWithState.IsIncremental()
 	if incremental {
 		jql = fmt.Sprintf("updated >= '%v' AND %v", collectorWithState.LatestState.LatestSuccessStart.Format("2006/01/02 15:04"), jql)
+	} else if data.UpdatedDateAfter != nil {
+		jql = fmt.Sprintf("updated >= '%v' AND %v", data.UpdatedDateAfter.Format("2006/01/02 15:04"), jql)
+	} else if data.CreatedDateAfter != nil {
+		jql = fmt.Sprintf("created >= '%v' AND %v", data.CreatedDateAfter.Format("2006/01/02 15:04"), jql)

Review Comment:
   The logic changed when `isIncrement && CreatedDateAfter != nil`. It will collect the issues `issue.created < CreatedDateAfter && issue.updated > LatestSuccessStart` now but it won't before.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #4408: feat: jira supports timefilter by updated_date

Posted by "likyh (via GitHub)" <gi...@apache.org>.
likyh commented on code in PR #4408:
URL: https://github.com/apache/incubator-devlake/pull/4408#discussion_r1104470725


##########
plugins/jira/tasks/issue_collector.go:
##########
@@ -58,24 +58,23 @@ func CollectIssues(taskCtx core.SubTaskContext) errors.Error {
 			Table store raw data
 		*/
 		Table: RAW_ISSUE_TABLE,
-	}, data.CreatedDateAfter)
+	}, data.CreatedDateAfter, data.UpdatedDateAfter)
 	if err != nil {
 		return err
 	}
 
 	// build jql
 	// IMPORTANT: we have to keep paginated data in a consistence order to avoid data-missing, if we sort issues by
 	//  `updated`, issue will be jumping between pages if it got updated during the collection process
-	createdDateAfter := data.CreatedDateAfter
 	jql := "created is not null ORDER BY created ASC"
-	if createdDateAfter != nil {
-		// prepend a time range criteria if `since` was specified, either by user or from database
-		jql = fmt.Sprintf("created >= '%v' AND %v", createdDateAfter.Format("2006/01/02 15:04"), jql)
-	}
 
 	incremental := collectorWithState.IsIncremental()
 	if incremental {
 		jql = fmt.Sprintf("updated >= '%v' AND %v", collectorWithState.LatestState.LatestSuccessStart.Format("2006/01/02 15:04"), jql)
+	} else if data.UpdatedDateAfter != nil {
+		jql = fmt.Sprintf("updated >= '%v' AND %v", data.UpdatedDateAfter.Format("2006/01/02 15:04"), jql)
+	} else if data.CreatedDateAfter != nil {
+		jql = fmt.Sprintf("created >= '%v' AND %v", data.CreatedDateAfter.Format("2006/01/02 15:04"), jql)

Review Comment:
   The logic changed when `CreatedDateAfter != nil`. It will collect `issue.created< CreatedDateAfter && issue.updated> LatestSuccessStart` now but it won't before.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org