Feature #16932

Weblate staging website: improve algorithm that chooses among available suggestions

Added by intrigeri 2019-08-01 12:46:23 . Updated 2019-08-22 10:13:36 .

Status:
Resolved
Priority:
Normal
Assignee:
intrigeri
Category:
Infrastructure
Target version:
Start date:
Due date:
% Done:

0%

Feature Branch:
salsa.debian.org:/hefee/puppet-tails.git:hefee/16932-most-voted-suggestion
Type of work:
Code
Blueprint:

Starter:
Affected tool:
Translation Platform
Deliverable for:
309

Description

According to drebs’ research on Feature #11763#note-31, files/weblate/scripts/save-suggestions.py (in the puppet-tails.git repo) currently picks the oldest suggestion. Instead we would like to:

  • Pick the suggestion with most number of votes.
  • If there are several suggestions with the largest number of votes, then pick the newest one.

Subtasks


Related issues

Related to Tails - Bug #16989: Enable voting for Weblate users Resolved

History

#1 Updated by intrigeri 2019-08-01 12:47:06

@hefee, can you easily tell us how expensive this would be to implement?

#2 Updated by intrigeri 2019-08-01 14:39:01

> * If there are several suggestions with the largest number of votes, then pick the newest one.

drebs and I have tried to implement this with https://git-tails.immerda.ch/puppet-tails/commit/?id=afacf5d62f7b112a1070ed472c84ae675c24c3c7 and have prepared a test string with several suggestions (in wiki/src/sandbox.fr.po). Now building the staging website, will report back once we can see the output.

#3 Updated by intrigeri 2019-08-01 15:04:28

intrigeri wrote:
> > * If there are several suggestions with the largest number of votes, then pick the newest one.
>
> drebs and I have tried to implement this with https://git-tails.immerda.ch/puppet-tails/commit/?id=afacf5d62f7b112a1070ed472c84ae675c24c3c7 and have prepared a test string with several suggestions (in wiki/src/sandbox.fr.po). Now building the staging website, will report back once we can see the output.

It worked! :)

So the only remaining thing to evaluate here is “Pick the suggestion with most number of votes” (and only fall back to date comparison to disentangle equality there).

#4 Updated by hefee 2019-08-09 17:55:37

It should be quite simple to implement this. I expect something like 10-15min. It should be something like this. But I havn’t tested it yet. Maybe we need reverse=True, as parameters for sort or replace next() with list()[0] or list()[–1]:

<code class="diff">
--- a/files/weblate/scripts/save-suggestions.py
+++ b/files/weblate/scripts/save-suggestions.py
@@ -64,7 +64,9 @@ for i in range(len_subprojects):
         for translation in subproject.translation_set.all():
             for unit in translation.unit_set.all():
                 if unit.suggestions:
-                    s = list(unit.suggestions)[0]
+                    # Get most voted suggestion
+                    date_sorted = sorted(unit.suggestions, key=lambda i: i.timestamp))
+                    s = next(sorted(date_sorted, key=lambda i: i.get_num_votes()))
                     logger.debug("found suggestion for %s", unit)
                     # weblate/trans/models/translations.py: update_units
                     src = unit.get_source_plurals()[0]
</code>

#5 Updated by hefee 2019-08-22 10:04:35

  • Status changed from Confirmed to Needs Validation
  • Assignee set to intrigeri
  • Feature Branch set to salsa.debian.org:/hefee/puppet-tails.git:hefee/16932-most-voted-suggestion

I tested it for wiki/src/sandbox.de.po and checked that the fist translation unit is corrected set to “Dies ist ein Sandkasten. XX” (most voted suggestion)

I enabled suggestion_voting=True for the wiki/src/sandbox for this test and currently we need reviewer privileges to vote. In order to use voting in production, we need to enable votes for every user.

#6 Updated by intrigeri 2019-08-22 10:13:36

  • Status changed from Needs Validation to Resolved

Deployed!

> I enabled suggestion_voting=True for the wiki/src/sandbox for this test and currently we need reviewer privileges to vote. In order to use voting in production, we need to enable votes for every user.

OK, if you feel the current state of things is not good enough, please raise this in the discussion about workflows/permissions.

#7 Updated by hefee 2019-08-22 14:02:52

  • related to Bug #16989: Enable voting for Weblate users added