-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
timqian
committed
Jul 11, 2019
1 parent
f65bbff
commit 30302ca
Showing
6 changed files
with
41 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/db.sqlite | ||
/secret.json | ||
/scripts/sampleJsons/ | ||
|
||
# Logs | ||
logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
!.next | ||
*.md | ||
/bots | ||
/scripts | ||
/bots/ | ||
/scripts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const abc = require('./abc.json'); | ||
const { add } = require('../db/Topics'); | ||
|
||
async function batchInsertSlackMsgs(msgs) { | ||
// filter out channel_join msgs and thread replies | ||
const validMsgs = msgs.filter(msg => msg.thread_ts && msg.replies); | ||
|
||
|
||
// reverse order | ||
for (let i = validMsgs.length - 1; i >= 0; i -= 1) { | ||
const msg = validMsgs[i]; | ||
console.log(msg, 'msg'); | ||
await add({ | ||
groupName: 't9tio', | ||
title: msg.text, | ||
type: 'slack', | ||
ts: msg.ts, | ||
from: msg.user, | ||
date: Number(msg.ts.split('.')[0]) * 1000, | ||
}); | ||
} | ||
} | ||
|
||
batchInsertSlackMsgs(abc.messages); |