Skip to content

Commit

Permalink
Merge pull request #347 from gitnnolabs/dynamic_interface_components
Browse files Browse the repository at this point in the history
Melhorias na interface do gráfico.
  • Loading branch information
gitnnolabs authored Sep 13, 2024
2 parents 595f108 + 9d89c93 commit 5cdb335
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 155 deletions.
38 changes: 33 additions & 5 deletions article/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
apc = indexes.CharField(model_attr="apc", null=True)

# control fields
record_type = indexes.CharField(null=False)
# record_type = indexes.CharField(null=False)
record_status = indexes.CharField(null=True)

# Foreign key field
Expand All @@ -58,6 +58,18 @@ class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
states = indexes.MultiValueField(null=True)
regions = indexes.MultiValueField(null=True)

# Universe
universe = indexes.MultiValueField(null=True)

# Scope
scope = indexes.MultiValueField(null=True)

# Database
database = indexes.MultiValueField(null=True)

# Graphs
graphs = indexes.MultiValueField(null=True)

text = indexes.CharField(document=True, use_template=True)

# control fields
Expand Down Expand Up @@ -103,8 +115,25 @@ def prepare_creator(self, obj):
def prepare_updated_by(self, obj):
return obj.updated_by

def prepare_record_type(self, obj):
return "article"
# def prepare_record_type(self, obj):
# return "article"

def prepare_universe(self, obj):
return ["brazil"]

def prepare_scope(self, obj):
return ["document"]

def prepare_database(self, obj):
return ["ocabr+openalex"]

def prepare_graphs(self, obj):
return [
"thematic_level_0",
"open_access_status",
"license",
"is_oa",
]

def prepare_record_status(self, obj):
return "No Publisher"
Expand All @@ -129,7 +158,6 @@ def prepare_type(self, obj):
return k
return "others"


def _prepare_contributors(self, contributors):

if contributors:
Expand Down Expand Up @@ -244,4 +272,4 @@ def get_model(self):
return models.Article

def index_queryset(self, using=None):
return self.get_model().objects.all()
return self.get_model().objects.filter(year=2020)
32 changes: 29 additions & 3 deletions education_directory/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EducationIndex(indexes.SearchIndex, indexes.Indexable):
"""

# Common fields between directory and article
record_type = indexes.CharField(null=False)
# record_type = indexes.CharField(null=False)
record_status = indexes.CharField(model_attr="record_status", null=True)
institutions = indexes.MultiValueField(null=True)
cities = indexes.MultiValueField(null=True)
Expand Down Expand Up @@ -49,6 +49,18 @@ class EducationIndex(indexes.SearchIndex, indexes.Indexable):
model_attr="institutional_contribution", null=True
)

# Universe
universe = indexes.MultiValueField(null=True)

# Scope
scope = indexes.MultiValueField(null=True)

# Database
database = indexes.MultiValueField(null=True)

# Graphs
graphs = indexes.MultiValueField(null=True)

# control fields
created = indexes.CharField(null=False)
updated = indexes.CharField(null=False)
Expand All @@ -74,8 +86,22 @@ def prepare_updated(self, obj):
def prepare_creator(self, obj):
return obj.creator

def prepare_record_type(self, obj):
return "directory"
# def prepare_record_type(self, obj):
# return "directory"

def prepare_universe(self, obj):
return ["Brazil"]

def prepare_scope(self, obj):
return ["education_directory"]

def prepare_database(self, obj):
return ["ocabr"]

def prepare_graphs(self, obj):
return [
"thematic_level_0",
]

def prepare_directory_type(self, obj):
return "education_directory"
Expand Down
32 changes: 29 additions & 3 deletions event_directory/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class EventIndex(indexes.SearchIndex, indexes.Indexable):
"""

# Common fields between directory and article
record_type = indexes.CharField(null=False)
# record_type = indexes.CharField(null=False)
record_status = indexes.CharField(model_attr="record_status", null=True)
cities = indexes.MultiValueField(null=True)
states = indexes.MultiValueField(null=True)
Expand Down Expand Up @@ -49,6 +49,18 @@ class EventIndex(indexes.SearchIndex, indexes.Indexable):
model_attr="institutional_contribution", null=True
)

# Universe
universe = indexes.MultiValueField(null=True)

# Scope
scope = indexes.MultiValueField(null=True)

# Database
database = indexes.MultiValueField(null=True)

# Graphs
graphs = indexes.MultiValueField(null=True)

# control fields
created = indexes.CharField(null=False)
updated = indexes.CharField(null=False)
Expand All @@ -74,8 +86,22 @@ def prepare_updated(self, obj):
def prepare_creator(self, obj):
return obj.creator

def prepare_record_type(self, obj):
return "directory"
# def prepare_record_type(self, obj):
# return "directory"

def prepare_universe(self, obj):
return ["Brazil"]

def prepare_scope(self, obj):
return ["event_directory"]

def prepare_database(self, obj):
return ["ocabr"]

def prepare_graphs(self, obj):
return [
"thematic_level_0",
]

def prepare_directory_type(self, obj):
return "event_directory"
Expand Down
12 changes: 12 additions & 0 deletions index/ocabr/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@
<field name="thematic_level_1" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="thematic_level_2" type="string" indexed="true" stored="true" multiValued="true"/>

<!-- Universe -->
<field name="universe" type="string" indexed="true" stored="true" multiValued="true"/>

<!-- Scope -->
<field name="scope" type="string" indexed="true" stored="true" multiValued="true"/>

<!-- Database -->
<field name="database" type="string" indexed="true" stored="true" multiValued="true"/>

