bbs

Month: 2021-02

2021-02-01

David Lee 09:46:38
@davidtaolee has joined the channel
pichuchen 20:05:19
這週如果有什麼想要提請討論的議題請在這篇回應,這樣我會放進來讓大家知道
jiji0856 20:23:32
怎麼知道這個專案的?
PTT soft_jobs
您平常的活動或是工作?
後端工程師
平常出沒的區域?
台北市
您有興趣或者是關心的主題?
DevOps golang
其他意見發表:
PTT id:
lolo0856
👋 1
David Lee 21:08:49
Hi 各位大大
David Lee 21:09:17
https://github.com/Ptt-official-app/Ptt-backend/blob/development/FOR_DEVELOPERS.md
我照著個跑到這步

FOR_DEVELOPERS.md

``` # 給開發者的資訊 ## 開發環境建置 安裝下列的應用程式來建構開發環境: | 應用程式名稱 | 應用程式版本(有特定版本才填寫) | 安裝要求 | | ------- | ------- | ------- | |[Golang](<https://golang.org/dl/>)|1.14 以上|必要| |[GoLand](<https://www.jetbrains.com/go/promo/>)| |如果使用 GoLand * 推薦給新手| |[Sublime Text 3](<https://classic.yarnpkg.com/zh-Hant/>)| |如果使用 Sublime Text,記得安裝 Gofmt 套件| |[docker compose](<https://docs.docker.com/compose/install/>)| |使用 `docker compose` 直襲本專案時| ### Sublime Text 3 的套件 要使用 Sublime Text 3,請安裝以下套件。 | 套件 | 安裝要求 | | ------- | ------- | |[Gofmt](<https://packagecontrol.io/packages/Gofmt>)|可選| |[ConvertToUTF8](<https://ephrain.net/sublime-text-%E8%AE%93-sublime-text-%E6%94%AF%E6%8F%B4-big5-%E7%B7%A8%E7%A2%BC%E7%9A%84%E6%96%87%E5%AD%97%E6%AA%94/>)|可選| --- ## 安裝與設定 ### Clone Ptt-backend 專案 ```bash $ git clone <https://github.com/Ptt-official-app/Ptt-backend.git> ``` ### 下載測試伺服器靜態資料與配置設定檔 ```bash # 下載 BBS Home $ wget <http://pttapp.cc/data-archives/bbs_backup_lastest.tar.xz> # 用 xz 進行解壓縮 $ tar -Jxvf bbs_backup_lastest.tar.xz # 下載 SHM 測試資料 $ wget <http://pttapp.cc/data-archives/dump.shm.lastest.tar.bz2> # 用 bzip2 進行解壓縮 $ tar -jxvf dump.shm.lastest.tar.bz2 ``` - 設定檔預設讀取 `config_default.toml`,如果希望改成自己的設定檔請將他複製成 `config.toml` 即可。 ## 編譯與執行 請在工作目錄 `./Ptt-backend` 下執行此命令。 ### 狀況 1: 直接使用 `go build` ```bash $ go build $ ./Ptt-backend ``` #### Troubleshoot // TODO ### 狀況 2: 使用 Gitpod 開發 // TODO --- ## 生產環境/其他環境的判定 一但要上線到生產環境,請務必改掉 security 章節內的設定。 --- ## Deploy 到 Staging 環境以及正式環境的方法 當下表左欄所列的分支更新後,分支和網站將會自動被更新。 | 分支 | 建置與更新的分支 | 對應站點 | | ---- | ---- | ---- | |`master` (尚未建置) ||| |`staging` (尚未建置)|| |`development`||<https://pttapp.cc>| --- ## 分支規則 只允許推送 Pull Request 到 `development` 。 在推送 Pull Request 時,請依照以下命名規則為您的分支命名 | 變更種類 | 分支的命名規則 | | ---- | ---- | |新增功能|`feature/#{ISSUE_ID}-#{branch_title_name}`| |Hotfix commit|`hotfix/#{ISSUE_ID}-#{branch_title_name}`| ### 基本分支 | 目的 | 分支 | 預覽用 URL | 誰可以發 Pull Request | 備註 | | ---- | ---- | ---- | ---- | ---- | | 開發 | development | <https://pttapp.cc> | All developers | 基本上請推送 Pull Request 到這裡 | | 正式版預覽 | staging | | Only administrators | 對於正式版釋出前的最終確認,禁止管理員以外的人推送 Pull Request。 | | 正式版 | master | | Only administrators | 禁止管理員以外的人推送 Pull Request | ### 系統所使用的分支 | 目的 | 分支 | 預覽用 URL | 備註 | | ---- | -------- | ---- | ---- | ```

David Lee 21:09:29
image.png
David Lee 21:09:46
然後我要怎麼連?
pichuchen 21:33:15
試試看,因為我們還沒有 Demo 用的 Web UI
`curl http://localhost:8081/v1/token -d 'grant_type=password&username=SYSOP&password=123123'`
David Lee 21:44:57
喔喔,可以了
David Lee 21:45:10
幫我認證一下,我新開了一個使用者 foobar
pichuchen 22:35:18
foobar 開好了

2021-02-02

Amos Chang 00:20:06
@gn01842919 has joined the channel
Te-Yu Chang 00:35:05
@dale.teyuchang has joined the channel
pichuchen 01:40:20
第二週的信件寄出了,我還滿擔心什麼時候會進入 spam 的,如果有進入spam的現象再提醒一下...
Te-Yu Chang 01:42:54
*怎麼知道這個專案的?*
PTT
*您平常的活動或是工作?*
backend
*平常出沒的區域?*
Austin, Texas
*您有興趣或者是關心的主題?*
Distributed System
Architecture Design
Infrastructure
*其他意見發表:*
👋 1
Doge 03:13:57
@sageofcross has joined the channel
Doge 03:31:34
*怎麼知道這個專案的?*
Soft Job 版

*您平常的活動或是工作?*
網頁相關的後端工程師

*平常出沒的區域?*
新北|台南

*您有興趣或者是關心的主題?*
程式架構、底層運作原理、高並行的處理

*其他意見發表:*
整個截止期前入場,這樣大丈夫嗎?
第一次參加開源專案,甚至連 BBS 都只用過網頁版的,但即使如此還是想參與開發,請多指教 XD
👋 1
Te-Yu Chang 07:09:40
I created a PR to clean up `go.sum`. It is straight forward so I didn’t create an issue for that. It is my first PR for this project. Please help review and feel free to let me know if you have any concerns. Thanks! https://github.com/Ptt-official-app/Ptt-backend/pull/28

#28 Remove stale hashes in go.sum

*:clap: 解決掉的 issue / Resolved Issues* N/A *:memo: 相關的 issue / Related Issues* N/A *:pick: 變更內容 / Details of Changes* • Remove stale hashes in go.sum

其實我會建議還是要開個ISSUE稍微介紹為什麼需要手動刪除,不刪除和刪除分別的優缺點這樣
👍 4
c510w995 09:10:04
@c510w995 has joined the channel
c510w995 09:13:57
*怎麼知道這個專案的?*
PTT SOFT_JOBS
*您平常的活動或是工作?*
網頁後端工程師
*平常出沒的區域?*
台北
*您有興趣或者是關心的主題?*
golang/ system design/ backend
*其他意見發表:*
第一次參加開源專案
還請各位前輩多多指教
很期待和各位大神一起合作 🙂
謝謝🙏
👋 2
titaneric 10:03:16
@chenyee has joined the channel
陳昱廷 10:51:55
@y2468101216 has joined the channel
陳昱廷 10:54:15
*怎麼知道這個專案的?*
Soft Job 版
*您平常的活動或是工作?*
後端兼測試工程師
*平常出沒的區域?*
*台北*
*您有興趣或者是關心的主題?*
*測試相關,高併發*
*其他意見發表:*
*過年前有點忙,會先看看 issue 有沒有能順手解的*
👋 1
陳昱廷 12:12:10
有個問題
陳昱廷 12:12:12
https://github.com/Ptt-official-app/Ptt-backend/blob/development/FOR_DEVELOPERS.md

FOR_DEVELOPERS.md

