Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions ui/README.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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のようなものを叩かせる)

## 今後具体的なクラス相当の設計を考える

## やりたいこと

Expand Down
3 changes: 3 additions & 0 deletions Server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Server

あああ
199 changes: 199 additions & 0 deletions server/docs/openapi.yaml
Original file line number Diff line number Diff line change
@@ -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"

7 changes: 7 additions & 0 deletions server/handler/bot/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package bot

import traqwsbot "github.com/traPtitech/traq-ws-bot"

func NewBotHandler(bot *traqwsbot.Bot) *Bot {
return &Bot{bot: bot}
}
7 changes: 7 additions & 0 deletions server/handler/bot/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package bot

import traqwsbot "github.com/traPtitech/traq-ws-bot"

type Bot struct {
bot *traqwsbot.Bot
}
7 changes: 7 additions & 0 deletions server/handler/db/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package db

import traqwsbot "github.com/traPtitech/traq-ws-bot"

func NewBotHandler(bot *traqwsbot.Bot) *Bot {
return &Bot{bot: bot}
}
7 changes: 7 additions & 0 deletions server/handler/db/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package db

import traqwsbot "github.com/traPtitech/traq-ws-bot"

type Bot struct {
bot *traqwsbot.Bot
}
7 changes: 7 additions & 0 deletions server/handler/service/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package service

import traqwsbot "github.com/traPtitech/traq-ws-bot"

func NewBotHandler(bot *traqwsbot.Bot) *Bot {
return &Bot{bot: bot}
}
7 changes: 7 additions & 0 deletions server/handler/service/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package service

import traqwsbot "github.com/traPtitech/traq-ws-bot"

type Bot struct {
bot *traqwsbot.Bot
}
7 changes: 7 additions & 0 deletions server/handler/traqapi/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package traqapi

import traqwsbot "github.com/traPtitech/traq-ws-bot"

func NewBotHandler(bot *traqwsbot.Bot) *Bot {
return &Bot{bot: bot}
}
7 changes: 7 additions & 0 deletions server/handler/traqapi/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package traqapi

import traqwsbot "github.com/traPtitech/traq-ws-bot"

type Bot struct {
bot *traqwsbot.Bot
}
51 changes: 51 additions & 0 deletions server/model.md
Original file line number Diff line number Diff line change
@@ -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
}
```

1 change: 1 addition & 0 deletions server/setup/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package setup