Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project title as unique ID #2

Closed
ghost opened this issue Oct 30, 2018 · 12 comments
Closed

Project title as unique ID #2

ghost opened this issue Oct 30, 2018 · 12 comments
Labels
data model data model change or db tweak

Comments

@ghost
Copy link

ghost commented Oct 30, 2018

Given that the value is unpredictable and the usage of the value as ID is uncertain, suggest drop the property.

@ghost ghost added this to To do in API v0 development Nov 13, 2018
@ghost
Copy link
Author

ghost commented Nov 20, 2018

@trashmai 我們現在還是用 project title 來當 uniqueID 嗎?

@ghost ghost added the data model data model change or db tweak label Nov 23, 2018
@ghost ghost added this to the 計畫資料管理及更新 W1 WF2 WF3 milestone Nov 23, 2018
@kelp404
Copy link
Collaborator

kelp404 commented Nov 25, 2018

I will fix it today.

@oahehc
Copy link

oahehc commented Nov 25, 2018

補充 & 提醒一下,
目前已經有個 projectId (計畫編號) 是讓 user 自行 key in 且可以編輯的,
所以這邊應該是會另外產生 unique key for project 對嗎?

image

kelp404 added a commit that referenced this issue Nov 25, 2018
@kelp404
Copy link
Collaborator

kelp404 commented Nov 25, 2018

@oahehc 改過去了 b37e14f

@oahehc
Copy link

oahehc commented Nov 25, 2018

@kelp404

  1. 如上面 comment 所提, projectId 目前是被使用在計畫編號, 是 user 手動 key in 且可以編輯的欄位, 直接拿來作為 project key 是否適合建議再評估一下
  2. 權限中請協助加上 project unique key, 目前只給 title & roles 可能會 mapping 不到正確的權限
endpoint GET /ctp-user/me

image

@kelp404
Copy link
Collaborator

kelp404 commented Nov 25, 2018

We need to check all logic about Project.
like this:
https://github.com/TaiBIF/camera-trap-api/blob/master/common/models/project.js#L49

@ghost
Copy link
Author

ghost commented Nov 25, 2018

Hi both,
We should indeed review this. I'd suggest:

  1. change the current "projectId" to "adminProjectId" since it's user input and not mandatory
  2. add an automatically generated projectId field for mongoDB identity use and for /ctp-user/me alike
  3. update documentation.

makes sense?

@kelp404
Copy link
Collaborator

kelp404 commented Nov 25, 2018

2018-11-25 3 29 40

請問 projectId 對應到前端是「計畫編號」嗎? 如果是的話也不能用 projectId,任何能修改的東西不應該當作 id 使用。

我剛剛去掃了目前的專案後發現一堆用 projectTitle 在當作參考的邏輯,整個處理完可能需要花掉一天,包含處理資料庫內現有的資料。
我覺得用 MongoDB 給的 _id 是比較好的,id 的產生其實是一件很複雜的事情,例如兩台機器同時產生大量 id 時會不會重複...等問題,交由資料庫系統處理比較好。

就依照 @cjk-halodule 說的將現有 Project.projectId 改名成 Project.adminProjectId,然後再開一個 Project.projectId 內容是由 MongoDB 產生的 unique id。

@ghost
Copy link
Author

ghost commented Nov 25, 2018

3.1.3 的欄位就應該用新創的 adminProjectId 了 - 這個也得在前端的程式中更新
其它完全同意

@oahehc
Copy link

oahehc commented Nov 25, 2018

同意以上做法

@diabloevagto 前端應該也有不少地方要同步調整, 再幫忙留意一下

@diabloevagto
Copy link

diabloevagto commented Nov 25, 2018

是不是該考慮趁這個機會把所有 api 都重新定義過?目前 api 定義完全沒考慮前端跟 wf
目前的 api 其實開得非常糟糕,說真的前端專案我認為已經失控了

ghost pushed a commit to TaiBIF/camera-trap-webapp that referenced this issue Nov 25, 2018
ghost pushed a commit that referenced this issue Nov 25, 2018
ghost pushed a commit that referenced this issue Nov 25, 2018
This reverts commit 753593a.
ghost pushed a commit to TaiBIF/camera-trap-webapp that referenced this issue Nov 26, 2018
ghost pushed a commit that referenced this issue Nov 26, 2018
ghost pushed a commit to TaiBIF/camera-trap-webapp that referenced this issue Nov 26, 2018
@kelp404 kelp404 assigned ghost and unassigned kelp404 Nov 27, 2018
@ghost ghost mentioned this issue Nov 27, 2018
ghost pushed a commit to TaiBIF/camera-trap-webapp that referenced this issue Nov 27, 2018
@ghost
Copy link
Author

ghost commented Dec 2, 2018

This has proceeded to nearly done. Reopen only when an issue emerges.

@ghost ghost closed this as completed Dec 2, 2018
API v0 development automation moved this from To do to Done Dec 2, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data model data model change or db tweak
Projects
No open projects
Development

No branches or pull requests

3 participants