``` # 給開發者的資訊 ## 開發環境建置 安裝下列的應用程式來建構開發環境: | 應用程式名稱 | 應用程式版本(有特定版本才填寫) | 安裝要求 | | ------- | ------- | ------- | |[Golang](<https://golang.org/dl/>)|1.14 以上|必要| |[GoLand](<https://www.jetbrains.com/go/promo/>)| |如果使用 GoLand * 推薦給新手| |[Sublime Text 3](<https://classic.yarnpkg.com/zh-Hant/>)| |如果使用 Sublime Text,記得安裝 Gofmt 套件| |[docker compose](<https://docs.docker.com/compose/install/>)| |使用 `docker compose` 直襲本專案時| ### Sublime Text 3 的套件 要使用 Sublime Text 3,請安裝以下套件。 | 套件 | 安裝要求 | | ------- | ------- | |[Gofmt](<https://packagecontrol.io/packages/Gofmt>)|可選| |[ConvertToUTF8](<https://ephrain.net/sublime-text-%E8%AE%93-sublime-text-%E6%94%AF%E6%8F%B4-big5-%E7%B7%A8%E7%A2%BC%E7%9A%84%E6%96%87%E5%AD%97%E6%AA%94/>)|可選| --- ## 安裝與設定 ### Clone Ptt-backend 專案 ```bash $ git clone <https://github.com/Ptt-official-app/Ptt-backend.git> ``` ### 下載測試伺服器靜態資料與配置設定檔 ```bash # 下載 BBS Home $ wget <http://pttapp.cc/data-archives/bbs_backup_lastest.tar.xz> # 用 xz 進行解壓縮 $ tar -Jxvf bbs_backup_lastest.tar.xz # 下載 SHM 測試資料 $ wget <http://pttapp.cc/data-archives/dump.shm.lastest.tar.bz2> # 用 bzip2 進行解壓縮 $ tar -jxvf dump.shm.lastest.tar.bz2 ``` - 設定檔預設讀取 `config_default.toml`,如果希望改成自己的設定檔請將他複製成 `config.toml` 即可。 ## 編譯與執行 請在工作目錄 `./Ptt-backend` 下執行此命令。 ### 狀況 1: 直接使用 `go build` ```bash $ go build $ ./Ptt-backend ``` #### Troubleshoot // TODO ### 狀況 2: 使用 Gitpod 開發 // TODO --- ## 生產環境/其他環境的判定 一但要上線到生產環境,請務必改掉 security 章節內的設定。 --- ## Deploy 到 Staging 環境以及正式環境的方法 當下表左欄所列的分支更新後,分支和網站將會自動被更新。 | 分支 | 建置與更新的分支 | 對應站點 | | ---- | ---- | ---- | |`master` (尚未建置) ||| |`staging` (尚未建置)|| |`development`||<https://pttapp.cc>| --- ## 分支規則 只允許推送 Pull Request 到 `development` 。 在推送 Pull Request 時,請依照以下命名規則為您的分支命名 | 變更種類 | 分支的命名規則 | | ---- | ---- | |新增功能|`feature/#{ISSUE_ID}-#{branch_title_name}`| |Hotfix commit|`hotfix/#{ISSUE_ID}-#{branch_title_name}`| ### 基本分支 | 目的 | 分支 | 預覽用 URL | 誰可以發 Pull Request | 備註 | | ---- | ---- | ---- | ---- | ---- | | 開發 | development | <https://pttapp.cc> | All developers | 基本上請推送 Pull Request 到這裡 | | 正式版預覽 | staging | | Only administrators | 對於正式版釋出前的最終確認,禁止管理員以外的人推送 Pull Request。 | | 正式版 | master | | Only administrators | 禁止管理員以外的人推送 Pull Request | ### 系統所使用的分支 | 目的 | 分支 | 預覽用 URL | 備註 | | ---- | -------- | ---- | ---- | ```

陳昱廷 12:12:34
裡面提到有 *下載 SHM 測試資料*
陳昱廷 12:12:44
但是要放在哪邊
pichuchen 13:42:43
下載的話通常會在工作目錄,也就是 git clone 後的 Ptt-backend, 當然也可以自己放在自己想放的地方
kira 15:57:26
@kiraxie11287 has joined the channel
Julian Chu 19:49:24
想問問看有沒有人對bat比較熟的 可以幫忙review一下make.bat
https://github.com/Ptt-official-app/Ptt-backend/pull/12/files#diff-fdb01b5af0ae147e0e3aa673b80401463571d9d1d51f88b834df205f8c8e34b0
應該是用 Windows 跑過看有沒有問題這樣?
我跑在Linux上,所以幫不上忙XD
光coding style我覺得可以
因為windows bat可讀性就是很差
如果可以我是建議用REM加註解
Julian Chu 2021-02-02 23:41:59
哈哈 其實David有get我的點,我幾乎沒有在寫bat所以不確定有沒有更好的寫法,加REM是好主意, bat/bash我在win10/wsl有跑過了 ,有人願意幫忙一起測試一下就好了
我感覺沒啥問題,不過我在想是否用 go 寫好 commend 然後 build 出來放在專案底下就好。
畢竟其他 framework 也是類似的作法
Julian Chu 2021-02-03 17:46:09
@y2468101216 這種做法的好處是不用會shellscript/bat, 但是需要額外維護build給不同平台的檔案。目前go開源專案的主流還是makefile
因為我覺得與其多維護 sh 跟 bat ,不如處理 go 跨平台的問題,維護比較簡單。

進來維護的人可以純會 go 就好。只是好其為何當初不這樣做而已
Julian Chu 2021-02-04 01:44:40
不見得比較簡單,平台就好幾種,manifest用git版控控也麻煩,用shellscript可以簡單處理的東西,用go寫就會多出很多code,而且shellscript算是普及度高的東西 不難找到人維護
Lei Rain 21:25:35
.
David Lee 23:05:51
我pttapp.cc可以登入了,今天從新下載了新的DB,跑了這兩個API,都回應有錯
image.png
第一個API沒有吐error message, 所以不確定是對應到哪一段code, Ptt-backend executable有提供command line options嗎? 比如說 ./Ptt-backend --debug之類的,可以吐出不同logger level的訊息
我剛剛試了一下,可以用 logger.Debugf去print debug的訊息,目前default是全開

@pichuchen 你覺得弄一個

./Ptt-backend --debug

的功能出來

然後有加這個參數才會印 logger.Debugf
的訊息好嗎?

我可以來研究看看
目前通通都有印Debugf
目前直接把需要的點通通加上 debugf 比較簡單,然後 logger level 的部分因為我們有 config 了,所以可以提案新增config 這樣
目前還沒有輸入log level的設計
然後他會出現 not found 的原因,應該是我還沒把你的帳號sync過去離線資料,我先做這件事
你覺得這個需要開一個feature嗎?
config目前好像也沒有設計這個,剛剛看了一下config_default.toml
需要,不過應該要等 Clean Arch .. 那個 repo merge 之後才能進行
了解,那我先開Issue,priority之後定
我怕不好開,因為要修改 config.go 這個檔案
可是這個檔案還沒 merge 近來
config.go? 我有看到這個檔案阿
clean arch那個repo在哪裡?
喔喔,
不過我覺得還好,到時候再merge就可以了
靜態db好了
David Lee 23:53:35
好奇問一下
gitignore為什麼不是放config_default.toml而是config.toml?
我以為大家的config.toml都會是default, 實際修改的會是config_default.toml (至少我一開始有進去改ssh key)
我也試過把config_default.toml砍掉,然後運行就會報錯
還是我哪裡有理解錯誤呢?
image.png
根據 https://github.com/Ptt-official-app/Ptt-backend/blob/ae1c6670523bbd247076163bdea25f9207625033/config.go#L18

`config_default.toml` 是提供預設值用的,而 `config.toml` 則是讓各自可以進行不同值的改動用。

無論如何 `config_default.toml` 如果沒給,就會導致連不上資料庫而出錯;反之 `config.toml` 沒改只是變成使用預設值罷了,所以它在 gitignore 內是蠻合理的。

希望有替你解惑。
喔喔,懂了,所以我的ssh key應該要放在config.toml, config_default.toml保持原本的

原本的教學這句話我看得有誤會:
https://github.com/Ptt-official-app/Ptt-backend/commit/7ea2263f3706b87e3886440edc2c8e3b5338752b#r46672606

2021-02-03

Viktor 01:20:01
@apple8952047 has joined the channel
Vladka 09:24:54
想跟大家討論一下關於透過推文數找尋文章的功能
https://github.com/Ptt-official-app/Ptt-backend/issues/26
一開始開 issue 時只想到推文數 > 0 (ge) 的狀況
後來發現原來有 < 0 搜噓文數的功能
不知道大家覺得參數命名有沒有需要更動

#26 [主線] [PTT] 實作找尋推文數以上文章

