From 0c90e738426605a622061fa99457e4d73cfc6a85 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Tue, 3 Oct 2023 16:51:30 +0100 Subject: [PATCH] outline tidy schema https://github.com/dwyl/tidy/issues/1 --- README.md | 3 +- src/SUMMARY.md | 3 +- src/fields/02-schema.md | 4 ++ src/tidy/01-setup.md | 6 +-- src/tidy/02-schema.md | 87 ++++++++++++++++++++--------------------- src/tidy/README.md | 5 ++- 6 files changed, 57 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index a79ef9a..7b4ab45 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,8 @@ If you don't already, see: # Contributing To help us improve the book, -the easiest way is to edit it directly on `GitHub`: +the easiest way is to +`edit` it directly on `GitHub`: [dwyl/book/src](https://github.com/dwyl/book/tree/main/src) While reading the book online, diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 1c3017c..ef956f3 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -26,4 +26,5 @@ - [Add `item` to `list`](mvp/19-add-item-to-list.md) - [Stats](mvp/20-stats.md) - [Tidy](tidy/README.md) - - [Setup](tidy/01-setup.md) \ No newline at end of file + - [Setup](tidy/01-setup.md) + - [Schema](tidy/02-schema.md) \ No newline at end of file diff --git a/src/fields/02-schema.md b/src/fields/02-schema.md index 31b524f..cd9571c 100644 --- a/src/fields/02-schema.md +++ b/src/fields/02-schema.md @@ -65,3 +65,7 @@ Let's take a moment to go through them and understand what each file is doing. ### `lib/fields_demo_web/live/attendee_live/show.ex` + + + +https://en.wikipedia.org/wiki/List_of_gender_identities \ No newline at end of file diff --git a/src/tidy/01-setup.md b/src/tidy/01-setup.md index ae8655b..d4b7ccd 100644 --- a/src/tidy/01-setup.md +++ b/src/tidy/01-setup.md @@ -3,7 +3,6 @@ These are the steps we took when creating the `tidy` App. You can follow along at your own pace. -And/or use them as the basis for your own App(s). If you feel we have skipped a step or anything is unclear, @@ -149,8 +148,9 @@ mix setup mix phx.server ``` -> **Tip**: we always create an alias for `mix phx.server` as `mix s` -> The alias will be used for the remainder of this guide. +> **Tip**: we always create an alias +> for `mix phx.server` as `mix s` +> The alias will be used for the remainder of this chapter. With the `Phoenix` server running, visit diff --git a/src/tidy/02-schema.md b/src/tidy/02-schema.md index 31b524f..93ada5d 100644 --- a/src/tidy/02-schema.md +++ b/src/tidy/02-schema.md @@ -1,20 +1,46 @@ -# Create `attendee` schema +# Create `object` schema -The goal is to allow `people` attending **_Awesome_ Conf** - the ***`attendees`*** - +As outlined in +[tidy#1](https://github.com/dwyl/tidy/issues/1), +our goal is to allow `people` +wanting to help `tidy` the house, to submit the following data: -+ `first_name` - how we greet you. Will appear on your conference pass. -+ `last_name` - your family name. Will appear on you conference pass. -+ `email` - to confirm attendance -+ `phone_number` - to verify your access when attending the secret event. -+ `address_line_1` - so we can send the welcome pack and prizes -+ `address_line_2` - if your address has multiple lines. -+ `postcode` - for the address. -+ `gender` - for venue capacity planning. -+ `diet_pref` - dietary preferences for meals and snacks provided at the conference. -+ `website` - share your awesomeness and have it as a QR code on your conference pass. -+ `desc` - brief description of your awesome project. -+ `feedback` - Feedback or suggestions +## `object` + ++ `name` - the name of the `object` you need help with ++ `desc` - brief description of the `object` + including any salient features. ++ `color` - a `string` for main color of the `object` e.g. "green" ++ `person_id` - the `id` of the `person` who created the `object` record. ++ `owner_id` - `id` of the `person` who _owns_ the `object` ++ `location` - a `string` describing _where_ the `object` belongs. ++ `status` - a `int` representing the current `status` of the `object` record. + +> **Note**: we will need to map out the `statuses` required for this App and add them to our list. + + +## `images` + +An `object` can have one or more `images`. +These are used identify and categorize the `object`. + ++ `obj_id` - the `id` of the `object` the `image` belongs to. ++ `person_id` - `id` of the `person` who uploaded the `image`. ++ `url` - the `URL` of the `image` that was uploaded to +[`S3`](https://github.com/dwyl/imgup/issues/98) + + +## `comments` + +An `object` can have one ore more `comments` associated with it. +This allows `people` to discuss the `object` in a conversational style +similar to what they are already used to +from using **Instant Messaging**. + ++ `obj_id` - the `id` of the `object` the `image` belongs to. ++ `person_id` - `id` of the `person` who uploaded the `image`. ++ `text` - the `string` of their comment. ## 4.1 `gen.live` @@ -24,44 +50,17 @@ Using the command, run: ```sh -mix phx.gen.live Accounts Attendee attendees first_name:binary last_name:binary email:binary phone_number:binary address_line_1:binary address_line_2:binary postcode:binary gender:binary diet_pref:binary website:binary desc:binary feedback:binary +mix phx.gen.live Objects Object objects name:binary desc:binary color:binary person_id:integer owner_id:integer location:binary status:integer ``` You should expect to see output similar to the following: ```sh -* creating lib/fields_demo_web/live/attendee_live/show.ex -* creating lib/fields_demo_web/live/attendee_live/index.ex -* creating lib/fields_demo_web/live/attendee_live/form_component.ex -* creating lib/fields_demo_web/live/attendee_live/index.html.heex -* creating lib/fields_demo_web/live/attendee_live/show.html.heex -* creating test/fields_demo_web/live/attendee_live_test.exs -* creating lib/fields_demo/accounts/attendee.ex -* creating priv/repo/migrations/20230928032757_create_attendees.exs -* creating lib/fields_demo/accounts.ex -* injecting lib/fields_demo/accounts.ex -* creating test/fields_demo/accounts_test.exs -* injecting test/fields_demo/accounts_test.exs -* creating test/support/fixtures/accounts_fixtures.ex -* injecting test/support/fixtures/accounts_fixtures.ex - -Add the live routes to your browser scope in lib/fields_demo_web/router.ex: - - live "/attendees", AttendeeLive.Index, :index - live "/attendees/new", AttendeeLive.Index, :new - live "/attendees/:id/edit", AttendeeLive.Index, :edit - - live "/attendees/:id", AttendeeLive.Show, :show - live "/attendees/:id/show/edit", AttendeeLive.Show, :edit - - -Remember to update your repository by running migrations: - - $ mix ecto.migrate + ``` Those are a _lot_ of new files. 😬 Let's take a moment to go through them and understand what each file is doing. -### `lib/fields_demo_web/live/attendee_live/show.ex` +### `` diff --git a/src/tidy/README.md b/src/tidy/README.md index 418a685..393463a 100644 --- a/src/tidy/README.md +++ b/src/tidy/README.md @@ -3,10 +3,11 @@ The reasoning for creating this [mini-app](https://github.com/dwyl/product-roadmap/issues/32) is simple: -clutter costs us cash +**clutter costs** us ***cash*** +because it **_wastes_ time** and prevents us from living our "best life". -More detail in: +More detailed background/reasoning in: [dwyl/tidy](https://github.com/dwyl/tidy) Here we are only documenting how we built it! \ No newline at end of file