Commit 50db9f8c by mercymodest

feat: add SQL script for Google Calendar notification statistics query

parent 6fac0ce3
# 表结构
# 表结构
# create table t_google_calendar_notification
# (
# id bigint not null comment 'ID'
# primary key,
# channel_id varchar(200) not null comment 'X-Goog-Channel-ID %d-%d deviceId#thirdPartyCalendarAuthId',
# device_id bigint null comment 'device id',
# third_party_calendar_auth_id bigint null comment 'thirdPartyCalendarAuthId',
# resource_id varchar(200) not null comment 'Google Resource ID calendarId',
# resource_state varchar(32) not null comment 'Resource State',
# message_number bigint not null comment 'Message Number',
# resource_uri varchar(512) not null comment 'Resource URI',
# token varchar(256) null comment 'Channel Token',
# expiration varchar(50) null comment 'Channel Expiration',
# is_handled tinyint default 0 not null comment 'Is Handled (0: No, 1: Yes)',
# cost int null comment '消耗时间(单位:毫秒)',
# handle_time datetime null comment 'Handle Time',
# is_exception tinyint default 0 not null comment 'Is Exception (0: No, 1: Yes)',
# exception_message text null comment 'Exception Message',
# create_time datetime default CURRENT_TIMESTAMP not null comment 'Create Time'
# )
# comment 'Google Calendar Notification' charset = utf8mb4;
#
# create index idx_channel_id_resource_id
# on t_google_calendar_notification (channel_id, resource_id);
#
# create index idx_create_time
# on t_google_calendar_notification (create_time);
#
# create index idx_device_id_third_party_calendar_auth_id
# on t_google_calendar_notification (device_id, third_party_calendar_auth_id);
#
# create index idx_third_party_calendar_auth_id
# on t_google_calendar_notification (third_party_calendar_auth_id);
#
## 以当前时间为基准,查询过去24小时(create_time)且 resource_state = 'exists' cost 100 到记录
SELECT *
FROM t_google_calendar_notification
WHERE create_time >= NOW() - INTERVAL 24 HOUR
AND resource_state = 'exists'
ORDER BY cost DESC
LIMIT 500;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment