Skip to content

Commit

Permalink
chg: [language] add thread languages stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Mar 25, 2024
1 parent 2db54de commit de43f35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/lib/Language.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def _get_obj_translation(obj_global_id, language, source=None, content=None, fie
translation = r_get_obj_translation(obj_global_id, language, field=field)
if not translation:
source, translation = LanguageTranslator().translate(content, source=source, target=language)
if source and translation:
if source:
obj_type, subtype, obj_id = obj_global_id.split(':', 2)
add_obj_language(source, obj_type, subtype, obj_id, objs_containers=objs_containers)
if translation:
Expand Down
1 change: 1 addition & 0 deletions bin/lib/chats_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ def api_get_thread(thread_id, thread_instance_uuid, translation_target=None, nb=
thread = ChatThreads.ChatThread(thread_id, thread_instance_uuid)
if not thread.exists():
return {"status": "error", "reason": "Unknown thread"}, 404
# print(thread.get_obj_language_stats())
meta = thread.get_meta({'chat', 'nb_messages', 'nb_participants'})
# if meta['chat']:
# meta['chat'] = get_chat_meta_from_global_id(meta['chat'])
Expand Down
12 changes: 9 additions & 3 deletions bin/lib/objects/Messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def get_subchannel(self):
if subchannel.get('chat-subchannel'):
return f'chat-subchannel:{subchannel["chat-subchannel"].pop()}'

def get_current_thread(self):
subchannel = self.get_correlation('chat-thread')
if subchannel.get('chat-thread'):
return f'chat-thread:{subchannel["chat-thread"].pop()}'

# children thread
def get_thread(self):
for child in self.get_childrens():
obj_type, obj_subtype, obj_id = child.split(':', 2)
Expand Down Expand Up @@ -319,9 +325,9 @@ def get_objs_container(self):
subchannel = self.get_subchannel()
if subchannel:
objs_containers.add(subchannel)
# thread = self.get_thread() # TODO Get current thread
# if thread:
# objs_containers.add(thread)
thread = self.get_current_thread()
if thread:
objs_containers.add(thread)
return objs_containers

#- Language -#
Expand Down

0 comments on commit de43f35

Please sign in to comment.