Skip to content

Commit

Permalink
feat: Added content metadata tags for academy detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
IrfanUddinAhmad committed Jan 8, 2024
1 parent 3f1fbe8 commit 5a2c97c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.7 on 2024-01-08 20:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('catalog', '0037_alter_historicalcontentmetadata_options_and_more'),
('academy', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='tag',
name='content_metadata',
field=models.ManyToManyField(related_name='tags', to='catalog.contentmetadata'),
),
]
3 changes: 2 additions & 1 deletion enterprise_catalog/apps/academy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from model_utils.models import TimeStampedModel
from simple_history.models import HistoricalRecords

from enterprise_catalog.apps.catalog.models import EnterpriseCatalog
from enterprise_catalog.apps.catalog.models import ContentMetadata, EnterpriseCatalog


class Tag(models.Model):
Expand All @@ -19,6 +19,7 @@ class Tag(models.Model):
"""
title = models.CharField(max_length=255, help_text=_('Tag title'))
description = models.TextField(help_text=_('Tag description.'))
content_metadata = models.ManyToManyField(ContentMetadata, related_name='tags')

class Meta:
verbose_name = _('Tag')
Expand Down
6 changes: 4 additions & 2 deletions enterprise_catalog/apps/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ def _get_algolia_products_for_batch(
'enterprise_catalogs',
'enterprise_catalogs__academies',
'enterprise_catalogs__academies__tags',
'enterprise_catalogs__academies__tags__content_metadata',
)

# Retrieve ContentMetadata records for:
Expand Down Expand Up @@ -856,8 +857,9 @@ def _get_algolia_products_for_batch(
academy_uuids_by_key[content_key].add(str(academy.uuid))
academy_uuids_by_catalog_uuid[str(catalog.uuid)].add(str(academy.uuid))
for tag in associated_academy_tags:
academy_tags_by_key[content_key].add(str(tag.title))
academy_tags_by_catalog_uuid[str(catalog.uuid)].add(str(tag.title))
if tag.content_metadata.filter(content_key=content_key):
academy_tags_by_key[content_key].add(str(tag.title))
academy_tags_by_catalog_uuid[str(catalog.uuid)].add(str(tag.title))

# Second pass. This time the goal is to capture indirect relationships on programs:
# * For each program:
Expand Down

0 comments on commit 5a2c97c

Please sign in to comment.