Commit 98f7b78124a69fbee7cd53f419bc87bdae8a6536
1 parent
7e7c889b
przyspieszenie kopiowania aspektów
Showing
1 changed file
with
14 additions
and
8 deletions
dictionary/management/commands/import_data.py
... | ... | @@ -561,6 +561,19 @@ class ImportData(object): |
561 | 561 | else: |
562 | 562 | raise Exception('Brak szablonu dla nagłówka: %s', dict(row)) |
563 | 563 | |
564 | + def copy_aspects(self, lexeme_attrs): | |
565 | + aspect_vals = LexemeAttributeValue.objects.filter(attribute__name='aspekt') | |
566 | + aspect_avs = [] | |
567 | + for lexeme_av in lexeme_attrs: | |
568 | + if lexeme_av.attribute_value in aspect_vals: | |
569 | + crs = CrossReference.objects.filter( | |
570 | + from_lexeme__id=lexeme_av.lexeme_id, | |
571 | + type__symbol__in=('verger', 'verppas', 'verpact')) | |
572 | + for cr in crs: | |
573 | + aspect_avs.append(LexemeAV( | |
574 | + lexeme=cr.to_lexeme, attribute_value=lexeme_av.attribute_value)) | |
575 | + bulk_create(LexemeAV, aspect_avs) | |
576 | + | |
564 | 577 | def delete_and_import(self): |
565 | 578 | models = ( |
566 | 579 | TableCell, |
... | ... | @@ -645,14 +658,7 @@ class ImportData(object): |
645 | 658 | print 'importing cross-references...' |
646 | 659 | bulk_create(CrossReference, self.new_cross_references()) |
647 | 660 | print 'copying aspect values to derived lexemes...' |
648 | - aspect_vals = LexemeAttributeValue.objects.filter(attribute__name='aspekt') | |
649 | - for lexeme_av in lexeme_attrs: | |
650 | - if lexeme_av.attribute_value in aspect_vals: | |
651 | - crs = CrossReference.objects.filter( | |
652 | - from_lexeme__id=lexeme_av.lexeme_id, | |
653 | - type__symbol__in=('verger', 'verppas', 'verpact')) | |
654 | - for cr in crs: | |
655 | - lexeme_av.attribute_value.add_lexeme(cr.to_lexeme) | |
661 | + self.copy_aspects(lexeme_attrs) | |
656 | 662 | print 'importing variants...' |
657 | 663 | bulk_create(Variant, self.new_variants()) |
658 | 664 | print 'importing table templates...' |
... | ... |