/** * 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'] ); } } } } } } } } SQL質問集 – Raqqa

SQL質問集

1) 顧客一覧(fact.res.partner)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “有効な顧客を20件見せて。顧客ID、顧客名、メールアドレスを表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:5]}’

2) 顧客別案件件数(fact.res.partner × fact.opportunity)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “顧客別の案件件数を多い順に10件見せて。顧客名と案件件数を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

3) 案件一覧(fact.opportunity)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “直近に更新された案件を10件見せて。案件ID、案件名、ステージ、期待売上、更新日時を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

4) 期待売上上位案件(fact.opportunity)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “期待売上が高い案件を上位10件見せて。案件名、担当ID、ステージ、期待売上を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

5) ステージ別集計(fact.opportunity)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “ステージ別の案件数と期待売上合計を見せて。期待売上合計が大きい順に表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

6) 期間別推移(fact.period × fact.opportunity)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “期間別の案件件数と期待売上合計を新しい期間順に10件見せて。期間ID、案件件数、期待売上合計を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

7) 担当別案件集計(fact.sales.rep × fact.opportunity)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “担当別の案件件数と期待売上合計を多い順に10件見せて。担当ID、担当者名、案件件数、期待売上合計を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

8) 高確度シグナル(fact.proposal.signal)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “自己確度が高いシグナルを10件見せて。案件ID、担当ID、自己確度、適合度、痛みの強さ、作成日時を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

9) メール活動集計(fact.email.event)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “案件ごとのメール活動件数を多い順に10件見せて。案件ID、メール件数、最新送信日時を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’

10) 案件結果集計(fact.opportunity.outcome)

curl -sS -X POST “$BASE_URL/analytics/query” \
-H “Content-Type: application/json” \
-H “Authorization: Bearer $DEVPORTAL_BEARER_TOKEN” \
-H “Idempotency-Key: $(uuidgen)” \
-d ‘{
“question”: “結果別の案件件数と受注金額合計を見せて。結果、案件件数、受注金額合計を表示してください。”,
“top_k”: 5,
“locale”: “ja_JP”
}’ | jq ‘{reason_code,sql,rows:(.rows // [])[0:10]}’


Comments

コメントを残す

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