Skip to content

Commit

Permalink
Reports: add two extra rows explaining translated_wordcount in detail…
Browse files Browse the repository at this point in the history
…ed reports

Every `Translation` row with non-zero similarity can be split in two rows:
-  raw_rate * (1 - similarity) * source_wordcount
-  source_wordcount * review_rate

If we divide this payment value on current user rate we'll get a value for
translated wordcount.
  • Loading branch information
ta2-1 committed Nov 16, 2015
1 parent b22c644 commit 7cfe299
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
11 changes: 10 additions & 1 deletion pootle/apps/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,19 @@ def get_detailed_report_context(user, month):
wordcount = None

translated, reviewed = score.get_paid_wordcounts()
translated_details = {}
if translated is not None:
action = ReportActionTypes.TRANSLATION
subtotal = score.rate * translated
wordcount = translated

translated_details['raw_rate'] = score.rate - score.review_rate
translated_details['raw_translated_wordcount'] = \
score.wordcount * (1 - score.get_similarity())
translated_details['raw_subtotal'] = \
(translated_details['raw_translated_wordcount'] *
translated_details['raw_rate'])
translated_details['review_subtotal'] = \
score.wordcount * score.review_rate
if score.rate in totals['translated']:
totals['translated'][score.rate]['words'] += translated
else:
Expand Down Expand Up @@ -224,6 +232,7 @@ def get_detailed_report_context(user, month):
'subtotal': subtotal,
'wordcount': wordcount,
'source_wordcount': score.wordcount,
'translated_details': translated_details,
'creation_time': score.creation_time,
})

Expand Down
57 changes: 50 additions & 7 deletions pootle/templates/admin/detailed_reports.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@
{
font-size: 130%;
}

.subaction
{
background: #eee;
color: #999;
}

</style>
</head>
<body>
Expand All @@ -140,8 +147,8 @@ <h2>{% blocktrans with object.display_name as user %}Report for {{ user }}{% end
<thead>
<tr>
<th id="datetime">{% trans "Local server time" %} (GMT{{ utc_offset }})</th>
<th id="action">{% trans "Action" %}</th>
<th id="unit">{% trans "Unit" %}</th>
<th id="action">{% trans "Action" %}</th>
<th id="source-words">{% trans "Source words" %}</th>
<th id="similarity">{% trans "Similarity" %}</th>
<th id="words">{% trans "Words" %}</th>
Expand All @@ -156,25 +163,34 @@ <h2>{% blocktrans with object.display_name as user %}Report for {{ user }}{% end
{% if item.score %}
{% with score=item.score %}
<tr>
<td>{{ item.creation_time }}</td>
<td>{{ item.action_name }}</td>
<td {% if item.action == action_types.TRANSLATION and item.similarity != 0 %}rowspan="3"{% endif %}>{{ item.creation_time }}</td>
<td class="unit">
{% if score.submission.unit.isobsolete %}
<strike>#{{ score.submission.unit.id }}</strike>
{% else %}
<a href="{{ score.submission.unit.get_translate_url }}">#{{ score.submission.unit.id }}</a>
{% endif %}
</td>
<td class="number">{{ item.source_wordcount }}</td>
<td>{{ item.action_name }}</td>
<td class="number">
{% if score.is_similarity_taken_from_mt %}<sup>MT</sup>{% endif %}
{% if item.action == action_types.TRANSLATION and item.similarity != 0 %}
&mdash;
{% else %}
{{ item.source_wordcount }}
{% endif %}
</td>
<td class="number">
{% if item.action == action_types.TRANSLATION and item.similarity != 0 %}&mdash;{% else %}
{% if score.is_similarity_taken_from_mt %}<sup>{% trans 'MT' %}</sup>{% endif %}
{% if item.action == action_types.REVIEW %}
&mdash;
{% elif item.action == action_types.TRANSLATION or item.action == action_types.SUGGESTION %}
{% if item.similarity == 0 %}&lt; 50{% else %}{{ item.similarity|floatformat }}{% endif %}%
{% endif %}
{% endif %}{% endif %}
</td>
<td class="number">
{{ item.wordcount|floatformat:4 }}
</td>
<td class="number">{{ item.wordcount|floatformat:4 }}</td>
{% if object.rate > 0 and own_report or object.rate > 0 and admin_report %}
<td class="number">
{% if item.action != action_types.SUGGESTION %}
Expand All @@ -197,6 +213,33 @@ <h2>{% blocktrans with object.display_name as user %}Report for {{ user }}{% end
</td>
{% endif %}
</tr>
{% if item.action == action_types.TRANSLATION and item.similarity != 0 %}
<tr class="subaction">
<td rowspan="2">{% trans "Subactions" %}</td>
<td>{% trans "Raw Translation" %}</td>
<td class="number">{{ item.source_wordcount }}</td>
<td class="number">
{% if score.is_similarity_taken_from_mt %}<sup>{% trans 'MT' %}</sup>{% endif %}
{% if item.similarity == 0 %}&lt; 50{% else %}{{ item.similarity|floatformat }}{% endif %}%
</td>
<td class="number">{{ item.translated_details.raw_translated_wordcount|floatformat:4 }}</td>
{% if object.rate > 0 and own_report or object.rate > 0 and admin_report %}
<td class="number" title="{{ score.rate }} {{ object.currency }} - {{ score.review_rate }} {{ object.currency }}">{{ item.translated_details.raw_rate }} {{ object.currency }}</td>
<td class="number">{{ item.translated_details.raw_subtotal|floatformat:4 }} {{ object.currency }}</td>
{% endif %}
</tr>
<tr class="subaction">
<td>{% trans "Review" %}</td>
<td class="number">{{ item.source_wordcount }}</td>
<td class="number">&mdash;</td>
<td class="number">{{ item.source_wordcount }}</td>
{% if object.rate > 0 and own_report or object.rate > 0 and admin_report %}
<td class="number">{{ score.review_rate }} {{ object.currency }}</td>
<td class="number">{{ item.translated_details.review_subtotal|floatformat:4 }} {{ object.currency }}</td>
</td>
{% endif %}
</tr>
{% endif %}
{% endwith %}
{% else %}
{% if own_report and object.rate > 0 or admin_report and object.rate > 0 %}
Expand Down

0 comments on commit 7cfe299

Please sign in to comment.