codebuddies / backend

CodeBuddies back-end
https://codebuddies.org
GNU General Public License v3.0
20 stars 25 forks source link

[API] [Sample Data] Projects API projects.json Fixture #76

Closed lpatmo closed 4 years ago

lpatmo commented 4 years ago

Context

In preparation for the /api/v1/projects endpoint, we'll need a fixtures file for projects.json

Acceptance criteria

[ ] Create a projects.json fixtures file [ ] Include 10 blocks of sample data inside it

 {
    "model":"projects.project",
    "guid":"02ef2aaa-da96-11e9-8a1f-d20089b01401",
    "fields":{
       "title":"webpack",
       "creator":"Tobias Koppers",
       "description":"open-source JavaScript module bundler",
       "url":"https://github.com/webpack/webpack",
       "user":8,
       "date_published":"2019-09-19T04:29:04Z",
       "created":"2019-09-19T04:29:04.069Z",
       "modified":"2019-09-19T04:29:04Z",
       "open_to_contributors":true,
       "contributors": [1, 9, 3, 8, 23, 19, 23]
    }
 },
BethanyG commented 4 years ago

Ooof. Apologies for all the back and forth. Made a separate issue for the JSON spec, as I think we have some details to iron out that will create noise here. Three things to note about fixtures from the backend perspective:

  1. The guid right now is randomly generated by the ORM code on insert..and I suspect because of the type (UUID1 -- see this for details), it is always generated. Having a guid listed in a fixture (or a POST for that matter) gets ignored - it changes each time the fixture is loaded or a POST is made. I view that as a bug (of sorts), but need to track down exactly why that's happening, and how to stop it.

  2. Cooking up data is great at sussing out how things might look and for mocking from the front end..but its really hard to modify data like this as the underlying spec changes (which is likely as we talk more about what goes in it), so I strongly recommend having a model discussion or spec discussion as a linked issue. ...And not making very many mocked records until we are clear on what the api requirements are.

  3. Fixture JSON can be automatically generated (see this on fixtures from Django docs) by running manage.py dumpdata <app name.model name> (https://docs.djangoproject.com/en/3.0/ref/django-admin/#django-admin-dumpdata), once there is data in the DB.

lpatmo commented 4 years ago

@bkbuilt Sorry I didn't realize sooner that fixtures can be generated from models via manage.py dumpdata <app name.model name> -- but the example data you've created would be useful, so feel free to dump that in here! Thanks!

bkbuilt commented 4 years ago

Hi sorry here is the file just in case it ends up being useful for something. `[ { "model":"projects.project", "guid":"02ef2aaa-da96-11e9-8a1f-d20089b01401", "fields":{ "title":"webpack", "creator":"Tobias Koppers", "description":"open-source JavaScript module bundler", "url":"https://github.com/webpack/webpack", "user":8, "date_published":"2019-09-19T04:29:04Z", "created":"2019-09-19T04:29:04.069Z", "modified":"2019-09-19T04:29:04Z", "open_to_contributors":true, "contributors": [1, 9, 3, 8, 23, 19, 24] } },

{
    "model":"projects.project",
    "guid":"1f1969d2-da98-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"Babel",
        "creator":"Sebastian McKenzie",
        "description":"open-source JavaScript transcompiler",
        "url":"https://github.com/babel/babel",
        "user":21,
        "date_published":"2019-09-19T04:44:10Z",
        "created":"2019-09-19T04:44:10.315Z",
        "modified":"2019-09-19T04:44:10Z",
        "open_to_contributors":true,
        "contributors": [1, 3, 6, 5, 21, 20, 24]
    }
},

{
    "model":"projects.project",
    "guid":"2602cd16-da92-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"Material-UI",
        "creator":"Olivier Tassinari",
        "description":"provides React components for faster and easier web development",
        "url":"https://github.com/mui-org/material-ui",
        "user":22,
        "date_published":"2019-09-19T04:01:24Z",
        "created":"2019-09-19T04:01:24.931Z",
        "modified":"2019-09-19T04:01:24Z",
        "open_to_contributors":true,
        "contributors": [1, 6, 4]
    }
},

{
    "model":"projects.project",
    "guid":"27831670-da95-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"vue",
        "creator":"Evan You",
        "description":"progressive framework for building user interfaces",
        "url":"https://github.com/vuejs/vue",
        "user":3,
        "date_published":"2019-09-19T04:22:55Z",
        "created":"2019-09-19T04:22:55.939Z",
        "modified":"2019-09-19T04:22:55Z",
        "open_to_contributors":true,
        "contributors": [2, 8, 19, 23]
    }
},

{
    "model":"projects.project",
    "guid":"2d55f8d8-da8b-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"CryptPad",
        "creator":"Caleb James De Lisle",
        "description":"encrypted drive & collaborative editor",
        "url":"https://github.com/xwiki-labs/cryptpad",
        "user":18,
        "date_published":"2019-09-19T03:11:30Z",
        "created":"2019-09-19T03:11:30.743Z",
        "modified":"2019-09-19T03:11:30Z",
        "open_to_contributors":true,
        "contributors": [9, 3, 8]
    }
},

{
    "model":"projects.project",
    "guid":"2dba3384-da90-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"ESLint",
        "creator":"Nicholas C. Zakas",
        "description":"static code analysis tool for identifying problematic patterns found in JavaScript code",
        "url":"https://github.com/eslint/eslint",
        "user":20,
        "date_published":"2019-09-19T03:47:18Z",
        "created":"2019-09-19T03:47:18.883Z",
        "modified":"2019-09-19T03:47:18Z",
        "open_to_contributors":true,
        "contributors": [8, 24]
    }
},

{
    "model":"projects.project",
    "guid":"2fbcc748-da8e-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"Open Source Broadcaster",
        "creator":"Hugh Bailey",
        "description":"free and open source software for video recording and live streaming",
        "url":"https://github.com/obsproject/obs-studio",
        "user":15,
        "date_published":"2019-09-19T03:33:03Z",
        "created":"2019-09-19T03:33:03.262Z",
        "modified":"2019-09-19T03:33:03Z",
        "open_to_contributors":true,
        "contributors": [23, 19]
    }
},

{
    "model":"projects.project",
    "guid":"375969f6-da8a-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"nest",
        "creator":"Kamil Mysliwiec",
        "description":"progressive NodeJS framework for building efficient and scalable server-side applications",
        "url":"https://github.com/nestjs/nest",
        "user":11,
        "date_published":"2019-09-19T03:04:38Z",
        "created":"2019-09-19T03:04:38.046Z",
        "modified":"2019-09-19T03:04:38Z",
        "open_to_contributors":true,
        "contributors": [17, 24]
    }
},

{
    "model":"projects.project",
    "guid":"3e67a8ee-da93-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"peermaps",
        "creator":"James Halliday",
        "description":"peer to peer cartography",
        "url":"https://github.com/peermaps/peermaps",
        "user":5,
        "date_published":"2019-09-19T04:09:15Z",
        "created":"2019-09-19T04:09:15.354Z",
        "modified":"2019-09-19T04:09:15Z",
        "open_to_contributors":true,
        "contributors": [5, 23, 19, 24]
    }
},

{
    "model":"projects.project",
    "guid":"5b14d9c2-da8d-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"Nuxt.js",
        "creator":"Alexandre Chopin",
        "description":"web application framework based on Vue.js",
        "url":"https://github.com/nuxt/nuxtjs.org",
        "user":17,
        "date_published":"2019-09-19T03:27:06Z",
        "created":"2019-09-19T03:27:06.485Z",
        "modified":"2019-09-19T03:27:06Z",
        "open_to_contributors":true,
        "contributors": [7, 8, 19]
    }
},

{
    "model":"projects.project",
    "guid":"66c77394-da9a-11e9-8a1f-d20089b01401",
    "fields":{
        "title":"Aurelia",
        "creator":"Rob Eisenberg",
        "description":"a standards-based, front-end framework designed for high-performing, ambitious applications",
        "url":"https://github.com/aurelia/aurelia",
        "user":4,
        "date_published":"2019-09-19T05:00:29Z",
        "created":"2019-09-19T05:00:29.567Z",
        "modified":"2019-09-19T05:00:29Z",
        "open_to_contributors":true,
        "contributors": [1, 2, 3, 4, 5, 6]
    }
}

]`

billglover commented 4 years ago

My understanding is that are comfortable that the documentation of fixture data is sufficient and that there is no need for this to be committed as a projects.json file for the application. I'm closing this issue for now, but please re-open if my understanding is incorrect.