Skip to content

Commit

Permalink
Merge pull request #76 from taichanNE30/develop
Browse files Browse the repository at this point in the history
Prod 2023-07-28
  • Loading branch information
tai-cha authored Jul 27, 2023
2 parents 09d96e1 + 96d8b8f commit 740228a
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
build-script.sh
Dockerfile
docker-compose.yml
render.yml

node_modules
dist
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pnpm
- default "334観測中"

### POST_DISABLED
- 何か値を設定するとMisskeyにノートが投稿されなくなります
- 値を`TRUE`に設定するとMisskeyにノートが投稿されなくなります
- 手元で集計のみ行いたい場合等にお使いください

## etc..
Expand All @@ -98,6 +98,7 @@ pnpm
## Docker-Composeを用いた構築
この方法ではデータベースも同時に用意可能です
### 公式イメージを用いる場合
※こちらも参考にしてください( https://github.com/taichanNE30/yamag-docker-compose-example )
1. 適当なディレクトリを作成します
1. リポジトリ内のenv_templatesを参考に`.env.app`, `.env.db`を作成します
1. 以下のdocker-compose.ymlを作成します
Expand Down
71 changes: 71 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
services:
- type: cron
name: yamag-blueprint-note
runtime: node
schedule: "35 18 * * *"
region: singapore
repo: https://github.com/taichanne30/yamag.git
buildCommand: "bash build-script.sh"
startCommand: "pnpm start"
envVars:
- key: DATABASE_URL
fromDatabase:
name: yamag-blueprint-db
property: connectionString
- fromGroup: yamag-blueprint-settings
- type: cron
name: yamag-blueprint-remind
runtime: node
schedule: "32 18 * * *"
region: singapore
repo: https://github.com/taichanne30/yamag.git
buildCommand: "bash build-script.sh"
startCommand: "pnpm run remind"
envVars:
- fromGroup: yamag-blueprint-settings
- type: worker
name: yamag-blueprint-mention
runtime: node
region: singapore
repo: https://github.com/taichanne30/yamag.git
buildCommand: "bash build-script.sh"
startCommand: "pnpm run mentions"
envVars:
- key: DATABASE_URL
fromDatabase:
name: yamag-blueprint-db
property: connectionString
- fromGroup: yamag-blueprint-settings

databases:
- name: yamag-blueprint-db
databaseName: yamag
region: singapore
plan: starter
ipAllowList:
- source: 0.0.0.0/0
description: everywhere

envVarGroups:
- name: yamag-blueprint-settings
envVars:
- key: TZ
sync: false
- key: RECORD_HOUR
sync: false
- key: RECORD_MINUTE
sync: false
- key: MATCHER
sync: false
- key: USER_NAME
sync: false
- key: POST_TITLE
sync: false
- key: REMIND_POST_TEXT
sync: false
- key: SERVER_ORIGIN
sync: false
- key: SERVER_TOKEN
sync: false
- key: POST_DISABLED
sync: false
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,29 @@ const getNotes = async ():Promise<Array<Note>> => {
['public', 'home'].includes(note.visibility) &&
note.user.host === null
})
console.log(`対象のノート: ${filteredNotes.length}件`)
let ranking = createRanks(filteredNotes)
let text = showRanking(ranking)
let post = await retry(async() => {
YAMAG.Misskey.postNote(text)
console.log("ランキング集計完了\n")
console.log(text)

await retry(async() => {
return await YAMAG.Misskey.postNote(text)
}, {
retries: 15,
minTimeout: 5000,
onRetry: (err, num)=> {
console.log(`Retrying: note posting...${num}`)
console.debug(err)
}
}).then(async n => {
console.log('投稿完了')
}).catch(err => {
console.log("ノート投稿の失敗が既定の回数を超えました")
console.log(err)
})
if (Config.isDbEnabled()) {
storeRanks(ranking)
console.log('DBに結果を保存しました')
}
})()

0 comments on commit 740228a

Please sign in to comment.