Skip to content

Commit

Permalink
feat(sql_crud): add option to filter operations
Browse files Browse the repository at this point in the history
  • Loading branch information
zieka committed Aug 21, 2023
1 parent f8b9fbc commit 4527362
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 3 additions & 1 deletion moderne_visualizations_misc/cobol_relationships.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"outputs": [],
"source": [
"node_shape: str = \"ellipse\"\n",
"filter_resources_related_to: str = \"\"\n"
"filter_resources_related_to: str = \"\""
]
},
{
Expand Down Expand Up @@ -106,12 +106,14 @@
" ),\n",
" )\n",
"\n",
"\n",
"def makeNode(resource, type):\n",
" if isinstance(resource, str) and isinstance(type, str):\n",
" return resource + \" \" + type\n",
" else:\n",
" return resource\n",
"\n",
"\n",
"def makeLabel(action, actionMetadata):\n",
" if isinstance(actionMetadata, str):\n",
" return action + \" \" + f\"({actionMetadata})\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"outputs": [],
"source": [
"filter_resources_related_to: str = \"\"\n"
"filter_resources_related_to: str = \"\""
]
},
{
Expand Down
6 changes: 6 additions & 0 deletions moderne_visualizations_misc/specs/sql_crud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ displayName: SQL operation usage in code
description: This report shows the SQL operation usages across the projects. It is a good way to understand the SQL usage patterns and identify call sites.
recipe: org.openrewrite.sql.FindSql
dataTable: org.openrewrite.sql.table.DatabaseColumnsUsed
options:
- filter_operations_to:
displayName: Filter to specific operations
description: >
Enter the name of the operation you want to subset the data table to.
required: false
17 changes: 17 additions & 0 deletions moderne_visualizations_misc/sql_crud.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"filter_operations_to: list[str] = []"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -11,6 +24,10 @@
"from code_data_science import data_table as dt, data_grid as moderne_data_grid\n",
"\n",
"df = dt.read_csv(\"../samples/sql_crud.csv\")\n",
"\n",
"if len(filter_operations_to) > 0:\n",
" df = df[df[\"operation\"].isin(filter_operations_to)]\n",
"\n",
"df = df.rename(\n",
" columns={\n",
" \"repositoryOrigin\": \"Origin\",\n",
Expand Down

0 comments on commit 4527362

Please sign in to comment.