-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from gisce/fix-message-id-outlook
Fix strange space before Message-Id
- Loading branch information
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
migrations/5.0.23.12.0/post-0001_trim_message_id_database.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# coding=utf-8 | ||
import logging | ||
from tqdm import tqdm | ||
|
||
|
||
logger = logging.getLogger('openerp.migration.' + __name__) | ||
|
||
|
||
def up(cursor, installed_version): | ||
if not installed_version: | ||
return | ||
cursor.execute("SELECT count(id) FROM poweremail_mailbox where pem_message_id ilike ' %'") | ||
total_to_migrate = cursor.fetchone()[0] | ||
t = tqdm(total=total_to_migrate, desc='Migrating messages') | ||
remaining_to_migrate = total_to_migrate | ||
while remaining_to_migrate: | ||
cursor.execute( | ||
"UPDATE poweremail_mailbox SET pem_message_id = trim(pem_message_id) WHERE id in (" | ||
"SELECT id from poweremail_mailbox WHERE pem_message_id ilike ' %' LIMIT 1000" | ||
")" | ||
) | ||
cursor.execute("SELECT count(id) FROM poweremail_mailbox where pem_message_id ilike ' %'") | ||
remaining_to_migrate = cursor.fetchone()[0] | ||
t.update(1000) | ||
t.close() | ||
|
||
|
||
def down(cursor, installed_version): | ||
pass | ||
|
||
|
||
migrate = up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters