KED-2020 / api-mind-map

1 stars 1 forks source link

Delete the Suggestion Entity & reuse Document Entity? #5

Closed Kyeg closed 3 years ago

Kyeg commented 3 years ago

Currently, the Suggestion Entity in the Inboxes Domain and the Document Entity in the Favorites Domain reuse the same database table. However, it seems some differences between these two entities. As following example, the Document Entity (e.g. id 2292) has origin_id, while the Suggestion Entity (e.g. id 2262~2291) does not.

Maybe we can delete the Suggestion Entity & reuse Document Entity afterwards? Any suggestion?

> MindMap::Database::DocumentOrm.all
+------+-----------+---------------------------------+---------------------------------+---------------------------------+---------------------------+---------------------------+
| id   | origin_id | name                            | description                     | html_url                        | created_at                | updated_at                |
+------+-----------+---------------------------------+---------------------------------+---------------------------------+---------------------------+---------------------------+
| 2262 |           | tensorflow                      | An Open Source Machine Learn... | https://github.com/tensorflo... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
| 2263 |           | TensorFlow                      | Project containig related ma... | https://github.com/romeokien... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
| 2264 |           | TensorFlow-Examples             | TensorFlow Tutorial and Exam... | https://github.com/aymericda... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
| 2265 |           | tensorflow2_tutorials_chinese   | tensorflow2中文教程,持续更...  | https://github.com/czy36meng... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
...
| 2289 |           | EffectiveTensorflow             | TensorFlow tutorials and bes... | https://github.com/vahidk/Ef... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
| 2290 |           | stylegan                        | StyleGAN - Official TensorFl... | https://github.com/NVlabs/st... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
| 2291 |           | TensorFlow-Tutorials            | Simple tutorials using Googl... | https://github.com/nlintz/Te... | 2020-12-09 22:41:48 +0800 | 2020-12-09 22:41:48 +0800 |
| 2292 | 165785822 | derrxb                          | My space online for my photo... | https://github.com/derrxb/de... | 2020-12-09 22:44:58 +0800 | 2020-12-09 22:44:58 +0800 |
+------+-----------+---------------------------------+---------------------------------+---------------------------------+---------------------------+---------------------------+
Kyeg commented 3 years ago

In following example, id 2551 is a suggestion, and id 2581 is a document.

> MindMap::Database::DocumentOrm.all
+------+-----------+---------------------------------+---------------------------------+---------------------------------+---------------------------+---------------------------+
| id   | origin_id | name                            | description                     | html_url                        | created_at                | updated_at                |
+------+-----------+---------------------------------+---------------------------------+---------------------------------+---------------------------+---------------------------+
| 2551 |           | tensorflow                      | An Open Source Machine Learn... | https://github.com/tensorflo... | 2020-12-09 23:11:48 +0800 | 2020-12-09 23:11:48 +0800 |
| 2552 |           | TensorFlow                      | Project containig related ma... | https://github.com/romeokien... | 2020-12-09 23:11:48 +0800 | 2020-12-09 23:11:48 +0800 |
...
| 2580 |           | TensorFlow-Tutorials            | Simple tutorials using Googl... | https://github.com/nlintz/Te... | 2020-12-09 23:11:48 +0800 | 2020-12-09 23:11:48 +0800 |
| 2581 | 165785822 | derrxb                          | My space online for my photo... | https://github.com/derrxb/de... | 2020-12-09 23:25:30 +0800 | 2020-12-09 23:25:30 +0800 |
+------+-----------+---------------------------------+---------------------------------+---------------------------------+---------------------------+---------------------------+

If we try to access the suggestion from the database, some error will be caused. Maybe because the format of suggestion is different from the document. (Maybe because DRY-STRUCT does not prefer a nil origin_id? I seem occur this error before.)

> http localhost:9000/api/v1/favorites/documents/2551

HTTP/1.1 500 Internal Server Error
Content-Length: 66
Content-Type: application/json

{
    "message": "Could not access database.",
    "status": "internal_error"
}
> http localhost:9000/api/v1/favorites/documents/2581

HTTP/1.1 200 OK
Content-Length: 319
Content-Type: application/json

{
    "description": "My space online for my photography and software development thoughts",
    "html_url": "https://github.com/derrxb/derrxb",
    "links": [
        {
            "href": "http://localhost:9090/api/v1/inboxes/derrxb",
            "rel": "self"
        }
    ],
    "name": "derrxb",
    "origin_id": 165785822,
    "topics": [
        {
            "name": "blog"
        },
        {
            "name": "photography"
        },
        {
            "name": "portfolio"
        }
    ]
}