mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-22 22:27:17 +00:00
chg: [language] add thread languages stats
This commit is contained in:
parent
2db54def46
commit
de43f350b2
3 changed files with 11 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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 -#
|
||||
|
|
Loading…
Reference in a new issue