Skip to content

Commit

Permalink
Merge pull request #13 from SmartReports/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
matteotolloso authored Nov 9, 2023
2 parents c850065 + 6632918 commit d46035a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions smartreport_app/kb_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

def kb_interface(params):
kpi_name = params['kpi_name'],
def kb_interface(kpi_name, params):
plot_type = params['chart_type']

# other parameters like the time period
Expand Down
11 changes: 8 additions & 3 deletions smartreport_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from django.utils.translation import gettext_lazy as _


# class ArchivedReport(models.Model):
# created = models.DateTimeField(auto_now_add=True)
# file = models.FileField(upload_to="reports/")

class UserType(models.TextChoices):
DOCTOR = 'doctor', _('Doctor')
Expand Down Expand Up @@ -124,3 +121,11 @@ class DashboardLayout(models.Model):

def __str__(self):
return self.name

class ArchivedReport(models.Model):
created = models.DateTimeField(auto_now_add=True)

template = models.ForeignKey(
ReportTemplate, related_name="archived_reports", on_delete=models.CASCADE)

file = models.FileField(upload_to="reports/")
5 changes: 3 additions & 2 deletions smartreport_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ def kpi_data(request, format=None):
params = request.query_params

# check if the parameters "kpi_name" and "user_type" are provided
if not 'kpi_name' in params or not 'user_type' in params or not 'chart_type' in params:
if not 'kpi_id' in params or not 'user_type' in params or not 'chart_type' in params:
return Response({"message": "The required parameters 'kpi_name' and 'user_type' are missing"}, status=status.HTTP_400_BAD_REQUEST)

kpi_name = Kpi.objects.get(pk=params['kpi_id']).name

if False: # enable in production
# check if the required kpi exists
Expand All @@ -95,6 +96,6 @@ def kpi_data(request, format=None):

# ask the kb for the response, the format is different depending on the kind of plot

data = kb_interface(params)
data = kb_interface(kpi_name, params)

return Response({'data' : data})

0 comments on commit d46035a

Please sign in to comment.