This commit is contained in:
Виктор Гладких 2019-11-08 11:42:40 +03:00
parent 251d29c461
commit be0412ffae

View File

@ -11,27 +11,17 @@ class Command(BaseCommand):
def account_sql(self):
with connections['legacy'].cursor() as cursor:
cursor.execute('''
select REPLACE(p.image_url, 'original.png', p.attachment_file_name) as image_url,
p.attachment_file_name,
p.account_id
from
(
select
REPLACE(
REPLACE(t.url, 'original.jpg', t.attachment_file_name),
'original.jpeg', t.attachment_file_name
) as image_url,
t.attachment_file_name,
t.account_id
from
(
select a.account_id, a.attachment_file_name,
LOWER(trim(CONCAT(u.url, a.attachment_suffix_url))) as url
from account_pictures a,
(select 'https://s3.eu-central-1.amazonaws.com/gm-test.com/media/' url) u
) t
) p
''')
select
url as image_url,
t.account_id
from
(
select a.account_id, a.attachment_file_name,
trim(CONCAT(u.url, a.attachment_suffix_url)) as url
from account_pictures a,
(select 'https://s3.eu-central-1.amazonaws.com/gm-test.com/media/' as url) u
) t
''')
return namedtuplefetchall(cursor)
def handle(self, *args, **kwargs):