Skip to content

Commit

Permalink
Merge pull request #1463 from the-deep/project/reporting-module-charts
Browse files Browse the repository at this point in the history
Project/reporting module charts
  • Loading branch information
tnagorra authored Apr 26, 2024
2 parents 48b0003 + 093162a commit 0c1dc33
Show file tree
Hide file tree
Showing 14 changed files with 1,497 additions and 10 deletions.
37 changes: 37 additions & 0 deletions apps/analysis/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
AnalysisReportBorderStyleSerializer,
AnalysisReportImageContentStyleSerializer,
AnalysisReportHeadingConfigurationSerializer,
AnalysisReportHorizontalAxisSerializer,
AnalysisReportVerticalAxisSerializer,
AnalysisReportBarChartConfigurationSerializer,
AnalysisReportCategoricalLegendStyleSerializer,
AnalysisReportMapLayerConfigurationSerializer,
AnalysisReportSymbolLayerConfigurationSerializer,
AnalysisReportLineLayerStyleSerializer,
)


Expand Down Expand Up @@ -50,6 +57,26 @@
ReportEnum.ImageContentStyleFit, name='AnalysisReportImageContentStyleFitEnum')
AnalysisReportHeadingConfigurationVariantEnum = convert_enum_to_graphene_enum(
ReportEnum.HeadingConfigurationVariant, name='AnalysisReportHeadingConfigurationVariantEnum')
AnalysisReportHorizontalAxisTypeEnum = convert_enum_to_graphene_enum(
ReportEnum.HorizontalAxisType, name='AnalysisReportHorizontalAxisTypeEnum')
AnalysisReportBarChartTypeEnum = convert_enum_to_graphene_enum(
ReportEnum.BarChartType, name='AnalysisReportBarChartTypeEnum')
AnalysisReportBarChartDirectionEnum = convert_enum_to_graphene_enum(
ReportEnum.BarChartDirection, name='AnalysisReportBarChartDirectionEnum')
AnalysisReportLegendPositionEnum = convert_enum_to_graphene_enum(
ReportEnum.LegendPosition, name='AnalysisReportLegendPositionEnum')
AnalysisReportLegendDotShapeEnum = convert_enum_to_graphene_enum(
ReportEnum.LegendDotShape, name='AnalysisReportLegendDotShapeEnum')
AnalysisReportAggregationTypeEnum = convert_enum_to_graphene_enum(
ReportEnum.AggregationType, name='AnalysisReportAggregationTypeEnum')
AnalysisReportMapLayerTypeEnum = convert_enum_to_graphene_enum(
ReportEnum.MapLayerType, name='AnalysisReportMapLayerTypeEnum')
AnalysisReportScaleTypeEnum = convert_enum_to_graphene_enum(
ReportEnum.ScaleType, name='AnalysisReportScaleTypeEnum')
AnalysisReportScalingTechniqueEnum = convert_enum_to_graphene_enum(
ReportEnum.ScalingTechnique, name='AnalysisReportScalingTechniqueEnum')
AnalysisReportLineLayerStrokeTypeEnum = convert_enum_to_graphene_enum(
ReportEnum.LineLayerStrokeType, name='AnalysisReportLineLayerStrokeTypeEnum')

# Model field mapping
enum_map = {
Expand All @@ -75,5 +102,15 @@
(AnalysisReportBorderStyleSerializer, 'style', AnalysisReportBorderStyleStyleEnum),
(AnalysisReportImageContentStyleSerializer, 'fit', AnalysisReportImageContentStyleFitEnum),
(AnalysisReportHeadingConfigurationSerializer, 'variant', AnalysisReportHeadingConfigurationVariantEnum),
(AnalysisReportHorizontalAxisSerializer, 'type', AnalysisReportHorizontalAxisTypeEnum),
(AnalysisReportBarChartConfigurationSerializer, 'type', AnalysisReportBarChartTypeEnum),
(AnalysisReportBarChartConfigurationSerializer, 'direction', AnalysisReportBarChartDirectionEnum),
(AnalysisReportCategoricalLegendStyleSerializer, 'position', AnalysisReportLegendPositionEnum),
(AnalysisReportCategoricalLegendStyleSerializer, 'shape', AnalysisReportLegendDotShapeEnum),
(AnalysisReportVerticalAxisSerializer, 'aggregation_type', AnalysisReportAggregationTypeEnum),
(AnalysisReportMapLayerConfigurationSerializer, 'type', AnalysisReportMapLayerTypeEnum),
(AnalysisReportSymbolLayerConfigurationSerializer, 'scale_type', AnalysisReportScaleTypeEnum),
(AnalysisReportSymbolLayerConfigurationSerializer, 'scaling_technique', AnalysisReportScalingTechniqueEnum),
(AnalysisReportLineLayerStyleSerializer, 'stroke_type', AnalysisReportLineLayerStrokeTypeEnum),
]
})
8 changes: 8 additions & 0 deletions apps/analysis/filter_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,21 @@ def search_filter(self, qs, _, value):


class AnalysisReportUploadGQFilterSet(django_filters.FilterSet):
search = django_filters.CharFilter(method='search_filter')
report = IDListFilter(field_name='report')
types = MultipleInputFilter(AnalysisReportUploadTypeEnum, field_name='type')

class Meta:
model = AnalysisReportUpload
fields = []

def search_filter(self, qs, _, value):
if value:
qs = qs.filter(
models.Q(file__title__icontains=value)
).distinct()
return qs


class AnalysisReportSnapshotGQFilterSet(django_filters.FilterSet):
report = IDListFilter(field_name='report')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2024-03-06 05:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('analysis', '0012_remove_analysisreportcontainer_content_style'),
]

operations = [
migrations.AlterField(
model_name='analysisreportcontainer',
name='content_type',
field=models.SmallIntegerField(choices=[(1, 'Text'), (2, 'Heading'), (3, 'Image'), (4, 'URL'), (5, 'Timeline Chart'), (6, 'KPIs'), (7, 'Bar Chart')]),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 3.2.25 on 2024-04-26 09:14

from django.db import migrations, models


# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# analysis.migrations.0015_analysisreportcontainerdata_client_reference_id

class Migration(migrations.Migration):

replaces = [
('analysis', '0013_alter_analysisreportcontainer_content_type'),
('analysis', '0014_alter_analysisreportcontainer_content_type'),
('analysis', '0015_analysisreportcontainerdata_client_reference_id'),
('analysis', '0016_alter_analysisreportcontainer_content_type'),
('analysis', '0013_auto_20240315_0501'),
('analysis', '0017_merge_20240318_0519'),
]

dependencies = [
('analysis', '0012_remove_analysisreportcontainer_content_style'),
]

operations = [
migrations.AlterField(
model_name='analysisreportcontainer',
name='content_type',
field=models.SmallIntegerField(choices=[(1, 'Text'), (2, 'Heading'), (3, 'Image'), (4, 'URL'), (5, 'Timeline Chart'), (6, 'KPIs'), (7, 'Bar Chart')]),
),
migrations.AlterField(
model_name='analysisreportcontainer',
name='content_type',
field=models.SmallIntegerField(choices=[(1, 'Text'), (2, 'Heading'), (3, 'Image'), (4, 'URL'), (5, 'Timeline Chart'), (6, 'KPIs'), (7, 'Bar Chart'), (8, 'Map')]),
),
migrations.AddField(
model_name='analysisreportcontainerdata',
name='client_reference_id',
field=models.CharField(max_length=20),
preserve_default=False,
),
migrations.AlterField(
model_name='analysisreportcontainer',
name='content_type',
field=models.SmallIntegerField(choices=[(1, 'Text'), (2, 'Heading'), (3, 'Image'), (4, 'URL'), (5, 'Timeline Chart'), (6, 'KPIs'), (7, 'Bar Chart'), (8, 'Map'), (9, 'Line Chart')]),
),
migrations.AddField(
model_name='analyticalstatement',
name='title',
field=models.CharField(blank=True, max_length=150),
),
migrations.AddField(
model_name='topicmodelcluster',
name='title',
field=models.CharField(blank=True, max_length=150),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2024-03-08 10:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('analysis', '0013_alter_analysisreportcontainer_content_type'),
]

operations = [
migrations.AlterField(
model_name='analysisreportcontainer',
name='content_type',
field=models.SmallIntegerField(choices=[(1, 'Text'), (2, 'Heading'), (3, 'Image'), (4, 'URL'), (5, 'Timeline Chart'), (6, 'KPIs'), (7, 'Bar Chart'), (8, 'Map')]),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.17 on 2024-03-11 08:56

from django.utils.crypto import get_random_string
from django.db import migrations, models


def generate_random_reference_id():
return get_random_string(length=16)


class Migration(migrations.Migration):

dependencies = [
('analysis', '0014_alter_analysisreportcontainer_content_type'),
]

operations = [
migrations.AddField(
model_name='analysisreportcontainerdata',
name='client_reference_id',
# NOTE: This will not generate random values, we don't have much data before this migrations.
# So, for now just ignoring.
field=models.CharField(default=generate_random_reference_id, max_length=20),
preserve_default=False,
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2024-03-12 13:22

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('analysis', '0015_analysisreportcontainerdata_client_reference_id'),
]

operations = [
migrations.AlterField(
model_name='analysisreportcontainer',
name='content_type',
field=models.SmallIntegerField(choices=[(1, 'Text'), (2, 'Heading'), (3, 'Image'), (4, 'URL'), (5, 'Timeline Chart'), (6, 'KPIs'), (7, 'Bar Chart'), (8, 'Map'), (9, 'Line Chart')]),
),
]
14 changes: 14 additions & 0 deletions apps/analysis/migrations/0017_merge_20240318_0519.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.17 on 2024-03-18 05:19

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('analysis', '0013_auto_20240315_0501'),
('analysis', '0016_alter_analysisreportcontainer_content_type'),
]

operations = [
]
7 changes: 7 additions & 0 deletions apps/analysis/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ class ContentType(models.IntegerChoices):
HEADING = 2, 'Heading'
IMAGE = 3, 'Image'
URL = 4, 'URL'
TIMELINE_CHART = 5, 'Timeline Chart'
KPI = 6, 'KPIs'
BAR_CHART = 7, 'Bar Chart'
MAP = 8, 'Map'
LINE_CHART = 9, 'Line Chart'

report = models.ForeignKey(AnalysisReport, on_delete=models.CASCADE)
row = models.SmallIntegerField()
Expand All @@ -616,6 +621,8 @@ class ContentType(models.IntegerChoices):
class AnalysisReportContainerData(models.Model):
container = models.ForeignKey(AnalysisReportContainer, on_delete=models.CASCADE)
upload = models.ForeignKey(AnalysisReportUpload, on_delete=models.PROTECT)
# NOTE: This is used by client for internal references in JSON data
client_reference_id = models.CharField(max_length=20)
# Generic for now. Client will define this later
data = models.JSONField(default=dict)

Expand Down
1 change: 1 addition & 0 deletions apps/analysis/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ class Meta:
'id',
'upload', # AnalysisReportUploadType
'data', # NOTE: This is Generic for now
'client_reference_id',
)

@staticmethod
Expand Down
Loading

0 comments on commit 0c1dc33

Please sign in to comment.