Skip to content

Commit

Permalink
Fix lang
Browse files Browse the repository at this point in the history
  • Loading branch information
pdonorio committed May 25, 2017
1 parent ab01b24 commit 3e7a7d4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
3 changes: 2 additions & 1 deletion operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# rethink.find_double_records()
# rethink.build_zoom(force=False)
# rethink.medium_expo_thumbnail(force=False)
rethink.some_operation()
rethink.fix_languages()
# rethink.some_operation()

#########################
# RETHINKDB 2 ELASTICSEARCH
Expand Down
54 changes: 43 additions & 11 deletions operations/rethink.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,16 @@ def check_doubles():

#################################
#################################
def check_translations():
def fix_languages():

q2 = query.get_table_query('datadocs')
for record in q2.run():
conversion = {
"francais": "français",
"latino": "latin",
"italiano": "italien"
}

q = query.get_table_query('datadocs')
for record in q.run():

if record['type'] != 'documents':
continue
Expand All @@ -251,15 +257,41 @@ def check_translations():
if len(images) < 1:
continue
image = images.pop()

# if 'translations' in image:
# x = query.get_table_query('datavalues') \
# .get(record['record']).run()
# for step in x['steps']:
# if step['step'] == 1:
# for y in step['data']:
# if y['position'] == 1:
# print(y['value'])
# break
# break

flag = False

if 'language' in image:
new = conversion.get(image['language'].lower())
image['language'] = new
if new is not None:
flag = True

if 'translations' in image:
x = query.get_table_query('datavalues').get(record['record']).run()
for step in x['steps']:
if step['step'] == 1:
for y in step['data']:
if y['position'] == 1:
print(y['value'])
break
break
tmp = {}
for language, value in image.pop('translations', {}).items():
new = conversion.get(language.lower())
tmp[new] = value
if new is not None:
flag = True
image['translations'] = tmp

if flag:
record['images'] = [image]
q.get(record['record']).replace(record).run()
# if 'translations' in image:
# print("DEBUG")
# exit(1)


def expo_operations():
Expand Down

0 comments on commit 3e7a7d4

Please sign in to comment.