Commit 82d2c9e4 authored by Michal Čihař's avatar Michal Čihař

Track indexupdates by id

We can not use relation because of deleted units.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 136d0dc4
......@@ -53,7 +53,7 @@ class Command(BaseCommand):
for update in updates[:limit].iterator():
indexupdates.add(update.pk)
delete_search_unit(
update.unit_id,
update.unitid,
update.translation.language.code
)
......@@ -71,10 +71,10 @@ class Command(BaseCommand):
updates = IndexUpdate.objects.filter(to_delete=False)
for update in updates[:limit].iterator():
indexupdates.add(update.pk)
unit_ids.add(update.unit_id)
unit_ids.add(update.unitid)
if update.source:
source_unit_ids.add(update.unit_id)
source_unit_ids.add(update.unitid)
# Filter matching units
units = Unit.objects.filter(
......
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-02-02 12:19
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trans', '0053_auto_20160202_1145'),
]
operations = [
migrations.AddField(
model_name='indexupdate',
name='unitid',
field=models.IntegerField(default=0, unique=True),
preserve_default=False,
),
migrations.AlterField(
model_name='check',
name='check',
field=models.CharField(choices=[('end_space', 'Trailing space'), (b'inconsistent', 'Inconsistent'), ('begin_newline', 'Starting newline'), ('max-length', 'Maximum length of translation'), ('zero-width-space', 'Zero-width space'), ('escaped_newline', 'Mismatched \\n'), ('same', 'Unchanged translation'), ('end_question', 'Trailing question'), (b'angularjs_format', 'AngularJS interpolation string'), (b'python_brace_format', 'Python brace format'), ('end_newline', 'Trailing newline'), (b'c_format', 'C format'), ('end_exclamation', 'Trailing exclamation'), ('end_ellipsis', 'Trailing ellipsis'), ('end_colon', 'Trailing colon'), (b'xml-tags', 'XML tags mismatch'), (b'python_format', 'Python format'), (b'plurals', 'Missing plurals'), (b'javascript_format', 'Javascript format'), ('begin_space', 'Starting spaces'), (b'bbcode', 'Mismatched BBcode'), (b'php_format', 'PHP format'), ('end_stop', 'Trailing stop')], max_length=20),
),
]
......@@ -25,6 +25,7 @@ from django.utils.encoding import force_text, python_2_unicode_compatible
@python_2_unicode_compatible
class IndexUpdate(models.Model):
unit = models.OneToOneField('Unit')
unitid = models.IntegerField(unique=True)
source = models.BooleanField(default=True)
to_delete = models.BooleanField(default=False)
......
......@@ -195,14 +195,14 @@ def add_index_update(unit_id, source, to_delete):
try:
with transaction.atomic():
IndexUpdate.objects.create(
unit_id=unit_id,
unitid=unit_id,
source=source,
to_delete=to_delete,
)
# pylint: disable=E0712
except IntegrityError:
try:
update = IndexUpdate.objects.get(unit_id=unit_id)
update = IndexUpdate.objects.get(unitid=unit_id)
if to_delete or source:
if source:
update.source = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment