You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by he...@apache.org on 2023/05/02 18:08:31 UTC

[incubator-devlake] branch main updated: Fix empty tx rules patterns (#5074)

This is an automated email from the ASF dual-hosted git repository.

hez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new b09252e9f Fix empty tx rules patterns (#5074)
b09252e9f is described below

commit b09252e9f74b839b2554abcd19748556cf197937
Author: Camille Teruel <ca...@gmail.com>
AuthorDate: Tue May 2 20:08:26 2023 +0200

    Fix empty tx rules patterns (#5074)
    
    * fix: Fix wrong attr names in GitPullRequestCommit.collect
    
    * fix: connection and tx rules schemas should have camelCased prop names
    
    Move generation of camelCased aliases in ToolTable, so that connections and tx rules also get those aliases generated.
    
    ---------
    
    Co-authored-by: Camille Teruel <ca...@meri.co>
---
 .../azuredevops/streams/pull_request_commits.py      |  2 +-
 backend/python/pydevlake/pydevlake/model.py          | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/backend/python/plugins/azuredevops/azuredevops/streams/pull_request_commits.py b/backend/python/plugins/azuredevops/azuredevops/streams/pull_request_commits.py
index bb4211866..a7c42ab0e 100644
--- a/backend/python/plugins/azuredevops/azuredevops/streams/pull_request_commits.py
+++ b/backend/python/plugins/azuredevops/azuredevops/streams/pull_request_commits.py
@@ -30,7 +30,7 @@ class GitPullRequestCommits(Substream):
     def collect(self, state, context, parent: GitPullRequest) -> Iterable[tuple[object, dict]]:
         repo: GitRepository = context.scope
         azuredevops_api = AzureDevOpsAPI(context.connection)
-        response = azuredevops_api.git_repo_pull_request_commits(repo.org_id, repo.project_id, parent.repo_id, parent.id)
+        response = azuredevops_api.git_repo_pull_request_commits(repo.org_id, repo.project_id, repo.id, parent.pull_request_id)
         for raw_commit in response:
             raw_commit["pull_request_id"] = parent.domain_id()
             yield raw_commit, state
diff --git a/backend/python/pydevlake/pydevlake/model.py b/backend/python/pydevlake/pydevlake/model.py
index 51df93051..135e10c0a 100644
--- a/backend/python/pydevlake/pydevlake/model.py
+++ b/backend/python/pydevlake/pydevlake/model.py
@@ -46,6 +46,16 @@ class ToolTable(SQLModel):
         plural_entity = inflect_engine.plural_noun(cls.__name__.lower())
         return f'_tool_{plugin_name}_{plural_entity}'
 
+    class Config:
+        allow_population_by_field_name = True
+
+        @classmethod
+        def alias_generator(cls, attr_name: str) -> str:
+            # Allow to set snake_cased attributes with camelCased keyword args.
+            # Useful for extractors dealing with raw data that has camelCased attributes.
+            parts = attr_name.split('_')
+            return parts[0] + ''.join(word.capitalize() for word in parts[1:])
+
 
 class Connection(ToolTable, Model):
     name: str
@@ -118,16 +128,6 @@ class ToolModel(ToolTable, NoPKModel):
                 continue
             yield getattr(self, prop.key)
 
-    class Config:
-        allow_population_by_field_name = True
-
-        @classmethod
-        def alias_generator(cls, attr_name: str) -> str:
-            # Allow to set snake_cased attributes with camelCased keyword args.
-            # Useful for extractors dealing with raw data that has camelCased attributes.
-            parts = attr_name.split('_')
-            return parts[0] + ''.join(word.capitalize() for word in parts[1:])
-
 
 class DomainModel(NoPKModel):
     id: Optional[str] = Field(primary_key=True)