*實作細節 / Details of Implement* 在 `/v1/boards/{{board_id}}/articles` 新增參數 recommend_cnt 取得推文數 &gt;= recommend_cnt 的文章列表 初期演算法先以 O(n) 的演算法進行實作即可, n 為某看板文章數量。 *期程 / Schedule* • 討論時間: 一週,到2/7 • 實作時間: 一天,到2/8 • 確認時間: 待定 *相關文件 / Documents* <https://docs.google.com/document/d/18DsZOyrlr5BIl2kKxZH7P2QxFLG02xL2SO0PzVHVY3k/edit#heading=h.bnhpxsiwnbey|https://docs.google.com/document/d/18DsZOyrlr5BIl2kKxZH7P2QxFLG02xL2SO0PzVHVY3k/edit#heading=h.bnhpxsiwnbey>

把噓文視為負推文就好吧就是-1的概念,ptt 實際上也是會正負抵銷,我覺得不用特別調整,實務上也許會有需要找50 ~ -50 的推文...?
沒有吧 目前PTT看起來是 正數找 ge 負數找 le
文件上面寫 取得某看板文章列表,同時使用多個條件時,以交集處理。

我才會想說會不會需要作區間。

另外我真的覺得用負數判斷就好,要多做6個參數,怎想都不好。
另外提到正負抵銷這件事,如果同時推噓很多,我記得是以最後計算的結果作為搜尋數量,例如推噓各50,實際上會是0,這部分不知道是不是要沿用。
喔喔 交集指的是 作者 標題 推噓文數
應該是抵銷的
kira 10:20:09
*怎麼知道這個專案的?*
soft_job

*您平常的活動或是工作?*
backend developer

*平常出沒的區域?*
東京(但暫時去不了)/台北市

*您有興趣或者是關心的主題?*
高頻交易, Architecture Design, 分散式架構

*其他意見發表:*
取之於PTT 用之於PTT
👋 2

2021-02-04

andylee1013 15:23:37
@andylee1013 has joined the channel
David Lee 18:48:25
我今天拉新的code下來不能build也
image.png
感謝提醒,搞定了
David Lee 18:48:42
help!
andylee1013 20:03:36
*怎麼知道這個專案的?*
Soft Job 版
*您平常的活動或是工作?*
後端工程師
*平常出沒的區域?*
*台北*
*您有興趣或者是關心的主題?*
andylee1013 20:05:33
*怎麼知道這個專案的?*
Soft Job 版
*您平常的活動或是工作?*
後端兼測試工程師
*平常出沒的區域?*
*台北*
*您有興趣或者是關心的主題?*
Backend architecture, Golang implementation, open source developing
👋 1
David Lee 23:53:50
有沒有甚麼辦法可以讓開法者驅動打包最新的
http://pttapp.cc/data-archives/bbs_backup_lastest.tar.xz
這樣我改東西就可以馬上看到變化

不需要等站長上去打包
`curl localhost:10036/update-static-file -H 'Authorization: pttapp' `
完工
沒有回傳值,不知道有沒有生效
還在跑,晚點回來看
https
不好意思
最後一個加上s對嗎
curl https://pttapp.cc/update-static-file -H 'Authorization: pttapp'

對,然後剛剛設定錯vhost了
現在才是對的
他跑下去會有兩種狀態,一種是正在跑,一種是顯示有人在跑
$ curl https://pttapp.cc/update-static-file -H 'Authorization: pttapp' finish :slightly_smiling_face:
成功了
帥喔
好像不work,我新增一個最愛,但是還是只有一個
最愛好像不會新增後馬上寫入硬碟
這點要確認ptt c code, 我的測試經驗是要先登出還是備份才會寫到硬碟上
所以,如果PTT突然當機的話,還沒被寫入硬碟的最愛確實有可能噴掉
喔喔,原來如此,我來試試

2021-02-05

David Lee 00:00:02
比如: curl http://pttapp.cc/v1/users/foobar/backup
然後遠端會判定這個帳號有沒有開發者的權限
如果有就先檢查是否這個動作正在執行(有可能別的開發者也request打包)
如果有在執行,則忽略這個動作,在前一個打包指令完成之後,才回覆說已經打包完成
如果沒有,則開始執行打包資料庫,打包完成後,回覆說已經打包完成
陳昱廷 16:52:16
靜態資料需要有一個專門的開發者帳號 for ci cd 跟開發使用
pichuchen 17:21:26
自動化測試?
陳昱廷 17:27:29
我現在看是用 mock 作處理
陳昱廷 17:28:33
mock 也是可以
陳昱廷 17:31:52
我先用 mock 處理好了
David Lee 19:18:37
mock怎麼用啊? 不太懂,要跟大大學習
David Lee 19:18:42
我現在都是用curl
kudakenu 19:24:23
感覺是這個?
kudakenu 19:26:00
不過如果要做這種整合測試(不知道有沒有),可能還是用 curl 這類的比較好

2021-02-06

pichuchen 01:06:47
https://github.com/Ptt-official-app/Ptt-backend/pull/37

這個 ISSUE 需要請大家幫忙 Review 喔

#37 add post token test and add .vscode gitignore

*:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/36|#36> *:pick: 變更內容 / Details of Changes* • 增加 route_token_test.go • 增加 gitignore .vscode 完成了 route_token_test.go 的測試部分,使用 mock

Leo Liu 14:53:19
@silver886 has joined the channel
Leo Liu 14:57:01
*怎麼知道這個專案的?*
朋友介紹
*您平常的活動或是工作?*
Backend, DevOps, Infra
*平常出沒的區域?*
台北
*您有興趣或者是關心的主題?*
Golang / Backend / Open source
*其他意見發表:*
第一次參加開源專案
還請多指教囉🙏
👋 3
pichuchen 19:23:02
目前這個是 lint 有錯誤嗎?
截圖 2021-02-06 下午7.22.50.png
Julian Chu 2021-02-06 21:26:43
這個是bash的錯誤, 應該在PR#39修復了
所以有 merge 進來了嗎?
那看起來還是有問題要修XD
Julian Chu 2021-02-06 21:57:09
對 這個是提示code的排版問題,應該另外發一個PR排版所有程式碼, 之前怕PR太大就沒跟CI的一起做
Julian Chu 2021-02-06 21:59:46
目前有兩種問題 第一種是name,應該照lint預設就好好, 第二種是unhandled error, 這個可能要想一下是先用 _ 忽略錯誤,還是要處理。或是關掉errcheck的設定
Te-Yu Chang 2021-02-07 11:17:33
我把名字都修掉了,剩下的問題需要討論一下怎麼修
https://github.com/Ptt-official-app/Ptt-backend/pull/42
pichuchen 21:57:50
這週感覺進度有點慢一點點,不確定是不是主線開太少

2021-02-07

Amos Chang 00:30:37
*怎麼知道這個專案的?*
PTT Soft_Job 版徵才文

*您平常的活動或是工作?*
分散式儲存系統應用開發 (base on Ceph, 我做的部分以 S3 compatible 相關 feature 為主, 使用 C/C++ 與 Python)
最近在自學 Golang,但還沒什麼實務經驗,努力中。

*平常出沒的區域?*
雙北

*您有興趣或者是關心的主題?*
分散式架構、網頁後端、K8S

*其他意見發表:*
大家好,我對 Golang 跟比較現代的網頁後端開發都不是很熟,正在努力想要跟上中,先看一下 code,希望之後能對專案有所貢獻。

*PTT ID:*
gncn
👋 2
amberfu 01:48:35
@amberfu has joined the channel
Te-Yu Chang 11:17:33
我把名字都修掉了,剩下的問題需要討論一下怎麼修
https://github.com/Ptt-official-app/Ptt-backend/pull/42

#42 Rename variables in compliance with the convention

Signed-off-by: Te-Yu Chang <mailto:dale.teyuchang@gmail.com|dale.teyuchang@gmail.com> *:clap: 解決掉的 issue / Resolved Issues* • fix part of <https://github.com/Ptt-official-app/Ptt-backend/issues/3|#3> • fix part of <https://github.com/Ptt-official-app/Ptt-backend/issues/38|#38> *:memo: 相關的 issue / Related Issues* *:pick: 變更內容 / Details of Changes* • s/Id/ID • fix typos • remove redundant names and codes

👍 2

2021-02-08

Vladka 10:02:02
https://github.com/Ptt-official-app/Ptt-backend/pull/24
這邊又要跟大家討論一下 mock 的位置,目前 mock package import usecase 和 repository 的作法會導致 usecase 的測試引用 mock 時的 import cycle
想看看大家有什麼調整的想法
順便在這問一下 lint check fail 的部份是要直接在 issue 內順便修掉嗎? 因為看起來有一些是和這個 issue 不相關的功能。

