|
38 | 38 | def create_json_response(data, status_code): |
39 | 39 | return Response(json.dumps(data, indent=2, sort_keys=True), mimetype='application/json'), status_code |
40 | 40 |
|
| 41 | +def get_tempolocus_request_options(): |
| 42 | + requested = request.args.get('tempolocus') == '1' |
| 43 | + holiday_profile = request.args.get('tempolocus_holiday_profile') |
| 44 | + if holiday_profile not in {'standard', 'public-worker'}: |
| 45 | + holiday_profile = 'standard' |
| 46 | + activity_signal = request.args.get('tempolocus_activity_signal') |
| 47 | + if activity_signal not in {'lack', 'peak'}: |
| 48 | + activity_signal = 'lack' |
| 49 | + return requested, holiday_profile, activity_signal |
| 50 | + |
41 | 51 | # ============ FUNCTIONS ============ |
42 | 52 |
|
43 | 53 | # ============= ROUTES ============== |
@@ -149,12 +159,20 @@ def chats_explorer_chat(): |
149 | 159 | languages = Language.get_all_languages() |
150 | 160 | translation_languages = Language.get_translation_languages() |
151 | 161 | languages_stats = chats_viewer.api_get_languages_stats('chat', instance_uuid, chat_id) |
| 162 | + tempolocus_requested, tempolocus_holiday_profile, tempolocus_activity_signal = get_tempolocus_request_options() |
| 163 | + tempolocus_predictions = {} |
| 164 | + tempolocus_holiday_predictions = {} |
| 165 | + if tempolocus_requested: |
| 166 | + tempolocus_predictions = chats_viewer.get_chat_tempolocus_predictions('chat', instance_uuid, chat_id) |
| 167 | + tempolocus_holiday_predictions = chats_viewer.get_chat_tempolocus_holiday_predictions('chat', instance_uuid, chat_id, holiday_profile=tempolocus_holiday_profile, activity_signal=tempolocus_activity_signal) |
152 | 168 | lang_endpoint = url_for('chats_explorer.chats_explorer_chat_lang') + f'?type=chat&subtype={instance_uuid}&id={chat_id}&lang=' |
153 | 169 | return render_template('chat_viewer.html', chat=chat, bootstrap_label=bootstrap_label, |
154 | 170 | ollama_enabled=images_engine.is_ollama_enabled(), |
155 | 171 | ail_tags=Tag.get_modal_add_tags(chat['id'], chat['type'], chat['subtype']), |
156 | 172 | message_id=message_id, languages_stats=languages_stats, lang_endpoint=lang_endpoint, |
157 | | - all_languages=languages, translation_languages=translation_languages, translation_target=target) |
| 173 | + tempolocus_predictions=tempolocus_predictions, tempolocus_holiday_predictions=tempolocus_holiday_predictions, |
| 174 | + tempolocus_requested=tempolocus_requested, tempolocus_holiday_profile=tempolocus_holiday_profile, |
| 175 | + tempolocus_activity_signal=tempolocus_activity_signal, all_languages=languages, translation_languages=translation_languages, translation_target=target) |
158 | 176 |
|
159 | 177 | @chats_explorer.route("chats/explorer/chat/lang", methods=['GET']) |
160 | 178 | @login_required |
@@ -510,12 +528,20 @@ def objects_user_account(): |
510 | 528 | languages = Language.get_all_languages() |
511 | 529 | translation_languages = Language.get_translation_languages() |
512 | 530 | languages_stats = chats_viewer.api_get_languages_stats('user-account', instance_uuid, user_id) |
| 531 | + tempolocus_requested, tempolocus_holiday_profile, tempolocus_activity_signal = get_tempolocus_request_options() |
| 532 | + tempolocus_predictions = {} |
| 533 | + tempolocus_holiday_predictions = {} |
| 534 | + if tempolocus_requested and not is_forum_account: |
| 535 | + tempolocus_predictions = chats_viewer.get_user_account_tempolocus_predictions(user_id, instance_uuid) |
| 536 | + tempolocus_holiday_predictions = chats_viewer.get_user_account_tempolocus_holiday_predictions(user_id, instance_uuid, holiday_profile=tempolocus_holiday_profile, activity_signal=tempolocus_activity_signal) |
513 | 537 | lang_endpoint = url_for('chats_explorer.objects_user_account_lang') + f'?subtype={instance_uuid}&id={user_id}&lang=' |
514 | 538 | account_context = 'forum' if is_forum_account else 'chat' |
515 | 539 | return render_template('user_account.html', meta=user_account, bootstrap_label=bootstrap_label, |
516 | 540 | ail_tags=Tag.get_modal_add_tags(user_account['id'], user_account['type'], user_account['subtype']), |
517 | 541 | languages_stats=languages_stats, lang_endpoint=lang_endpoint, all_languages=languages, |
518 | | - translation_languages=translation_languages, translation_target=target, |
| 542 | + tempolocus_predictions=tempolocus_predictions, tempolocus_holiday_predictions=tempolocus_holiday_predictions, |
| 543 | + tempolocus_requested=tempolocus_requested, tempolocus_holiday_profile=tempolocus_holiday_profile, |
| 544 | + tempolocus_activity_signal=tempolocus_activity_signal, translation_languages=translation_languages, translation_target=target, |
519 | 545 | account_context=account_context) |
520 | 546 |
|
521 | 547 |
|
|
0 commit comments