Skip to content

Commit c94e0b3

Browse files
committed
feat: check bot
1 parent abae761 commit c94e0b3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn format_event_module(event: Event) -> Option<EventTableStruct> {
299299
payload: (!get_env_bool("FILTER_OUT_PAYLOAD"))
300300
.then(|| serde_json::to_string(&event.payload).unwrap_or_default())
301301
.unwrap_or_else(|| "{}".to_string()),
302-
abnormal: check_bot,
302+
abnormal: if check_bot { 1 } else { 0 },
303303
created_at: event.created_at,
304304
})
305305
}

src/db.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct EventTableStruct {
2727
pub event_type: String,
2828
pub payload: String,
2929
pub body: Option<String>,
30-
pub abnormal: bool,
30+
pub abnormal: i32,
3131
pub created_at: DateTime<Utc>,
3232
}
3333

@@ -97,15 +97,15 @@ impl EventTableStruct {
9797
for chunk in events.chunks(chunk_size).filter(|c| !c.is_empty()) {
9898
let sql = "INSERT INTO data.events (
9999
id, actor_id, actor_login, repo_id, repo_name, org_id, org_login,
100-
event_type, payload, body, created_at
100+
event_type, payload, body, abnormal,created_at
101101
)
102102
SELECT * FROM unnest(
103103
$1::bigint[], $2::bigint[], $3::text[], $4::bigint[], $5::text[],
104104
$6::bigint[], $7::text[], $8::text[], $9::json[], $10::text[],
105-
$11::timestamptz[]
105+
$11::integer[], $12::timestamptz[]
106106
) AS t(
107107
id, actor_id, actor_login, repo_id, repo_name, org_id, org_login,
108-
event_type, payload, body, created_at
108+
event_type, payload, body, abnormal, created_at
109109
)
110110
ON CONFLICT (id, created_at) DO NOTHING";
111111

@@ -120,6 +120,7 @@ impl EventTableStruct {
120120
.bind(Self::vec(chunk, |data| data.event_type.clone()))
121121
.bind(Self::vec(chunk, |data| data.payload.clone()))
122122
.bind(Self::vec(chunk, |data| data.body.clone()))
123+
.bind(Self::vec(chunk, |data| data.abnormal))
123124
.bind(Self::vec(chunk, |data| data.created_at))
124125
.execute(&db_pool()?)
125126
.await?;

0 commit comments

Comments
 (0)