<!-- graphs -->
<field name="graphs" type="string" indexed="true" stored="true" multiValued="true"/>

<!-- Dynamic field definitions -->
<dynamicField name="*" type="text" indexed="true" stored="true" multiValued="false"/>
<!-- <dynamicField name="*" type="ignored" /> -->
Expand Down
4 changes: 4 additions & 0 deletions index/ocabr/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@
<lst name="invariants">
<str name="facet">true</str>

<str name="facet.field">universe</str>
<str name="facet.field">scope</str>
<str name="facet.field">graphs</str>
<str name="facet.field">database</str>
<str name="facet.field">directory_type</str>
<str name="facet.field">record_type</str>
<str name="facet.field">type</str>
Expand Down
13 changes: 7 additions & 6 deletions indicator/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ def get_facet(self, facet_name, result=None, convert_dict=True, sort=True):

facet = result.facets.get("facet_fields").get(facet_name)

if convert_dict:
return (
dict(sorted(self._convert_list_dict(facet).items())) if sort else facet
)
else:
return facet
if facet:
if convert_dict:
return (
dict(sorted(self._convert_list_dict(facet).items())) if sort else facet
)
else:
return facet

def update_filters(self, filter_dict):
"""This update the self.filters, this check if exists default filter and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.1.6 on 2024-09-13 10:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("indicator", "0024_indicatordata"),
]

operations = [
migrations.AddField(
model_name="indicatorfile",
name="description",
field=models.TextField(
blank=True, max_length=1024, null=True, verbose_name="Descrição"
),
),
migrations.AddField(
model_name="indicatorfile",
name="label",
field=models.CharField(
blank=True, max_length=1024, null=True, verbose_name="Label"
),
),
]
3 changes: 3 additions & 0 deletions indicator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ class IndicatorFile(models.Model):
"""

name = models.CharField(_("File name"), max_length=1024, null=False, blank=False)
label = models.CharField(_("Label"), max_length=1024, null=True, blank=True)
description = models.TextField(_("Descrição"), max_length=1024, null=True, blank=True)
raw_data = models.FileField(_("JSONL Zip File"), null=True, blank=True)
is_dynamic_data = models.BooleanField(
_("Dynamic Data"), default=False, null=True, blank=True
)

autocomplete_search_field = "name"

def extension(self):
Expand Down
34 changes: 31 additions & 3 deletions infrastructure_directory/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InfraStructureIndex(indexes.SearchIndex, indexes.Indexable):


# Common fields between directory and article
record_type = indexes.CharField(null=False)
# record_type = indexes.CharField(null=False)
record_status = indexes.CharField(model_attr="record_status", null=True)
institutions = indexes.MultiValueField(null=True)
cities = indexes.MultiValueField(null=True)
Expand Down Expand Up @@ -51,6 +51,20 @@ class InfraStructureIndex(indexes.SearchIndex, indexes.Indexable):
model_attr="institutional_contribution", null=True
)

# Universe
universe = indexes.MultiValueField(null=True)

# Scope
scope = indexes.MultiValueField(null=True)

# Database
database = indexes.MultiValueField(null=True)

# Graphs
graphs = indexes.MultiValueField(null=True)

type = indexes.CharField(null=True)

# control fields
created = indexes.CharField(null=False)
updated = indexes.CharField(null=False)
Expand All @@ -69,8 +83,22 @@ def prepare_updated(self, obj):
def prepare_creator(self, obj):
return obj.creator

def prepare_record_type(self, obj):
return "directory"
# def prepare_record_type(self, obj):
# return "directory"

def prepare_universe(self, obj):
return ["Brazil"]

def prepare_scope(self, obj):
return ["infrastructure_directory"]

def prepare_database(self, obj):
return ["ocabr"]

def prepare_graphs(self, obj):
return [
"thematic_level_0",
]

def prepare_directory_type(self, obj):
return "infrastructure_directory"
Expand Down
33 changes: 29 additions & 4 deletions policy_directory/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PolicyIndex(indexes.SearchIndex, indexes.Indexable):
"""

# Common fields between directory and article
record_type = indexes.CharField(null=False)
# record_type = indexes.CharField(null=False)
record_status = indexes.CharField(model_attr="record_status", null=True)
institutions = indexes.MultiValueField(null=True)
cities = indexes.MultiValueField(null=True)
Expand Down Expand Up @@ -42,7 +42,18 @@ class PolicyIndex(indexes.SearchIndex, indexes.Indexable):
institutional_contribution = indexes.CharField(
model_attr="institutional_contribution", null=True
)

# Universe
universe = indexes.MultiValueField(null=True)

# Scope
scope = indexes.MultiValueField(null=True)

# Database
database = indexes.MultiValueField(null=True)

# Graphs
graphs = indexes.MultiValueField(null=True)

# control fields
created = indexes.CharField(null=False)
updated = indexes.CharField(null=False)
Expand All @@ -65,8 +76,22 @@ def prepare_updated(self, obj):
def prepare_creator(self, obj):
return obj.creator

def prepare_record_type(self, obj):
return "directory"
# def prepare_record_type(self, obj):
# return "directory"

def prepare_universe(self, obj):
return ["Brazil"]

def prepare_scope(self, obj):
return ["policy_directory"]

def prepare_database(self, obj):
return ["ocabr"]

def prepare_graphs(self, obj):
return [
"thematic_level_0",
]

def prepare_directory_type(self, obj):
return "policy_directory"
Expand Down
Loading

0 comments on commit 5cdb335

Please sign in to comment.