Skip to content

Commit

Permalink
Merge pull request #5 from openimis/feature/CM-29
Browse files Browse the repository at this point in the history
CM-29: Added generic export
  • Loading branch information
sniedzielski committed Jun 1, 2023
2 parents f3763d9 + e07527b commit 9996ef1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/openmis-module-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: pull openimis backend
run: |
rm ./openimis -rf
git clone --depth 1 --branch develop https://github.com/openimis/openimis-be_py.git ./openimis
git clone --depth 1 --branch coreMIS https://github.com/openimis/openimis-be_py.git ./openimis
- name: copy current branch
uses: actions/checkout@v2
with:
Expand Down
20 changes: 19 additions & 1 deletion social_protection/schema.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import graphene
import pandas as pd
from django.contrib.auth.models import AnonymousUser
from django.db.models import Q
from django.core.exceptions import PermissionDenied

from core.gql.export_mixin import ExportableQueryMixin

from django.utils.translation import gettext as _
from core.gql_queries import ValidationMessageGQLType
from core.schema import OrderedDjangoFilterConnectionField
Expand All @@ -28,7 +31,22 @@
import graphene_django_optimizer as gql_optimizer


class Query:
def patch_details(beneficiary_df: pd.DataFrame):
# Transform extension to DF columns
df_unfolded = pd.json_normalize(beneficiary_df['json_ext'])
# Merge unfolded DataFrame with the original DataFrame
df_final = pd.concat([beneficiary_df, df_unfolded], axis=1)
df_final = df_final.drop('json_ext', axis=1)
return df_final

class Query(ExportableQueryMixin, graphene.ObjectType):
export_patches = {
'beneficiary': [
patch_details
]
}
exportable_fields = ['beneficiary']

benefit_plan = OrderedDjangoFilterConnectionField(
BenefitPlanGQLType,
orderBy=graphene.List(of_type=graphene.String),
Expand Down

0 comments on commit 9996ef1

Please sign in to comment.