Skip to content

Commit

Permalink
add get element group by project
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Sep 10, 2024
1 parent 26d510c commit d5e965d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
59 changes: 59 additions & 0 deletions APSToolkitPython/src/aps_toolkit/AECDataModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,62 @@ def get_folders(self, project_id: str) -> pd.DataFrame:
result = self.execute_query_variables(data['query'], data['variables'])
folders = result['data']['foldersByProject']['results']
return pd.json_normalize(folders)

def get_element_group_by_project(self, projectId: str) -> pd.DataFrame:
"""
Get element groups by project, return source file urn and version urn in alternativeIdentifiers
:param projectId:
:return:
"""
data = {
"query": """
query GetElementGroupsByProject($projectId: ID!) {
elementGroupsByProject(projectId: $projectId) {
pagination {
cursor
}
results{
name
id
version{
versionNumber
createdOn
createdBy{
id
userName
firstName
lastName
email
lastModifiedOn
createdOn
}
}
createdOn
lastModifiedBy{
id
userName
firstName
lastName
email
lastModifiedOn
}
alternativeIdentifiers{
fileUrn
fileVersionUrn
}
parentFolder{
id
name
objectCount
}
}
}
}
""",
"variables": {
"projectId": projectId
}
}
result = self.execute_query_variables(data['query'], data['variables'])
item_versions = result['data']['elementGroupsByProject']['results']
return pd.json_normalize(item_versions)
4 changes: 4 additions & 0 deletions APSToolkitPython/src/test/test_aec_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def test_get_folders(self):
result = self.aec_data_model.get_folders(self.project_id)
self.assertIsNotNone(result)

def test_get_element_group_by_project(self):
result = self.aec_data_model.get_element_group_by_project(self.project_id)
self.assertIsNotNone(result)

def test_version_group_by_project(self):
query = """
query GetElementGroupsByProject($projectId: ID!) {
Expand Down

0 comments on commit d5e965d

Please sign in to comment.