OH-SHOWN / ohshown-backend

OH!SHOWN 野生動物出沒痕跡通報系統
http://ohshown.site
MIT License
2 stars 8 forks source link

[Umbrella Issue] FE request for the new questionnaire template #44

Closed EagleC0318 closed 1 year ago

EagleC0318 commented 2 years ago

Is your feature request related to a problem? Please describe. We have new questionnaire template in the FE, including a lot of new fields. However, the BE server is still working with the old (disfactory) fields. We should sync the BE API/DB schema/Admin with the FE new questionnaire template.

Describe the solution you'd like

  1. BE API: Update the BE code for the API server/api/factories to process new fields from FE (field list?).
  2. DB Schema: Modify the DB Schema to store the new fields (do we need more tables or just the api_ohshownevent?)
  3. Admin: Update the django admin to integrate the fields from new questionnaire.

Describe alternatives you've considered NO IDEA (Start from scratch??).

Additional context Add any other context or screenshots about the feature request here.

EagleC0318 commented 2 years ago

@tai271828 Any comments for breaking down this issue? @Neilxx and I think this is the first priority issue for BE to sync with the new FE questionnaire.

tai271828 commented 2 years ago

The first thing that came to my mind:

  1. refactoring BE to make sure that we migrated from "factories" to "ohshown". That being said, server/api/ohshown_events will replace server/api/factories in the end.
  2. in the meantime, use a new table for the new questionnaire, so we won't impact anyone who is interested in making a questionnaire. That being said, a new API e.g. server/api/ohshown_events_ng is also suggested from my point of view.
  3. admin console: no matter it's 1 or 2 implemented first, we will modify or make a corresponding session for them.

@tai271828 Any comments for breaking down this issue? @Neilxx and I think this is the first priority issue for BE to sync with the new FE questionnaire.

EagleC0318 commented 2 years ago

The first thing that came to my mind:

  1. refactoring BE to make sure that we migrated from "factories" to "ohshown". That being said, server/api/ohshown_events will replace server/api/factories in the end.
  2. in the meantime, use a new table for the new questionnaire, so we won't impact anyone who is interested in making a questionnaire. That being said, a new API e.g. server/api/ohshown_events_ng is also suggested from my point of view.
  3. admin console: no matter it's 1 or 2 implemented first, we will modify or make a corresponding session for them.

@tai271828 Any comments for breaking down this issue? @Neilxx and I think this is the first priority issue for BE to sync with the new FE questionnaire.

For 1. looks like we need to change backend/api/urls.py and fix the unit tests

yanghaochang104 commented 2 years ago

pre-requisite:

raw data from frontend (「目擊黑熊」form)

{
  "type": "2-1",    // 「我要通報... 」欄位的選項      
  "datetime": 1646844000000 // 選取的日期時間timestamp

  "groundTypes": ["森林(天然林)", "道路(馬路)", "農牧用地(禽舍)"],     // 環境地貌- 土地類型
  "vegetations": ["闊葉林", "裸露地"],    // 環境地貌 - 植被
  "bearAttractors": ["自然食物資源", "動物屍體"], // 環境地貌 - 可能吸引熊的物品

  "humanNumber": "1",
  "humanBehavior": 0,
  "humanBehaviorText": "",
  "distance": 3,
  "bearBehavior": 2,
  "bearBehaviorText": "",
  "food": 0,
  "foodText": "",
  "bearNotice": 0,
  "bearNoticeMinutes": 0,
  "humanReaction": 1,
  "humanReactionText": "",
  "bearReaction": [1, 2],
  "humanHurt": "0",
  "humanHurtExplanation": "",
  "ohShownAgain": "1",
  "ohShownAgainReason": "",

  "contactName": "test1",   // 姓名
  "contactPhone": "0900-000-000",  // 電話
  "contactMail": "testemail@test.com",  // email
  "agree": true,    // 同意licence

  "bearNumber": 3,  // 「填寫目擊黑熊問卷」 黑熊數量
  "bears": [ // 每隻黑熊的資料
    {
      "bearType": 0,
      "bearSize": 1,
      "bearSizeNumber": 5,
      "bearSex": 0,
      "bearFeature": "test1"
    },
    {
      "bearType": 1,
      "bearSize": 1,
      "bearSizeNumber": 3,
      "bearSex": 0,
      "bearFeature": "test2"
    },
    {
      "bearType": 0,
      "bearSize": 1,
      "bearSizeNumber": 50,
      "bearSex": 1,
      "bearFeature": "test3"
    }
  ],
  "lng": 120.48504632216294, // 經度
  "lat": 24.088258816482295, // 緯度
  "images": [], // 圖片的source path (使用imgur)
 
}
yanghaochang104 commented 2 years ago

