Conjunto de mudanças 6285 no repositório publico


Ignorar:
Timestamp:
02/05/2012 22:53:01 (9 anos atrás)
Autor:
seocam
Mensagem:

Merge com https://bitbucket.org/seocam/atu-colab/src/d0fa6287a857

Localização:
colab/trunk/colab/super_archives
Arquivos:
1 adicionado
2 editados

Legenda:

Não Modificado
Adicionado
Removido
  • colab/trunk/colab/super_archives/management/commands/import_emails.py

    r6216 r6285  
    134134       
    135135        subject_slug = slugify(email.subject_clean)
    136         thread = self.THREAD_CACHE.get(subject_slug)
     136        thread = self.THREAD_CACHE.get(subject_slug, {}).get(mailinglist.id)
    137137        if thread is None:
    138138            thread = Thread.objects.get_or_create(
     
    140140                subject_token=subject_slug
    141141            )[0]
    142 
    143             self.THREAD_CACHE[subject_slug] = thread
     142           
     143            if self.THREAD_CACHE.get(subject_slug) is None:
     144                self.THREAD_CACHE[subject_slug] = dict()
     145            self.THREAD_CACHE[subject_slug][mailinglist.id] = thread
    144146
    145147        thread.latest_message = email
     
    151153       
    152154        # Update last imported message into the DB
    153         mailinglist = MailingList.objects.get_or_create(name=list_name)[0]
     155        mailinglist, created = MailingList.objects.get_or_create(name=list_name)
    154156        mailinglist.last_imported_index = index
    155        
    156         # If the message is already at the database don't do anything
    157         messages = Message.objects.filter(
    158                                     message_id=email_msg.get('Message-ID'))
    159         create = False
    160         if not messages:
    161             create = True
    162         elif messages[0].thread.mailinglist.name != mailinglist.name:
    163             create = True
    164        
    165         if create:
     157       
     158        if created:
     159            # if the mailinglist is newly created it's sure that the message
     160            #   is not in the DB yet.
    166161            self.create_email(mailinglist, email_msg)
     162           
     163        else:
     164            # If the message is already at the database don't do anything
     165            try:
     166                messages = Message.objects.get(
     167                    message_id=email_msg.get('Message-ID'),
     168                    thread__mailinglist=mailinglist
     169                )
     170           
     171            except Message.DoesNotExist:
     172                self.create_email(mailinglist, email_msg)
    167173       
    168174        mailinglist.save()
  • colab/trunk/colab/super_archives/models.py

    r6215 r6285  
    8989
    9090class Thread(models.Model):
    91     class Meta:
    92         unique_together = ('subject_token', 'mailinglist')
    9391   
    9492    subject_token = models.CharField(max_length=512)
     
    10199    all_objects = models.Manager()
    102100    objects = NotSpamManager()
     101   
     102    class Meta:
     103        unique_together = ('subject_token', 'mailinglist')
    103104
    104105    def __unicode__(self):
     
    176177   
    177178    from_address = models.ForeignKey(EmailAddress, db_index=True)
    178     mailinglist = models.ForeignKey(MailingList)
    179179    thread = models.ForeignKey(Thread, null=True, db_index=True)
    180180    # RFC 2822 recommends to use 78 chars + CRLF (so 80 chars) for
     
    191191    objects = NotSpamManager()
    192192   
     193    class Meta:
     194        unique_together = ('thread', 'message_id')
     195   
    193196    def __unicode__(self):
    194197        return '(%s) %s: %s' % (self.id,
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.