diff --git a/ui/README.md b/README.md similarity index 50% rename from ui/README.md rename to README.md index 37e4327..ede2765 100644 --- a/ui/README.md +++ b/README.md @@ -2,6 +2,42 @@ traQ Database viewer traQでの発言履歴,発言数,スタンプ数など"話題性"につながる指標を抽出し、traQにおける発言の傾向および勢いを分析するためのデータを提供する。 収集されたデータを見やすい形でまとめ,利用しやすい形で提供することも目標とする。 +[サーバ](./Server.md) + +## Server パッケージ構成の見直し + +## mainパッケージ(もしくはsetup) +- 実行系のスクリプト + - main.go + - cron.go(定時実行関連) + - root.go(ルーティング関連) + - record.go(アプリ内情報保持関連) + +## serviceパッケージ +- サービスそのものを書くイメージ 情報の整理,整形は基本このパッケージ + - User.go(ユーザーごと情報取得,整理) + - Channel.go + - Stamp.go + +## botパッケージ +- traQBOT関連のパッケージ + - bot.go(セットアップ関連) + - command.go(コマンド対応系) + +## dbパッケージ +- db関連パッケージ + - テーブル毎に処理を書く + - e.g.)messagecount.go + - dbセットアップもここ + +## traQAPIパッケージ +- traQAPIを叩くパッケージ + - どこまでを含めるかは要検討 + - メッセージならその取得まではこのパッケージでやりたい(serviceパッケージではこちらで定義したmodelですべて対応したい) + - ID<->displayname変換などの処理もここ + - BOTのメッセージ投稿も実際にはここにAPIを実装する(botパッケージではBotSimplePostのようなものを叩かせる) + +## 今後具体的なクラス相当の設計を考える ## やりたいこと diff --git a/Server.md b/Server.md new file mode 100644 index 0000000..a2c82de --- /dev/null +++ b/Server.md @@ -0,0 +1,3 @@ +# Server + +あああ diff --git a/server/docs/openapi.yaml b/server/docs/openapi.yaml new file mode 100644 index 0000000..6e2f6cf --- /dev/null +++ b/server/docs/openapi.yaml @@ -0,0 +1,199 @@ +openapi: 3.0.3 +info: + title: traQer + description: Information about traQ usage + version: 0.1.0 +externalDocs: + description: github + url: https://github.com/alter334/traQer + +servers: + - url: https://traqer.trap.show/ +tags: + - name: ping + description: pong + - name: user + description: ユーザ紐付き情報 + - name: channel + description: チャンネル紐付き情報 + - name: stamp + description: スタンプ紐付き情報(次ver以降で実装) + - name: me + description: 自己情報(次ver以降で実装) + +paths: + /ping: + get: + tags: + - ping + summary: 疎通を確認 + responses: + "200": + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/ping" + /user: + get: + tags: + - user + summary: 全ユーザメッセージ数取得 + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/userData" + /user/{userid}: + get: + tags: + - user + summary: ユーザ毎メッセージ数取得 + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: object + $ref: "#/components/schemas/userData" + /user/group/{groupid}: + get: + tags: + - user + summary: グループ毎メッセージ数取得 + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/userData" + /channel: + get: + tags: + - channel + summary: 全ユーザメッセージ数取得 + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/userData" + /channel/{channelid}: + get: + tags: + - channel + summary: ユーザ毎メッセージ数取得 + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: object + $ref: "#/components/schemas/userData" + + + + +components: + schemas: + ping: + type: string + example: pong + userData: + type: object + properties: + userId: + type: string + description: ユーザUUID + userName: + type: string + description: ユーザtraQID + displayName: + type: string + description: ユーザ表示名 + homeChannelId: + type: string + description: ホームチャンネルUUID + totalPostCount: + type: integer + description: 総投稿数 + dailyPostCount: + type: integer + description: 日投稿数 + + channelData: + type: object + properties: + userId: + type: string + description: チャンネルUUID + totalPostCount: + type: integer + description: 総投稿数 + dailyPostCount: + type: integer + description: 日投稿数 + # task: + # type: object + # required: + # - id + # - title + # - description + # - condition + # - difficulty + # - dueDate + # properties: + # id: + # type: integer + # example: 1 + # title: + # type: string + # example: 単位認定の申請 + # description: + # type: string + # example: スコアレポートを教務課に提出する + # condition: + # type: integer + # example: 2 + # description: タスクが出来る状況の状況ID(デフォルト=いつでもできるタスクは0) + # difficulty: + # type: integer + # example: 2 + # description: "1:気軽にできる, 2: 普通, 3: ハードルが高い" + # dueDate: + # type: string + # format: date + # example: 2021-01-01 + # tasks: + # type: array + # items: + # $ref: "#/components/schemas/task" + # condition: + # type: object + # required: + # - id + # - name + # properties: + # id: + # type: integer + # example: 1 + # name: + # type: string + # example: どこでもできる + # conditions: + # type: array + # items: + # $ref: "#/components/schemas/condition" + \ No newline at end of file diff --git a/server/handler/bot/handler.go b/server/handler/bot/handler.go new file mode 100644 index 0000000..f57594c --- /dev/null +++ b/server/handler/bot/handler.go @@ -0,0 +1,7 @@ +package bot + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +func NewBotHandler(bot *traqwsbot.Bot) *Bot { + return &Bot{bot: bot} +} diff --git a/server/handler/bot/model.go b/server/handler/bot/model.go new file mode 100644 index 0000000..3536118 --- /dev/null +++ b/server/handler/bot/model.go @@ -0,0 +1,7 @@ +package bot + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +type Bot struct { + bot *traqwsbot.Bot +} diff --git a/server/handler/db/handler.go b/server/handler/db/handler.go new file mode 100644 index 0000000..82baf01 --- /dev/null +++ b/server/handler/db/handler.go @@ -0,0 +1,7 @@ +package db + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +func NewBotHandler(bot *traqwsbot.Bot) *Bot { + return &Bot{bot: bot} +} diff --git a/server/handler/db/model.go b/server/handler/db/model.go new file mode 100644 index 0000000..44eb570 --- /dev/null +++ b/server/handler/db/model.go @@ -0,0 +1,7 @@ +package db + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +type Bot struct { + bot *traqwsbot.Bot +} diff --git a/server/handler/service/handler.go b/server/handler/service/handler.go new file mode 100644 index 0000000..3ff18f5 --- /dev/null +++ b/server/handler/service/handler.go @@ -0,0 +1,7 @@ +package service + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +func NewBotHandler(bot *traqwsbot.Bot) *Bot { + return &Bot{bot: bot} +} diff --git a/server/handler/service/model.go b/server/handler/service/model.go new file mode 100644 index 0000000..e091271 --- /dev/null +++ b/server/handler/service/model.go @@ -0,0 +1,7 @@ +package service + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +type Bot struct { + bot *traqwsbot.Bot +} diff --git a/server/handler/traqapi/handler.go b/server/handler/traqapi/handler.go new file mode 100644 index 0000000..ea98180 --- /dev/null +++ b/server/handler/traqapi/handler.go @@ -0,0 +1,7 @@ +package traqapi + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +func NewBotHandler(bot *traqwsbot.Bot) *Bot { + return &Bot{bot: bot} +} diff --git a/server/handler/traqapi/model.go b/server/handler/traqapi/model.go new file mode 100644 index 0000000..3d36efd --- /dev/null +++ b/server/handler/traqapi/model.go @@ -0,0 +1,7 @@ +package traqapi + +import traqwsbot "github.com/traPtitech/traq-ws-bot" + +type Bot struct { + bot *traqwsbot.Bot +} diff --git a/server/model.md b/server/model.md new file mode 100644 index 0000000..973dae9 --- /dev/null +++ b/server/model.md @@ -0,0 +1,51 @@ +# サーバ設計関連資料 + +## パッケージ +- [readme](../README.md)参照 + +## struct関連 +- メソッドは略 +- 各パッケージにhandler.goを用意しそこにインスタンス化を定義 model.goも用意 + +### Server +``` +type Server struct{ + bot *Bot // Bot関連 + db *DB // db関連 + service *Service // 具体的機能 + traQapi *traQapi // traqApi関連 + serverData ServerData // 保持しておくデータ +} +``` + +### ServerData +``` +type ServerData struct { + lastTrackId traq.Message // 最後に取得したメッセージ + lastTrackTime time.Time // 最後の取得日時 + // 増えたらここに書く +} +``` + +### Bot +``` +type Bot struct { + bot *traqwsbot.Bot // traqBot +} +``` + +### DB +``` +type DB struct{ + db *sqlx.DB // sqlx.db +} +``` + +### traQapi +``` +type traQapi struct { + auth context.Context // 認証関連 + client *traq.APIClient // traqAPIClient +} +``` + diff --git a/server/setup/setup.go b/server/setup/setup.go new file mode 100644 index 0000000..9bca696 --- /dev/null +++ b/server/setup/setup.go @@ -0,0 +1 @@ +package setup