derivative tables: 截圖 2022-03-13 下午4 26 25

Neilxx commented 2 years ago

I already open a FE PR which update questionaire as newest one @EagleC0318 feel free to ask any question about questionaire which might blocking you doing BE refactoring!

Neilxx commented 2 years ago

additional information about questionaire: (also based on the new questionaire mentioned above) (not complete data FE send to BE)

// 表單基礎資訊
type: undefined, // 通報類型
alreadyOhshown: undefined, // 在這之前是否曾看過野外的台灣黑熊
alreadyOhshownNumber: undefined, // 在這之前是否曾看過野外的台灣黑熊-次數

// 環境地貌
groundTypes: [], // 土地類型
vegetations: [], // 植被
bearAttractors: [], // 附近可能吸引熊接近的物品

// 個體資訊
bearNumber: undefined, // 目擊個體數
bearType: [], // 個體種類(成熊、幼熊)
bearSize: [], // 體型
bearSex: [], // 性別
bearFeature: [], // 其他特徵

// 黑熊行為與反應
ohshownFeeling: '', // 看到熊當下,目擊者的感覺
humanNumber: undefined, // 目擊熊當下人數
humanBehavior: undefined, // 目擊者目擊當下在做什麼
humanBehaviorText: '', // 目擊者目擊當下在做什麼-文字補充
distance: undefined, // 目擊當下,目擊者與熊之間的距離
bearBehavior: undefined, // 目擊當下,熊在做什麼
bearBehaviorText: '', // 目擊當下,熊在做什麼-文字補充
food: [], // 黑熊食物
foodText: {}, // 黑熊食物-文字補充
bearNotice: undefined, // 黑熊何時注意到人員存在
bearNoticeMinutes: undefined, // 目擊後約X分鐘黑熊發現人員存在-數字補充
humanReaction: [], // 目擊黑熊後,目擊者反應
humanReactionText: '', // 目擊者反應-文字補充
bearReaction: [], // 黑熊發現目擊者後,黑熊的反應
bearReactionText: '', // 黑熊反應-文字補充
humanHurt: undefined, // 是否有人受傷或意外發生
humanHurtDescription: '', // 是否有人受傷或意外發生-文字補充

// 發現黑熊痕跡
traceType: undefined, // 痕跡類型
traceTypeText: '', // 痕跡類型-文字補充
freshness: undefined, // 新舊估計
freshnessNumber: undefined, // 新舊估計-數字補充
imageAvailable: undefined, // 是否提供影像檔案
otherInfo: '', // 其他補充說明

// 下一次,如果有機會的話
ohShownAgain: undefined, // 目擊者是否希望以後再看到野外的黑熊
ohShownAgainReason: '', // 目擊者是否希望以後再看到野外的黑熊-原因
preventOhshownMethods: [], // 您知道以下哪些做法有助於減少遇到熊的機會,或避免不愉快地與熊相遇
preventOhshownMethodsText: '', // 您知道以下哪些做法有助於減少遇到熊的機會,或避免不愉快地與熊相遇-文字補充
surveyIfBearExist: undefined // 您是否會先了解您預計前往的地點有無黑熊出沒
tai271828 commented 2 years ago

@yanghaochang104 @EagleC0318 any progress or blocker? Do you need any help?

EagleC0318 commented 2 years ago

Sorry I am quite busy recently and didn't have time to work on that. We might need to sync up the current status. @yanghaochang104 You're still working on building the satellite tables, right? How's going? @tai271828 I remember you fixed the old table. Maybe we can treat the old table as the main table (i.e. 回報主表), and link with the satellite tables. WDYT?

tai271828 commented 2 years ago

Both works for me. I personally will keep working on the "old" table as what I have already done. Please keep going on what you prefer, and I will help review the code.

Sorry I am quite busy recently and didn't have time to work on that. We might need to sync up the current status. @yanghaochang104 You're still working on building the satellite tables, right? How's going? @tai271828 I remember you fixed the old table. Maybe we can treat the old table as the main table (i.e. 回報主表), and link with the satellite tables. WDYT?

diaoga commented 2 years ago

Base on discussion on 6/22, we will split this issue into different table.

Neilxx commented 1 year ago

done