/** * WPML compatibility functions * * @global array $duplicated_posts Array to store the posts being duplicated. * * @package Yoast\WP\Duplicate_Post * @since 3.2 */ add_action( 'admin_init', 'duplicate_post_wpml_init' ); /** * Add handlers for WPML compatibility. */ function duplicate_post_wpml_init() { if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { add_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10, 3 ); add_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10, 3 ); add_action( 'shutdown', 'duplicate_wpml_string_packages', 11 ); } } global $duplicated_posts; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: Renaming a global variable is a BC break. $duplicated_posts = []; /** * Copy post translations. * * @global SitePress $sitepress Instance of the Main WPML class. * @global array $duplicated_posts Array of duplicated posts. * * @param int $post_id ID of the copy. * @param WP_Post $post Original post object. * @param string $status Status of the new post. */ function duplicate_post_wpml_copy_translations( $post_id, $post, $status = '' ) { global $sitepress; global $duplicated_posts; remove_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10 ); remove_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10 ); $current_language = $sitepress->get_current_language(); $trid = $sitepress->get_element_trid( $post->ID ); if ( ! empty( $trid ) ) { $translations = $sitepress->get_element_translations( $trid ); $new_trid = $sitepress->get_element_trid( $post_id ); foreach ( $translations as $code => $details ) { if ( $code !== $current_language ) { if ( $details->element_id ) { $translation = get_post( $details->element_id ); if ( ! $translation ) { continue; } $new_post_id = duplicate_post_create_duplicate( $translation, $status ); if ( ! is_wp_error( $new_post_id ) ) { $sitepress->set_element_language_details( $new_post_id, 'post_' . $translation->post_type, $new_trid, $code, $current_language ); } } } } // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: see above. $duplicated_posts[ $post->ID ] = $post_id; } } /** * Duplicate string packages. * * @global array() $duplicated_posts Array of duplicated posts. */ function duplicate_wpml_string_packages() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: renaming the function would be a BC-break. global $duplicated_posts; foreach ( $duplicated_posts as $original_post_id => $duplicate_post_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. $original_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $original_post_id ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. $new_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $duplicate_post_id ); if ( is_array( $original_string_packages ) ) { foreach ( $original_string_packages as $original_string_package ) { $translated_original_strings = $original_string_package->get_translated_strings( [] ); foreach ( $new_string_packages as $new_string_package ) { $cache = new WPML_WP_Cache( 'WPML_Package' ); $cache->flush_group_cache(); $new_strings = $new_string_package->get_package_strings(); foreach ( $new_strings as $new_string ) { if ( isset( $translated_original_strings[ $new_string->name ] ) ) { foreach ( $translated_original_strings[ $new_string->name ] as $language => $translated_string ) { do_action( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. 'wpml_add_string_translation', $new_string->id, $language, $translated_string['value'], $translated_string['status'] ); } } } } } } } } フロント図 – Raqqa

フロント図

sequenceDiagram
    participant User as 自然文(ユーザ)
    participant Client as クライアント(LLMでNL→SQL)
    participant API as APIサーバ
    participant DB as Postgres/Chroma/Metabase

    User->>Client: 「過去3ヶ月の売上推移を見せて」
    Client->>Client: NL→SQL 生成(LLM)
    Client->>API: POST /nlq/plan { message: "SELECT ..." }
    API->>DB: スキーマ確認(存在/非空)+ LIMIT強制 + ガード
    API-->>Client: { candidate_sql, validated_sql, used/skipped }

    Client->>API: POST /nlq/execute { sql: validated_sql, mode, output_level }
    API->>DB: SQL実行 / マスキング / Metabaseリンク生成
    API-->>Client: { rows, stats.metabase, ... }

    Client->>API: POST /nlq/history(plan/executeを保存)
    API->>DB: nlq_history へ永続化

    Client->>API: POST /chroma/package(差分ドキュメント組立)
    API-->>Client: { ChromaPackage ... }(プレビュー or キュー投入)

    Client->>API: POST /chroma/upsert { dry_run? items? }
    API->>DB: portal_chroma_doc → Chroma upsert(idempotent)
    API-->>Client: { processed/succeeded/failed/items }

最新

sequenceDiagram
    autonumber
    participant U as User
    participant L as ChatPanel(Left)
    participant M as SqlAndResult(Middle)
    participant R as AnalysisPanel(Right)
    participant S as StepBar(Top)
    participant C as api.ts(client)
    participant A as NLQ API(8081)
    participant B as Metabase
    participant H as History
    participant X as Chroma

    U->>L: type message
    L->>C: POST /nlq/plan
    C->>A: /nlq/plan
    A-->>C: PlanResponse
    C-->>L: show candidate SQL
    C-->>M: preview SQL + hint

    U->>M: click Execute (mode, analyze_mode)
    M->>C: POST /nlq/execute
    C->>A: /nlq/execute

    alt 200 OK
        A-->>C: ExecuteResponse (rows, stats)
        C-->>S: stats.timeline update
        C-->>M: table(rows, columns, column_map)
        C-->>R: analysis
        alt metabase public
            M->>B: iframe src = stats.metabase.url
        else metabase signed
            M->>B: iframe src = stats.metabase.iframe_src
        end
        par save history (optional)
            C->>A: POST /nlq/history
            A-->>C: 202
        and chroma upsert (optional)
            C->>A: POST /chroma/package
            A-->>C: ChromaPackage(source_hash)
            C->>A: POST /chroma/upsert {items:[pkg]}
            A-->>C: UpsertResponse(ok, doc_id)
        end
    else 429 Rate Limited
        A-->>C: 429 + Retry-After
        C-->>S: mark rate_limited
        C-->>M: show countdown + retry/quick button
    else 400 Guard Error
        A-->>C: 400 {title, detail}
        C-->>S: guard note=error
        C-->>L: tip with reason
    else 500 Server Error
        A-->>C: 500
        C-->>M: snackbar + retry
    end

    U->>L: restore session
    L->>C: GET /nlq/history?session_id=...
    C->>A: /nlq/history
    A-->>C: items[], next_cursor
    C-->>L: rebuild chat list

Comments

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です