#24 Feat/search articles

*:clap: 解決掉的 issue / Resolved Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/13|#13> • <https://github.com/Ptt-official-app/Ptt-backend/issues/14|#14> • <https://github.com/Ptt-official-app/Ptt-backend/issues/26|#26> *:memo: 相關的 issue / Related Issues* NA *:pick: 變更內容 / Details of Changes* • /v1/boards/{{board_id}}/articles 取得看版內文章列表的部份加上參數 author, title_contain, recommend_count_ge

目前 link check fail 主要是哪些? 很大片的話可以先開一個 ISSUE 然後做比較高的 priority 處理掉,不然好像很多都被它卡住了....
整理了一下 很多是
`*Id` should be `*ID`

其他部份
delivery
- Error return value of `w.Write` is not checked (errcheck)
- Error return value of `r.ParseForm` is not checked (errcheck)
- Error return value of `json.Unmarshal` is not checked (errcheck)
- type `MockUserRecord` is unused (unused)
- func `(*httpDelivery).routeClass` is unused (unused)
- func `(*httpDelivery).getClass` is unused (unused)
- exported func NewHTTPDelivery returns unexported type *github.com/Ptt-official-app/Ptt-backend/internal/delivery/http.httpDelivery, which can be annoying to use (golint)
- getBoardList 和 getClassesList if 裡有 return 不需要 else (golint)

usecase
- func (t *usecase) GetUserIdFromToken(token string) (string, error) receiver name 要改成 usecase

mock
- MockUsecase, MockRepository 開頭用了 package name

有幾個這issue gofmt 的部份,可以在這個 pr 修掉
Julian Chu 2021-02-08 15:46:35
lint的部分 正在https://github.com/Ptt-official-app/Ptt-backend/pull/42 處理

你的PR可以先忽略這塊。 目前的設定lint沒過還是可以merge吧?
NickWang 22:08:36
@sheng79225 has joined the channel
weichu 23:59:02
@ms0701515 has joined the channel

2021-02-09

cheng en hsieh 00:08:42
@a0955105 has joined the channel
pichuchen 00:25:32
我發現目前的lint可能要拔掉,因為他會卡住我們整體的進度
pichuchen 00:25:36
舉例而言
pichuchen 00:25:47
這樣應該是沒有必要的
截圖 2021-02-09 上午12.25.36.png
Julian Chu 2021-02-09 04:10:48
可以設定忽略, 但是w.Write還是會有回傳錯誤的情況,一般建議最少log方便查詢錯誤
了解
pichuchen 00:25:54
所以我會先把它拔掉
pichuchen 00:29:08
再來是現有的 test 在真的發生錯誤時他並不會出現 x
pichuchen 00:29:19
截圖 2021-02-09 上午12.29.10.png
Julian Chu 2021-02-09 04:35:55
可能是github action的誤判?
這兩行只是單純的t.log(.....)
測試本身是通過的
Julian Chu 2021-02-09 04:56:36
重測CI 測試的確無法觸發failed,但跟那兩行無關,
Julian Chu 2021-02-09 05:26:29
新的PR解決掉無法觸發x的問題,但是t.Log會在github action印出error的問題還需要研究
Julian Chu 2021-02-09 17:35:36
需要的話 我可以把-v拿掉,就不會印出,但是就會缺少印出來的資訊
我覺得 -v 可以拿掉,預設他不會有問題,有問題的話開發者在自行下 go test -v ?
Julian Chu 2021-02-10 01:58:08
ok 那我再開一個小的PR移除-v 跟從make裡移除cmd目錄的檢查
Te-Yu Chang 00:37:13
lint不一定要拔,可以先把標準放寬。不過也只剩幾個錯要修,所以我覺得以修好為目標比較好
test我覺得不能拔,應該是開一個新issue去找script哪裡寫錯導致他沒報錯
👍 1
Te-Yu Chang 00:40:08
By the way, 這就是我之前建議要在script裡面開 `set -e` 的原因
Julian Chu 2021-02-09 04:09:20
那會導致每個variable都要檢查,開set -e的情況,遇到空值的variable會直接拋錯中斷執行
Te-Yu Chang 2021-02-09 05:20:23
檢查variable的應該是 `set -u` ?
Julian Chu 2021-02-09 05:35:17
對 我記錯了orz, 但是之前用-e的時候也有問題,所以才拿掉,但我忘記是甚麼問題了......orz
Julian Chu 2021-02-09 05:41:16
想起來問題了
```VERSION=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null)```
-e的話 在這行tags為空的情況就會直接中斷指令
Te-Yu Chang 2021-02-09 06:43:11
如果只有這邊的話 等我們release第一版之後應該就沒問題了
Te-Yu Chang 05:26:05
我看到有些commit直接被推進 `development`。我建議任何commit都要透過PR才能進到我們的repo。這樣大家才有辦法review
主要是我這邊推的,因為先前 lint 的 PR 有些問題所以導致整體節奏出狀況,其他 PR 的 lint 都不會過,那這樣整個專案進度會卡死,所以先做緊急處置。後面等 lint 需要修正的東西修正後就可以恢復了。
Vladka 14:53:45
https://github.com/Ptt-official-app/Ptt-backend/pull/24
要麻煩大家 code review 這次有再針對測試 mock 的部份做調整,請大家幫忙看看有沒有什麼要修正的

#24 Feat/search articles

*:clap: 解決掉的 issue / Resolved Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/13|#13> • <https://github.com/Ptt-official-app/Ptt-backend/issues/14|#14> • <https://github.com/Ptt-official-app/Ptt-backend/issues/26|#26> *:memo: 相關的 issue / Related Issues* NA *:pick: 變更內容 / Details of Changes* • /v1/boards/{{board_id}}/articles 取得看版內文章列表的部份加上參數 author, title_contain, recommend_count_ge 在測試的部份有稍微做了些調整,把 mock 的部份獨立檔案來放。 另外原本 repository 的地方也寫了 struct MockRepository,個人認為這應該在 usecase 即可。 repository 要放的 mock 應該是針對 db ,目前只有刪除原本的 MockRepository,尚未新增 db mock。

👍 1

2021-02-10

Te-Yu Chang 01:32:07
Rebased. Please help review. Thanks.

我把名字都修掉了,剩下的問題需要討論一下怎麼修 <https://github.com/Ptt-official-app/Ptt-backend/pull/42>

Te-Yu Chang 01:34:33
Rebased. Please help review. Thanks. https://github.com/Ptt-official-app/Ptt-backend/pull/42

#42 Rename variables in compliance with the convention

*:clap: 解決掉的 issue / Resolved Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/3|#3> • <https://github.com/Ptt-official-app/Ptt-backend/issues/38|#38> *:memo: 相關的 issue / Related Issues* *:pick: 變更內容 / Details of Changes* • s/Id/ID • fix typos • remove redundant names and codes • catch errors from `Write()`

這個 PR 有很多沒有討論過的修改,例如把 `httpDelivery` 修改成 `Delivery` 的原因是什麼 `boardId` 改成 `boardID` 的原因是什麼
Julian Chu 2021-02-10 02:58:44
boardID是lint的規範, httpDelivery原本是要改成exported,不過被rename了
Julian Chu 2021-02-10 03:05:33
這個PR剛好是#38 code style的實作,可以做為是否套用lint規範的討論
如果說要改成 exported 的話,那應該是先改成 HttpDelivery 這樣?
Id -> ID 的 lint 規範有相關文件嗎? 我想知道他為什麼會有這樣的設計
Te-Yu Chang 2021-02-10 04:18:25
That would be `http.HttpDelivery` and linter complained about that because of stuttering.
@dale.teyuchang 有對應的文件之類的嗎?
Julian Chu 2021-02-10 04:26:51
Stuttering 的話 這一篇 https://blog.golang.org/package-names 找*Avoid stutter*
所以 ID 我認為比較沒爭議了,我先把這個資料補上 ISSUE 裡面,那未來有人對這個有意見的話再讓他去看 #30 就好了
那會有 var config = &Config{} 的嗎? 我印象中以前有看過,不過應該也可以把他一起補在 #38
Julian Chu 2021-02-10 05:58:56
有 那個很常見XD config:= &Config{}也是

如果是var跟:= 我印象沒有看過比較強制的規範

