Skip to content

Commit

Permalink
add get project
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Sep 10, 2024
1 parent 13ec84b commit 7758d5e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
27 changes: 27 additions & 0 deletions APSToolkitPython/src/aps_toolkit/AECDataModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,30 @@ def get_hubs(self) -> pd.DataFrame:
result = self.execute_query(data)
hubs = result['data']['hubs']['results']
return pd.json_normalize(hubs)

def get_projects(self, hub_id: str) -> pd.DataFrame:
data = {
"query": """
query GetProjects($hubId: ID!) {
projects(hubId: $hubId) {
results {
id
name
hub {
id
name
}
alternativeIdentifiers{
dataManagementAPIProjectId
}
}
}
}
""",
"variables": {
"hubId": hub_id
}
}
result = self.execute_query(data)
projects = result['data']['projects']['results']
return pd.json_normalize(projects)
21 changes: 1 addition & 20 deletions APSToolkitPython/src/test/test_aec_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,7 @@ def test_get_hubs(self):
self.assertIsNotNone(df_result)

def test_get_projects(self):
data = {
"query": """
query GetProjects($hubId: ID!) {
projects(hubId: $hubId) {
results {
id
name
hub {
id
name
}
}
}
}
""",
"variables": {
"hubId": f"{self.hub_id}"
}
}
result = self.aec_data_model.execute_query(data)
result = self.aec_data_model.get_projects(self.hub_id)
self.assertIsNotNone(result)

def test_version_group_by_project(self):
Expand Down

0 comments on commit 7758d5e

Please sign in to comment.