chg: [language] add thread languages stats

This commit is contained in:
terrtia 2024-03-25 16:55:20 +01:00
parent 2db54def46
commit de43f350b2
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 11 additions and 4 deletions

View file

@ -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:

View file

@ -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'])

View file

@ -115,6 +115,12 @@ class Message(AbstractObject):
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)
@ -319,9 +325,9 @@ class Message(AbstractObject):
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 -#