我個人習慣是這樣,供參考
var config = &Config{} => 通常會用在global variable
config := &Config => function內需要馬上實例化
var config => global/function內不用馬上實例化
👀 1
pichuchen 02:51:28
問個意見,轉錄文章需要在 go-bbs 實作嗎? 感覺 go-bbs 只要實作寫入就行了,實際上的權限檢查和操作應該在 Ptt-backend 操作?
截圖 2021-02-10 上午2.50.43.png
pichuchen 03:36:08
因為 go-bbs 好像不知如何下手,所以先用拋磚引玉的方式設計了一系列 Interface
https://github.com/Ptt-official-app/go-bbs/commit/242c3ad9003e125bf66478d35f3e1cf369dab9b2

這部分應該涵蓋了 Milestone 1 所需要的功能,再請大家看這樣設計有沒有哪邊需要修改的,沒有的話可能週五就Merge進development了
👍 1
Julian Chu 05:45:24
https://github.com/Ptt-official-app/Ptt-backend/pull/49
https://github.com/Ptt-official-app/Ptt-backend/pull/49#issuecomment-776310832
尋求好心人協助 幫忙debug macOS底下./make.bash lint無法運作部分,我在git bash跟WSL模擬幾種情況都重現不出來orz
想交叉比對一下跟pichu的結果,看缺少那個環節

#49 Bugfix/fix verbose flag, build command, remove ./cmd from lint command

download golangci-lint into /Users/pichu/go/bin 這個我看起來是沒有成功
GOBIN=/Users/pichu/go/bin
有一個可能性是 arm64 因為跑不出來的這台是 M1
```% go version
go version go1.16beta1 darwin/arm64```
這點也提供參考
```% ./make.bash lint
GOBIN=/Users/pichu/go/bin
GOLANGCI_LINT_VERSION=
golangci/golangci-lint info checking GitHub for latest tag
golangci/golangci-lint debug http_download https://github.com/golangci/golangci-lint/releases/latest
golangci/golangci-lint info found version: 1.36.0 for v1.36.0/darwin/arm64
golangci/golangci-lint debug downloading files into /var/folders/v3/qzc5zjs93jxfyt_0z9r82g2m0000gp/T/tmp.4h6IxWta
golangci/golangci-lint debug http_download https://github.com/golangci/golangci-lint/releases/download/v1.36.0/golangci-lint-1.36.0-darwin-arm64.tar.gz
golangci/golangci-lint debug http_download_curl received HTTP status 404
download golangci-lint into /Users/pichu/go/bin
golangci-lint checking...
./make.bash: line 51: /Users/pichu/go/bin/golangci-lint: No such file or directory```
被雷到了...
pichuchen 06:08:55
https://github.com/Ptt-official-app/go-bbs/issues/40

go bbs 新增一個新增看板的 ISSUE, 雖然不是主線任務,但是整體而言應該是比新增文章好做

#40 [主線] [PTT] 實作新增看板

*實作細節 / Details of Implement* • 請參考 <https://github.com/ptt/pttbbs/blob/4d56e77f264960e43e060b77e442e166e5706417/mbbsd/admin.c#L1046|pttbbs admin.c> 當中的 add_board_record 的行為。 • 不做權限檢查,權限檢查交由 Ptt-backend 套件進行,但是需要進行資料結構完整性上的檢查,例如是否超過最大看板數量。 • 是否支援 Cache (SHM) 需要討論,有可能同時支援沒有 Cache 的版本。 *期程 / Schedule* (希望這個任務大概什麼時候做完,如果會卡到其他地方的功能也請在這邊提出。) • 討論時間: 三日,到 2/13 • 實作時間: 一日,到 2/14 • 確認時間: 三日,到 2/17 *相關文件 / Documents* <https://github.com/ptt/pttbbs/blob/4d56e77f264960e43e060b77e442e166e5706417/mbbsd/admin.c#L1046|pttbbs admin.c>

pichuchen 22:35:01
https://www.evanlin.com/til-go-goreleaser/ 看到一個有趣的東西
Julian Chu 2021-02-11 05:10:35
好東西 很方便!

2021-02-11

pichuchen 01:48:03
https://github.com/Ptt-official-app/Ptt-backend/pull/24

這個 PR 需要幫忙 Code Review 喔

#24 Feat/search articles

*:clap: 解決掉的 issue / Resolved Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/13|#13> • <https://github.com/Ptt-official-app/Ptt-backend/issues/14|#14> • <https://github.com/Ptt-official-app/Ptt-backend/issues/26|#26> *:memo: 相關的 issue / Related Issues* NA *:pick: 變更內容 / Details of Changes* • /v1/boards/{{board_id}}/articles 取得看版內文章列表的部份加上參數 author, title_contain, recommend_count_ge 在測試的部份有稍微做了些調整,把 mock 的部份獨立檔案來放。 另外原本 repository 的地方也寫了 struct MockRepository,個人認為這應該在 usecase 即可。 repository 要放的 mock 應該是針對 db ,目前只有刪除原本的 MockRepository,尚未新增 db mock。

👀 1
Julian Chu 05:10:02
跪求reviewer
https://github.com/Ptt-official-app/Ptt-backend/pull/49

#49 Bugfix/fix verbose flag, build command, remove ./cmd from lint command

*:clap: 解決掉的 issue / Resolved Issues* *:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/6|#6> • PR <https://github.com/Ptt-official-app/Ptt-backend/pull/46|#46> • PR <https://github.com/Ptt-official-app/Ptt-backend/pull/48|#48> *:pick: 變更內容 / Details of Changes* • 修改test-unit, test-integration ,移除 -v flag ,避免t.Log()在github action裡印出錯誤 • 修改lint command,因應main.go的搬動, 移除lint對 ./cmd的檢查 • 修改build command, 依照教學文件 , 將binary輸出至根目錄 • 修改clean command

👀 1
pichuchen 05:18:12
MS1 的 HTTP 文件基本上完成了,不過好像出現了註冊流程,我不確定他是不是 MS1 的內容,不過 Ptt-backend 應該可以透過 HTTP 文件開始做 ISSUE了
pichuchen 19:30:11
發現一個有趣的東西,也許可以讓API 設計參考 https://github.com/ietf-wg-httpapi/rfc7807bis

ietf-wg-httpapi/rfc7807bis

Revision of RFC7807: HTTP Problem Details

2021-02-12

Julian Chu 06:16:03
pichu除夕還在看code 太猛了!!

祝大家新年快樂
👍 2
titaneric 10:46:52
@chenyihuang001 has joined the channel
Julian Chu 16:08:31
https://github.com/Ptt-official-app/Ptt-backend/pull/54
小PR 缺一人幫忙review/approve

#54 Implement #53 Get popular board list

*:memo: 相關的 issue / Related Issues* • 主 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/51|#51> • 實作 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/53|#53> *:pick: 變更內容 / Details of Changes* • 實作 delivery/http/route_boards.go 中的 getPopularBoardList • 實作 usecase/board.go 中的 GetPopularBoards • TODO: 依 BoardRecord 中的 number_of_user 遞減排序

👍 1
pichuchen 19:22:29
然後 go-bbs 接下來會考慮增加 cmd `bbstool` 這樣在開發中應該可以比較動態,不是只有 go test

2021-02-13

pichuchen 00:54:17
pttbbs 實作的 fnv 的初始向量和 golang 以及標準的初始向量不同
https://golang.org/pkg/hash/fnv/
```PTT 程式碼裡面有用到 FNV Hash, 不過在 32 bit 的初始向量好像有不同版本,一個是 0x02000023 (33554467) 另外一個是在維基百科上的 0x811C9DC5 (2166136261) ,前者除了 PTT 程式碼之外好像有看到 freeBSD 程式碼使用的樣子。```

golang.org

fnv - The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

@kiraxie11287
如果沒有要重新複製貼上 fnv 的話,我看到的方法是透過 UnmarshalBinary 設定初始 offset 這樣
有點不懂這邊說的
> UnmarshalBinary 設定初始 offset
這樣
chhsiao1981 01:33:12
https://github.com/Ptt-official-app/go-pttbbs/blob/main/cmsys/fnv_hash.go

cmsys/fnv_hash.go

