gcivil-nyu-org / spring2020-cs-gy-9223-backend

0 stars 2 forks source link

Create a new data model #43

Closed Ziheng-Wang closed 4 years ago

Ziheng-Wang commented 4 years ago

This pull & request is for new change of database model.

VentusXu09 commented 4 years ago

Some problems I found in new Models:

  1. In order to add a new GeneralData model, I need to assign Event model instead of event_id. Same as field_id and sensor_id. Actually, we can handle this with query, but it’s a bit complex. :)
  2. Here are two piece of data I wanna add: sensor_id : 1 event_id : 1 field_id : 1 data_value : 1.11 and sensor_id : 1 event_id : 1 field_id : 2 data_value : 2.22 Then I received the following error: UNIQUE constraint failed: mercury_generaldata.sensor_id_id It seems that the constraint: unique_together = ((“event_id”, “sensor_id”, “field_id”),) It requires all three ids being unique respectively.
  3. Missing codes in form.py
  4. Register models in admin.py if you wanna modify database on the admin page.

One suggestion for model design: In order to check the logic error in models, write a fake API function with fake data in view.py and try to call it with postman.

VentusXu09 commented 4 years ago

In models.py, we have two models EventCodeAccess and Events. Should we make some connection between these two models?

Ricardo-1894 commented 4 years ago

In models.py, we have two models EventCodeAccess and Events. Should we make some connection between these two models?

Good point, I think we should do some change to the current Events data model, I will add "enabled" attribute to it.