Skip to content

Commit

Permalink
Revert "Optimize tags dashboards (mozilla#3101)"
Browse files Browse the repository at this point in the history
This reverts commit 1dcd738.
  • Loading branch information
mathjazz committed Feb 23, 2024
1 parent c29e821 commit 7ab4138
Show file tree
Hide file tree
Showing 34 changed files with 1,477 additions and 515 deletions.
27 changes: 0 additions & 27 deletions pontoon/base/migrations/0053_alter_translation_index_together.py

This file was deleted.

39 changes: 19 additions & 20 deletions pontoon/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,25 +531,6 @@ class AggregatedStats(models.Model):
class Meta:
abstract = True

@classmethod
def get_chart_dict(cls, obj):
"""Get chart data dictionary"""
if obj.total_strings:
return {
"total_strings": obj.total_strings,
"approved_strings": obj.approved_strings,
"pretranslated_strings": obj.pretranslated_strings,
"strings_with_errors": obj.strings_with_errors,
"strings_with_warnings": obj.strings_with_warnings,
"unreviewed_strings": obj.unreviewed_strings,
"approved_share": round(obj.approved_percent),
"pretranslated_share": round(obj.pretranslated_percent),
"errors_share": round(obj.errors_percent),
"warnings_share": round(obj.warnings_percent),
"unreviewed_share": round(obj.unreviewed_percent),
"completion_percent": int(math.floor(obj.completed_percent)),
}

@classmethod
def get_stats_sum(cls, qs):
"""
Expand Down Expand Up @@ -1856,6 +1837,25 @@ def get_chart(cls, self, extra=None):

return chart

@classmethod
def get_chart_dict(cls, obj):
"""Get chart data dictionary"""
if obj.total_strings:
return {
"total_strings": obj.total_strings,
"approved_strings": obj.approved_strings,
"pretranslated_strings": obj.pretranslated_strings,
"strings_with_errors": obj.strings_with_errors,
"strings_with_warnings": obj.strings_with_warnings,
"unreviewed_strings": obj.unreviewed_strings,
"approved_share": round(obj.approved_percent),
"pretranslated_share": round(obj.pretranslated_percent),
"errors_share": round(obj.errors_percent),
"warnings_share": round(obj.warnings_percent),
"unreviewed_share": round(obj.unreviewed_percent),
"completion_percent": int(math.floor(obj.completed_percent)),
}

def aggregate_stats(self):
TranslatedResource.objects.filter(
resource__project=self.project,
Expand Down Expand Up @@ -3284,7 +3284,6 @@ class Meta:
("entity", "locale", "fuzzy"),
("locale", "user", "entity"),
("date", "locale"),
("approved_date", "locale"),
)
constraints = [
models.UniqueConstraint(
Expand Down
11 changes: 9 additions & 2 deletions pontoon/localizations/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
from operator import attrgetter
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db.models import Q
Expand All @@ -19,7 +20,7 @@
)
from pontoon.contributors.views import ContributorsMixin
from pontoon.insights.utils import get_insights
from pontoon.tags.utils import Tags
from pontoon.tags.utils import TagsTool


def localization(request, code, slug):
Expand Down Expand Up @@ -158,7 +159,13 @@ def ajax_tags(request, code, slug):
if not project.tags_enabled:
raise Http404

tags = Tags(project=project, locale=locale).get()
tags_tool = TagsTool(
locales=[locale],
projects=[project],
priority=True,
)

tags = sorted(tags_tool, key=attrgetter("priority"), reverse=True)

return render(
request,
Expand Down
4 changes: 0 additions & 4 deletions pontoon/projects/templates/projects/includes/teams.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
{% set locale_projects = project.available_locales_list() %}

{% for locale in locales %}
{% if not tag %}
{% set main_link = url('pontoon.projects.project', project.slug) %}
{% set chart_link = url('pontoon.translate', locale.code, project.slug, 'all-resources') %}
{% set latest_activity = locale.get_latest_activity(project) %}
{% set chart = locale.get_chart(project) %}
{% endif %}
{% if locale.code in locale_projects %}
{% set class = 'limited' %}
{% if chart %}
Expand All @@ -37,8 +35,6 @@
{% if tag %}
{% set main_link = url('pontoon.projects.project', project.slug) + '?tag=' + tag.slug %}
{% set chart_link = url('pontoon.translate', locale.code, project.slug, 'all-resources') + '?tag=' + tag.slug %}
{% set latest_activity = locale.latest_activity %}
{% set chart = locale.chart %}
{% if chart %}
{% set main_link = chart_link %}
{% endif %}
Expand Down
10 changes: 8 additions & 2 deletions pontoon/projects/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
from operator import attrgetter
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
Expand All @@ -18,7 +19,7 @@
from pontoon.contributors.views import ContributorsMixin
from pontoon.insights.utils import get_insights
from pontoon.projects import forms
from pontoon.tags.utils import Tags
from pontoon.tags.utils import TagsTool


def projects(request):
Expand Down Expand Up @@ -108,7 +109,12 @@ def ajax_tags(request, slug):
if not project.tags_enabled:
raise Http404

tags = Tags(project=project).get()
tags_tool = TagsTool(
projects=[project],
priority=True,
)

tags = sorted(tags_tool, key=attrgetter("priority"), reverse=True)

return render(
request,
Expand Down
10 changes: 0 additions & 10 deletions pontoon/tags/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from .resources import TagsResourcesTool
from .tags import TagsTool
from .tag import TagTool


__all__ = (
"TagsResourcesTool",
"TagsTool",
"TagTool",
)
2 changes: 1 addition & 1 deletion pontoon/tags/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.utils.functional import cached_property

from pontoon.base.models import Resource
from .tags import TagsTool
from pontoon.tags.utils import TagsTool


class LinkTagResourcesAdminForm(forms.Form):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pontoon/tags/templates/tags/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h1>
</ul>

{{ HeadingInfo.progress_chart() }}
{{ HeadingInfo.progress_chart_legend(tag.chart) }}
{{ HeadingInfo.progress_chart_legend(tag) }}
</div>
</section>
{% endblock %}
Expand Down
100 changes: 0 additions & 100 deletions pontoon/tags/tests/admin/test_tags.py

This file was deleted.

Loading

0 comments on commit 7ab4138

Please sign in to comment.