``` package cmsys import "<http://github.com/Ptt-official-app/go-pttbbs/types|github.com/Ptt-official-app/go-pttbbs/types>" //<https://github.com/ptt/pttbbs/blob/master/include/fnv_hash.h> //commit: 6bdd36898bde207683a441cdffe2981e95de5b20 func fnv32Bytes(theBytes []byte, hval uint32) uint32 { for _, each := range theBytes { hval *= FNV_32_PRIME hval ^= uint32(each) } return hval } func fnv1a32Bytes(theBytes []byte, hval uint32) uint32 { for _, each := range theBytes { if each == 0 { break } hval ^= uint32(each) hval *= FNV_32_PRIME } return hval } func fnv1a32StrCase(theBytes []byte, hval uint32) uint32 { for _, each := range theBytes { if each == 0 { break } hval ^= uint32(types.CcharToupper(each)) hval *= FNV_32_PRIME } return hval } func fnv1a32DBCSCase(theBytes []byte, hval uint32) uint32 { isDBCS := false for _, each := range theBytes { if each == 0 { break } if isDBCS { // 2nd DBCS isDBCS = false } else { if each &lt; 0x80 { each = types.CcharToupper(each) } else { isDBCS = true } } hval ^= uint32(each) hval *= FNV_32_PRIME } return hval } ////////// //64bits ////////// func fnv64Bytes(theBytes []byte, hval uint64) uint64 { for _, each := range theBytes { hval *= FNV_64_PRIME hval ^= uint64(each) } return hval } func fnv1a64Bytes(theBytes []byte, hval uint64) uint64 { for _, each := range theBytes { if each == 0 { break } hval ^= uint64(each) hval *= FNV_64_PRIME } return hval } func fnv1a64StrCase(theBytes []byte, hval uint64) uint64 { for _, each := range theBytes { if each == 0 { break } hval ^= uint64(types.CcharToupper(each)) hval *= FNV_64_PRIME } return hval } func fnv1a64DBCSCase(theBytes []byte, hval uint64) uint64 { isDBCS := false for _, each := range theBytes { if each == 0 { break } if isDBCS { // 2nd DBCS isDBCS = false } else { if each &lt; 0x80 { each = types.CcharToupper(each) } else { isDBCS = true } } hval ^= uint64(each) hval *= FNV_64_PRIME } return hval } func fnv1aByte(theByte byte, hval uint32) uint32 { hval ^= uint32(theByte) hval *= FNV_32_PRIME return hval } ```

pichuchen 02:59:33
然後 PTT 的搜尋紀錄似乎會被暫存下來
也就是說,如果今天在大型看板中搜尋類似 `[` 這樣的符號,第一次搜尋會感覺到很明顯的頓感,但是第二次之後就很快了
鈍感的來源猜測是來自寫硬碟
titaneric 16:08:43
需要有人幫忙review一下,https://github.com/Ptt-official-app/go-bbs/pull/41

#41 新增Userec遊戲成績欄位解析及對應測試

*:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/go-bbs/issues/1|#1> *:pick: 變更內容 / Details of Changes* • 利用提供的欄位pos抓取bytes array上對應的欄位資訊 • 在deserialize以及serialize上都用litten endian方式抓2 bytes • 修改testcases下.PASSWD bytes以及新增對應測試 *測試邏輯* 主要有5個遊戲類別,但只有暗棋沒有平手,所以會有3 * 5 - 1=14個欄位要被測試。 利用工具依序在這些欄位填上1到14,並同時測+16(0x10)以及+256(0x0100)以看出parsing有沒有問題

我覺得那個分數可以直接考慮用十六進位或是十進位表示,看怎樣人類比較好理解都行
抱歉我可能寫得不太好
原本是要區別不同欄位跟不同testcase才設計hex16跟hex256
因為1 + 16 + 256= 0x1101 (little endian),這樣可能比較好測
當然全部用十六進位表示可能更好,我再修一下
👀 1
nickyanggg 21:51:17
小pr,再請有空的人幫忙review一下,https://github.com/Ptt-official-app/Ptt-backend/pull/54

#54 Implement #53 Get popular board list

*:memo: 相關的 issue / Related Issues* • 主 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/51|#51> • 實作 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/53|#53> *:pick: 變更內容 / Details of Changes* • 實作 delivery/http/route_boards.go 中的 getPopularBoardList • 實作 usecase/board.go 中的 GetPopularBoards • TODO: 依 BoardRecord 中的 number_of_user 遞減排序

👀 2

2021-02-14

pichuchen 00:04:44
目前 ptt-backend 的母專案大致上都開完了,有些可能會有權限問題的 ISSUE (例如看板禁止推文)進行實作前可能需要討論
👍 2
Amos Chang 00:39:10
需要有人幫忙 review:
https://github.com/Ptt-official-app/Ptt-backend/pull/69

這是我第一個參與的開源專案,也是第一次用 go 來寫專案,如果有什麼可以改善或注意的地方都很歡迎跟我說

謝謝!

#69 Implement issue #58 [主線] [PTT] 實作個人看板的使用者資訊 (repository)

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/58|#58> *:memo: 相關的 issue / Related Issues* • #主 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/52|#52> • #子 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/58|#58> *:pick: 變更內容 / Details of Changes* • 新增 interface `BBSUserRecord` ,用來在 `bbs.UserRecord` 外面包一層 go-bbs 尚未支援的方法,並同步調整 test 相關的 mock,包含: • NumBadPosts() int • LastCountry() string • MailboxDescription() string • ChessStatus() map[string]interface{} • Plan() map[string]interface{} • 實作 `getMoneyDiscription()` 以顯示經濟狀況

有不支援的方法的部分應該可以開一下 go-bbs ISSUE
然後這個 ISSUE 應該是只有改動 repository 而以,所以應該不會改到 delivery 的程式碼?
leadenlight 2021-02-14 03:36:00
嗯,我開這個issue的時候是針對repository的部分
Amos Chang 2021-02-15 12:40:10
我把動到 delivery 的部分都改回去了,再麻煩你們看一下
Amos Chang 2021-02-15 12:40:36
go-bbs 的 issue 我可能明後天再開,這兩天先盲點別的事

2021-02-15

pichuchen 13:58:00
需要有人幫忙 review:
https://github.com/Ptt-official-app/go-bbs/pull/42

#42 補足Userec剩餘欄位及新增測試

*:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/go-bbs/issues/1|#1>,應該把剩餘欄位都補足了 *:pick: 變更內容 / Details of Changes* • 利用提供的欄位pos抓取bytes array上對應的欄位資訊 • 在deserialize以及serialize上都用litten endian方式抓給定bytes • 修改testcases下.PASSWD bytes以及新增對應測試 • 修改MarshalToByte method中PosOfPttPasswdCareer抓取長度,統一跟NewUserecWithByte method一致採40 • 修改PosOfPttPasswdLawCounter位置,需補上loginview長度(4 bytes) • 因為以上原因造成原先在.PASSWD部分資料需要做shift,還有TestEncodingUserec function中hex string也要跟著變動 *測試邏輯* 主要有5個遊戲類別,有勝、負以及和三種結果,所以會有3 * 5 =15個欄位要被測試。 利用工具依序在這些欄位填上1到15,並同時測+16(0x10)以及+256(0x0100)以看出parsing有沒有問題(檢查little endian及uint16)

c510w995 19:28:05
需要有人幫忙 review:
Test: Route get boards list #70

這是我第一個參與的開源專案,也是第一次用 go 來寫專案,如果有什麼可以改善或注意的地方都很歡迎跟我說:smile:

謝謝!
新年快樂!

#70 Test: Route get boards list

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/55|#55> *:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/36|#36> *:pick: 變更內容 / Details of Changes* • Add route boards tests

👋 2 👍 3

2021-02-17

May 01:53:21
@anddba has joined the channel
陳昱廷 11:46:48
https://github.com/Ptt-official-app/Ptt-backend/pull/37

#37 add post token test and add .vscode gitignore

*:memo: 相關的 issue / Related Issues* • 主 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/36|#36> • 實作 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/45|#45> *:pick: 變更內容 / Details of Changes* • 增加 route_token_test.go • 增加 gitignore .vscode 完成了 route_token_test.go 的測試部分,使用 mock

陳昱廷 11:46:55
麻煩 review 一下
pichuchen 14:46:55
使用者註冊後端API設計好了
IMAGE 2021-02-17 14:46:42.jpg
陳昱廷 14:58:12
https://github.com/Ptt-official-app/Ptt-backend/issues/73
https://github.com/Ptt-official-app/Ptt-backend/issues/74

目前這兩個測試 issue 沒人認領,有興趣者可以試試,可以當作練習 go 與其他語言間的不同

#74 [主線] [PTT] 實作 route_borads_articles_test.go

我想領一個, 可是我還卡一個 PR 🥲
pichuchen 17:32:25
https://pttapp.cc/develop/ptt-backend.log

