PR

【10/4】MessageAPIを使用した離脱防止通知 #3698

wada opened this at 2024-09-27T14:32:50; closed

Description

opened by wada at 2024-09-27T14:32:50; updated 2024-10-08T14:37:53

概要

離脱防止通知

メッセージ用画像 #3705

ヤマダPFのMessageAPIで条件に応じてユーザにメッセージを送付
メッセージのリンクから戻ってきたユーザを記録

追加ログテーブル

CREATE TABLE `log_yamada_message_api` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_no` int(10) unsigned NOT NULL,
  `message_type` smallint(5) unsigned NOT NULL,
  `reg_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `reg_date` (`reg_date`),
  KEY `user_no` (`user_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `log_yamada_message_api_comeback` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_no` int(10) unsigned NOT NULL,
  `message_type` smallint(5) unsigned NOT NULL,
  `sent_date` date NOT NULL,
  `reg_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

cron設定

0 20 * * * ENVIRONMENT=${JR_ENV} PF=yamada ${JR_DIR}/lib/exec/tool_send_message_api.sh

テスト方法、確認した内容

ログテーブル作成
user_info,user_platformにテストデータを作成
tool_send_message_api.shを実行して、ログテーブルにデータが入るか
(誤作動を防止するため、テストではユーザが5件以上だとAPI実行しない)
各種送付条件が機能しているか
送付テストを簡略化したい場合、Yamada_messageクラスのsend_test()を実行

PF側のメッセージからゲームに入った際にログテーブルにデータが入るか

TODO

  • [x] ABテスト
  • [x] 足切り
  • [x] メッセージ調整
  • [x] 画像追加
wada add_label at 2024-09-30T08:52:28: レビュー待ち
wada change_title at 2024-09-30T08:52:38: [WIP]【10/4】MessageAPIを使用した離脱防止通知 【10/4】MessageAPIを使用した離脱防止通知

Comment

#36664 by wada at 2024-09-30T08:52:47; updated 2024-09-30T08:52:47

@kouho
レビューお願いします。

Comment

#36739 by wada at 2024-10-02T17:47:08; updated 2024-10-02T17:47:08

@kouho
> tool_send_message_api.php実行時に、
$user_nosがarrayになり、S_GetUserPlatformByUserNoMany関数の中で以下のエラーが出るので確認してみていただきたいです。

_send_message_process()内でエラーが発生していると思うので、
エラーが出た時の_send_message_process()引数の内容を教えて下さい。

wada add_label at 2024-10-02T17:47:44: コメントあり

Comment

#36741 by kouho at 2024-10-02T17:54:25; updated 2024-10-02T17:54:25

@wada
引数はこちらでした

$message_types

241002 17:52:21:tool_send_message_api.php:Array
(
)
 :array (
  0 => 11,
  1 => 12,
  2 => 13,
)

$user_no_list

241002 17:52:21:tool_send_message_api.php:Array
(
)
 :array (
  0 =>
  array (
    'user_no' => '7',
    'login_count' => '1',
    'last_login' => '1701254607',
    'team_no' => '0',
  ),
  1 =>
  array (
    'user_no' => '8',
    'login_count' => '2',
    'last_login' => '1714024955',
    'team_no' => '1',
  ),
  2 =>
  array (
    'user_no' => '9',
    'login_count' => '1',
    'last_login' => '1702261811',
    'team_no' => '4',
  ),
  3 =>
  array (
    'user_no' => '12',
    'login_count' => '2',
    'last_login' => '1714025306',
    'team_no' => '1',
  ),
  4 =>
  array (
    'user_no' => '13',
    'login_count' => '1',
    'last_login' => '1702608680',
    'team_no' => '1',
  ),
  5 =>
  array (
    'user_no' => '14',
    'login_count' => '1',
    'last_login' => '1702615069',
    'team_no' => '1',
  ),
  6 =>
  array (
    'user_no' => '15',
    'login_count' => '1',
    'last_login' => '1703049022',
    'team_no' => '0',
  ),
  7 =>
  array (
    'user_no' => '17',
    'login_count' => '1',
    'last_login' => '1708507483',
    'team_no' => '0',
  ),
  8 =>
  array (
    'user_no' => '18',
    'login_count' => '2',
    'last_login' => '1709545073',
    'team_no' => '0',
  ),
  9 =>
  array (
    'user_no' => '19',
    'login_count' => '1',
    'last_login' => '1709545422',
    'team_no' => '0',
  ),
  10 =>
  array (
    'user_no' => '23',
    'login_count' => '1',
    'last_login' => '1712300553',
    'team_no' => '7',
  ),
  11 =>
  array (
    'user_no' => '24',
    'login_count' => '4',
    'last_login' => '1717761975',
    'team_no' => '8',
  ),
  12 =>
  array (
    'user_no' => '27',
    'login_count' => '1',
    'last_login' => '1727333961',
    'team_no' => '0',
  ),
)

Comment

#36742 by wada at 2024-10-02T18:52:49; updated 2024-10-02T18:52:49

@kouho
ありがとうございます。修正しました。

Comment

#36743 by kouho at 2024-10-02T19:00:49; updated 2024-10-02T19:00:49

@wada
対応ありがとうございます。修正確認しました。

kouho delete_label at 2024-10-02T19:00:58: コメントあり
kouho add_label at 2024-10-04T09:48:51: 皇甫 LGTM

Comment

#36750 by kouho at 2024-10-04T09:49:24; updated 2024-10-04T09:49:24

@wada
確認OKです

wada merge at 2024-10-08T14:37:47: 【10/4】MessageAPIを使用した離脱防止通知
wada close at 2024-10-08T14:37:47: Close
wada delete_branch at 2024-10-08T14:37:53: yamada_api_message

commit comment

#265 by kouho at 2024-10-02T16:34:39; lib/models/Yamada_message.php / old:247 new:None
daeb9617875d64ddfb7ce21681afc91a8cf73c11

@wada
tool_send_message_api.php実行時に、
$user_nosがarrayになり、S_GetUserPlatformByUserNoMany関数の中で以下のエラーが出るので確認してみていただきたいです。

PHP ErrorException:  mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/web/jr-web/lib/SubFunc.inc on line 326
PHP Stack trace:
PHP   1. {main}() /home/web/jr-web/lib/exec/tool_send_message_api.php:0
PHP   2. lib\models\Yamada_message->send_newbie_comeback() /home/web/jr-web/lib/exec/tool_send_message_api.php:9
PHP   3. lib\models\Yamada_message->_send_message_process() /home/web/jr-web/lib/models/Yamada_message.php:90
PHP   4. S_GetUserPlatformByUserNoMany() /home/web/jr-web/lib/models/Yamada_message.php:247
PHP   5. S_quote_smart_arr() /home/web/jr-web/lib/SubFunc/SubFunc_yamada.inc:390
PHP   6. S_quote_smart() /home/web/jr-web/lib/SubFunc.inc:73
PHP   7. mysql_real_escape_string() /home/web/jr-web/lib/SubFunc.inc:64
PHP   8. mysqli_real_escape_string() /home/web/jr-web/lib/SubFunc.inc:326
PHP   9. {closure:/home/web/jr-web/lib/SubFunc/SubFunc_debug.inc:148-171}() /home/web/jr-web/lib/SubFunc.inc:326

Commit range

base7c413a1fb76c863513e5fccb22c9a3e62daa31d0
headdaeb9617875d64ddfb7ce21681afc91a8cf73c11
base branchjolly/jr-web:master
head branchjolly/jr-web:yamada_api_message

View commits

Commit details are loaded from Git when a dynamic archive server is running, or can be embedded with --include-commits.
Files changed20 filesView patch
statusfile
modifiedlib/SubFunc/SubFunc_yamada.inc
modifiedlib/class/platform/yamada/YamadaAPI.class.php
modifiedlib/class/platform/yamada/YamadaPlatformService.class.php
modifiedlib/class/platform/yamada/YamadaWithoutAPI.class.php
modifiedlib/conf/class/NewIslandConfig.class.php
addedlib/conf/class/YamadaMessageConfig.class.php
addedlib/exec/tool_send_message_api.php
addedlib/exec/tool_send_message_api.sh
addedlib/models/Yamada_message.php
modifiedlib/models/Yamada_point_pass_quest.php
addedlib/models/dao/log_yamada_message_api.php
addedlib/models/dao/log_yamada_message_api_comeback.php
modifiedlib/models/dao/user_info.php
addedpublic_html/img/pf/yamada/message/info1.jpg
addedpublic_html/img/pf/yamada/message/info2.jpg
addedpublic_html/img/pf/yamada/message/info3.jpg
addedpublic_html/img/pf/yamada/message/info4.jpg
addedpublic_html/img/pf/yamada/message/info5.jpg
addedpublic_html/img/pf/yamada/message/info6.jpg
modifiedpublic_html/index.php
Patch body is stored as a separate file to keep this page lightweight.

Review comment

#265 by kouho at 2024-10-02T16:34:39; lib/models/Yamada_message.php / old:247 new:None
daeb9617875d64ddfb7ce21681afc91a8cf73c11

@wada
tool_send_message_api.php実行時に、
$user_nosがarrayになり、S_GetUserPlatformByUserNoMany関数の中で以下のエラーが出るので確認してみていただきたいです。

PHP ErrorException:  mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/web/jr-web/lib/SubFunc.inc on line 326
PHP Stack trace:
PHP   1. {main}() /home/web/jr-web/lib/exec/tool_send_message_api.php:0
PHP   2. lib\models\Yamada_message->send_newbie_comeback() /home/web/jr-web/lib/exec/tool_send_message_api.php:9
PHP   3. lib\models\Yamada_message->_send_message_process() /home/web/jr-web/lib/models/Yamada_message.php:90
PHP   4. S_GetUserPlatformByUserNoMany() /home/web/jr-web/lib/models/Yamada_message.php:247
PHP   5. S_quote_smart_arr() /home/web/jr-web/lib/SubFunc/SubFunc_yamada.inc:390
PHP   6. S_quote_smart() /home/web/jr-web/lib/SubFunc.inc:73
PHP   7. mysql_real_escape_string() /home/web/jr-web/lib/SubFunc.inc:64
PHP   8. mysqli_real_escape_string() /home/web/jr-web/lib/SubFunc.inc:326
PHP   9. {closure:/home/web/jr-web/lib/SubFunc/SubFunc_debug.inc:148-171}() /home/web/jr-web/lib/SubFunc.inc:326