多了一個 Debug 工具讓大家測試
pichuchen 17:32:46
他主要是透過 ./Ptt-backend 2>&1 | tee /var/log/ptt-backend.log 來取得 log
👍 5

2021-02-18

c510w995 00:22:07
Test: Route get boards list by PHChenGit · Pull Request #70 · Ptt-official-app/Ptt-backend (github.com)

這個 PR 需要有人幫忙 Review 喔 感謝
另外想問一下 branch development & development_enable_lint 這兩隻的關係以及怎麼更新這兩隻分支 感謝

#70 Test: Route get boards list

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/55|#55> *:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/36|#36> *:pick: 變更內容 / Details of Changes* • Add route boards tests

這兩隻的差別在 development_enable_lint 有 enable lint , 而 development 沒有
在進度開發方面,enable lint 的 branch 目前 @y2468101216 那邊的計畫是每一週從development 發送一次 PR 到 development_enable_lint ,因此平均起來 enable_lint 的進度應該會慢 development 3.5天
然後等到 enable_lint 這邊綠燈之後才整個合併回 development
對於最後一段不是很懂為什麼還要回 development? 另外想問這樣PR是要對 development 送嗎?還是對 development_enable_lint 送?目的是想知道如何更新開發者的branch
新功能的開發對 development 送
補齊原本沒有 testing code 的部分對 enable_lint 送
目前 test code 先對 development_enable_lint 作 rebase 跟 pr
每周我會同步跟修復測試
Timo Chiang 2021-02-18 12:11:18
可能要在增加測試issue(#36)或FOR_DEVELOPERS.md裡增加上述的說明,不然想幫忙的人會有點混亂?
我今天會增加一個 md 到 development 上
Hi 這個 PR 因為當初開發時 關於 Test 的開發指南還沒開出來 所以後來開了一個新的 PR 符合 branch naming style.

Test/#55 #impl route borads test by PHChenGit · Pull Request #96 · Ptt-official-app/Ptt-backend (github.com)

再麻煩幫忙看一下 感謝
陳昱廷 10:03:09
目前 test code 先對 development_enable_lint 作 rebase 跟 pr
bess 12:35:46
@besslee has joined the channel
👋 1
陳昱廷 13:15:37
要寫測試的可以參考 FOR_TEST_DEVELOPERS.md
👍 6
陳昱廷 13:15:46
新增在 development 上了

2021-02-19

nickyanggg 19:48:51
需要人幫忙 review,加了簡單的測試,因為當初寫的版本太過舊,所以就自己 merge 並重發 pr,那因為星期二就要當兵所以可能比較急一點,當兵後可能只有假日才可以更改,感謝。https://github.com/Ptt-official-app/Ptt-backend/pull/80

#80 實作 #53 Get popular board list

*:memo: 相關的 issue / Related Issues* • 主 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/51|#51> • 實作 issue <https://github.com/Ptt-official-app/Ptt-backend/issues/53|#53> *:pick: 變更內容 / Details of Changes* • 實作 delivery/http/route_boards.go 中的 getPopularBoardList • 實作 usecase/board.go 中的 GetPopularBoards • 增加 delivery/http/route_boards_test.go 中的 TestGetPopularBoardList • TODO: 依 BoardRecord 中的 number_of_user 遞減排序 因為之前再寫的時候 ptt-backend 是蠻舊版本的,所以就重新 merge、增加了簡單的測試並重發 pr。

Julian Chu 2021-02-20 01:45:35
應該沒問題了 等pichu merge吧 好好享受當兵前最後一個周末吧~
👍 3 👀 3

2021-02-20

Amos Chang 13:53:47
大家好,我這禮拜對於該如何參與專案有點困惑,想請教一下:

1. 現在是不是不會有人開好 subissue 等人認領了?
是要去 母 issue 底下說我想做這個 issue 的 http / usecase / repository 的部分,然後自行開立 subissue 後實作,這樣嗎?

2. 開出來的母 issue 雖然說「請依照文件實作」,但總覺得難以確認是要實作文件中的哪個部分
例如 [主線] [PTT] 實作文章推文 https://github.com/Ptt-official-app/Ptt-backend/issues/68
我在 https://docs.google.com/document/d/18DsZOyrlr5BIl2kKxZH7P2QxFLG02xL2SO0PzVHVY3k/edit#heading=h.j6io4sbmgs4k
一開始沒有看到,還以為沒有設計出來,但後來發現應該是 POST /v1/boards/{{board_id}}/articles/{{article_id}} HTTP/1.1
這一支才對,也許 issue 裡面明確指出要實作哪個 API 會比較好理解?

3. 現在 issue 列表中有一大堆 help_wanted,但實際上很多都已經有人認領了,我覺得有點令人困惑,
不知道能不能有人認領之後就把 subissue 的 help_wanted 拿掉?
有被認領到的話下面會有 Assignee
第3點可以試試看 在filter search bar 輸入 ‘is:issue is:open no:assignee label:"help wanted" ‘
Amos Chang 2021-02-21 16:32:07
了解了,謝謝!!

2021-02-21

chhsiao1981 00:58:47
hi all~

來打一下廣告~

在 go-openbbsmiddleware / go-pttbbs 這一線裡~
目前有一個網頁版的 demo-site:
https://www.devptt.site
(SYSOP/123123)

很歡迎大家去試試~


go-openbbsmiddleware / go-pttbbs 是以 gin 為 based 的 http-server.
redis / mongodb 為 go-openbbsmiddleware 所使用的 DB~
並且已經有完整的相對應的 swagger-ui:

https://api.devptt.site:5000/ (for go-openbbsmiddleware)
https://api.devptt.site:8080/ (for go-pttbbs)

codecov 也都超過 60%~ (主線 functions 大致上都有相對應的 tests~)
tests 大致上是透過 https://github.com/cweill/gotests 來產生 template~

很歡迎大家對於

https://github.com/Ptt-official-app/go-openbbsmiddleware
https://github.com/Ptt-official-app/go-pttbbs
https://github.com/Ptt-official-app/demo-pttbbs

提出各種關於 architecture / development-flow / ux / 其他相關的 issues / pr~

devptt.site

React App

Web site created using create-react-app

pichuchen 04:21:21
新增看板的 command line 好了,不過我的 git 因為 Xcode 更新的因素壞掉中,所以晚點才會推上去

因為我覺得有不少設計可能會有人有意見,所以我先把他拆成 PR 的形式讓大家 review
👀 1
wagaru 10:19:19
需要有好心人幫忙 review, 應該是相對簡單的功能。感謝~~~
另外 CI 有報錯,但錯的地方不是我這次有修改的地方,那是我這邊需要修好後 commit 嗎?
https://github.com/Ptt-official-app/Ptt-backend/pull/85

#85 usecase for get popular articles

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/83|#83> *:memo: 相關的 issue / Related Issues* • 支線 <https://github.com/Ptt-official-app/Ptt-backend/issues/83|#83> • 主線 <https://github.com/Ptt-official-app/Ptt-backend/issues/50|#50> *:pick: 變更內容 / Details of Changes* • usecase 新增 article.go, 實作 GetPopularArticles() • usecase 新增 article_test.go &amp; article_mock_test.go 以測試 usecase.GetPopularArticles() • repository 新增 article.go,定義 GetPopularArticles(),沒有實作內容 目前相關邏輯是單獨拉到 article.go,並沒有放在 board.go。 主要是覺得可以跟 board 脫鉤,但如果大家覺得沒必要的話可以再移回 board.go

你的 MockUsecase 可能要再幫他補一下 GetPopularArticles 的實作
沒看清楚誤會了,感謝~
👍 1
Amos Chang 18:58:01
@wagaru 的 PR 會用到的介面看起來 go-bbs 沒有開出來
我先幫 repository 做了 mock,希望有人能幫忙 review
當中 follow @wagaru 的作法把東西放在 article.go 裡面了

https://github.com/Ptt-official-app/Ptt-backend/pull/87

#87 Add mock for repository.GetPopularArticleRecords

and repository.BBSPopularArticleRecord since go-bbs has not implemented it yet *:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/86|#86> *:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/50|#50> *:pick: 變更內容 / Details of Changes* • add `BBSPopularArticleRecord` to mock `bbs.PopularArticleRecord` since go-bbs has not implemented it yet • add `GetPopularArticles()` to interface `Repository`

回應了
PTT 目前有哪邊會顯示熱門文章嗎?
印象中 Maple 系統有,但是 PTT 系統有嗎?
👍 2

2021-02-22

pichuchen 02:43:17
我的 git 和 gpg 終於修好了 https://github.com/Ptt-official-app/go-bbs/pull/50/files

再請大家幫忙 review 一下
👍 3
陳昱廷 11:35:00
這邊提醒大家一下,記得如果有新增測試檔案的話 pr 要 assign 給我,這樣 github 才會提醒我該工作了
👍 2
陳昱廷 12:25:41
大家幫忙看一下兩條線同步後的 pr
陳昱廷 12:33:04
https://github.com/Ptt-official-app/Ptt-backend/pull/91

#91 Development enable lint

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/88|#88> *:pick: 變更內容 / Details of Changes* 修正測試

陳昱廷 12:33:21
改道正確的 branch,大家幫忙看一下
陳昱廷 16:45:14
https://github.com/Ptt-official-app/Ptt-backend/issues/93

#93 [建議] errcheck 是否有必要

*相關 issue* • <https://github.com/Ptt-official-app/Ptt-backend/issues/90|#90> *原本作法的問題 / Existed Problem* 以目前 ci 的狀況看起來 errcheck fail 為大宗,目前看起來都是在 call io 相關沒有檢查 bytes 是否不為0 *實作細節 / Details of Implement* 增加 golangci.yaml 移除 io 相關 errcheck *期程 / Schedule* 無 *相關文件 / Documents* <https://golangci-lint.run/usage/configuration/|https://golangci-lint.run/usage/configuration/>

陳昱廷 16:45:22
有個議題要討論的
陳昱廷 16:45:30
大家有空可以討論一下

2021-02-23

c510w995 00:18:40
這個 PR 需要有人幫忙 Review. 再麻煩多幫忙 感謝

https://github.com/Ptt-official-app/Ptt-backend/pull/96
陳昱廷 12:26:26
回了
pichuchen 12:54:42
有個問題我覺得需要討論一下,驗證 Token 的這件事應該要在 usecase 做還是在 delivery 做?
Julian Chu 2021-02-24 04:45:08
驗證邏輯在usecase做, 在delivery套驗證的middleware是比較常見的作法
不過目前還沒有所謂驗證的 middleware, 也就是接下來驗證邏輯應該會逐漸轉移到 usecase 這樣?
Julian Chu 2021-02-24 16:16:55
middleware只是個function closure而已晚一點添加沒差,後面可能還要設計是global middleware或是特定route的。
對 會這樣建議, 好處是可以把驗證的測試單獨抽出來,同時如果要引入http以外的通訊方式,驗證邏輯可以通用
pichuchen 13:15:16
https://github.com/Ptt-official-app/Ptt-backend/issues/51#issuecomment-783895477

Comment on #51 [主線] [PTT] 實作熱門看板的看板列表

熱門看板實作方式目前有東西需要討論: 首先在原本的 BBS 系統當中「熱門看板」和「看板列表」是不太一樣的概念,熱門看板並不是單純的「版上人數很多的看板」,他還必須要符合一些條件,例如說他不能是隱藏看板,例如版主版或者是只限定版友進入的個人看板他就不能被列為熱門看板,再來是有些看板他可以設定成不得進入熱門看板等等。 也就是說,熱門看板的列表=篩選條件,可以透過 go-bbs 判斷後回傳,或者是應該透過 usecase 統一判斷熱門看板的商業邏輯後回傳。 因此這邊有兩種可能的實作方式: 1. go-bbs 新增 getPopularBoard 函式,統一判斷熱門看板列表 2. go-bbs 部分統一利用 getBoard 函式回傳,由 Ptt-backend 的 Usecase 透過看板屬性後在 usecase 進行判斷 以上需要請各位提供意見及討論。

pichuchen 13:15:28
有個問題需要請大家討論一下
陳昱廷 17:38:34
https://github.com/Ptt-official-app/Ptt-backend/pull/99

#99 修正無用函數跟簡化宣告

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/94|#94> *:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/90|#90> *:pick: 變更內容 / Details of Changes* 移除無用函數以及簡化宣告

有一段註解我覺得要清理一下
哪段?
陳昱廷 17:38:47
先把沒有需要討論的部分 lint 修了一下

2021-02-24

蕭馬克 10:08:16
@marc47marc47 has joined the channel
陳昱廷 16:34:51
https://github.com/Ptt-official-app/Ptt-backend/pull/103

#103 修正 errcheck

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/90|#90> *:memo: 相關的 issue / Related Issues* • <https://github.com/Ptt-official-app/Ptt-backend/issues/93|#93> *:pick: 變更內容 / Details of Changes* 修正 errcheck,主要分為兩大塊 1. ResponseWriter 2. Json

陳昱廷 16:35:00
修正了 errcheck
陳昱廷 16:35:17
大家有空可以 review 一下
陳昱廷 16:35:37
預計接下來會修 golint 跟 goimports
shihgangliu 19:40:34
@shihgangliu has joined the channel

2021-02-25

Kay 13:38:43
我們公司好像SLACK可以吃最近PR通知
Kay 13:39:03
不知道能不能把它弄到這個CHANNEL這樣似乎通知可以自動化
Kay 13:39:34
突然想到,該不會是付費功能吧(?)
Kay 13:40:31
image.png
Kay 13:43:04
image.png
1
Kay 13:43:09
看起來有,再研究看看
Rico 17:42:58
最近在討論專案 golang 版本,請問大家有什麼看法?
https://github.com/Ptt-official-app/Ptt-backend/pull/104
Julian Chu 2021-02-25 18:43:46
為了M1還是升1.16吧~
那我先把他合併起來,之後有問題之後再說
陳昱廷 18:02:20
https://github.com/Ptt-official-app/Ptt-backend/pull/105

#105 fix goimports

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/90|#90> *:memo: 相關的 issue / Related Issues* *:pick: 變更內容 / Details of Changes* 使用 goimports 自動修正

👍 1
陳昱廷 18:02:30
大家有空可以 review 一下

2021-02-26

陳昱廷 16:52:47
https://github.com/Ptt-official-app/Ptt-backend/pull/106

#106 修正了除了 interface 跟 mock 以外的 id

*:clap: 解決掉的 issue / Resolved Issues* • close <https://github.com/Ptt-official-app/Ptt-backend/issues/90|#90> *:pick: 變更內容 / Details of Changes* 修正 id to ID

陳昱廷 16:53:12
目前需要一個人幫我把 go-bbs 那邊的 Id 改為 ID 才行
陳昱廷 16:53:39
ptt-backend 就欠 interface 跟 mock 部份了
陳昱廷 16:53:49
大家有空可以 review
pichuchen 22:26:42
我把他合併了

2021-02-27

allmwh 23:18:59
@jonas870103 has joined the channel

2021-02-28

Timo Chiang 15:13:45
Hello~這邊有兩個功能需要有人來幫忙實作,有興趣的人可以在issue下面留言認領並一起討論細節~
https://github.com/Ptt-official-app/Ptt-backend/issues/60
https://github.com/Ptt-official-app/Ptt-backend/issues/61

#60 [主線] [PTT] 實作個人看板歷史留言

#61 [主線] [PTT] 實作儲存草稿

whitefloor 18:14:27
Hi,各位好,我也剛認領了一個issue想找夥伴一起處理,issue如網址所示,感謝
https://github.com/Ptt-official-app/Ptt-backend/issues/59
whitefloor 2021-03-01 15:39:42
文件中的router,正要問的時候就突然看到,給各位參考
/v1/users/{{user_id}}/articles
kuo-chuan weng 2021-03-02 11:06:43
我可以幫忙 我會去issue 底下留言
whitefloor 2021-03-02 14:16:06
好der 感謝
whitefloor 2021-03-03 12:27:59
我整理一下現在的進度
whitefloor 2021-03-03 12:31:03
1. ptt-backend的repository需要go-bbs解析,但go-bbs尚未實作
2. 決定與go-bbs一起實作,這樣在ptt-backend就不需要做mock
3. 在go-bbs實作時需要開issue
4. ptt-backend串接go-bbs時需要在go.mod增加版本號碼0.2.5 > 0.2.6
whitefloor 2021-03-03 22:30:14
@xboxa5105
whitefloor 2021-03-03 22:30:18
issue開好了
whitefloor 2021-03-03 22:41:58
可能要請你過去留個言pichu才能assign給你 我沒權限
whitefloor 2021-03-03 22:42:03
如果有問題再跟我說~
kuo-chuan weng 2021-03-04 10:15:40
好的
❤️ 1