# FAKM Week-5 Presentation ### "Sharing is caring" ![](https://i.imgur.com/Ffl45uq.png =500x) *Illustration made by: Ina!!!!* --- #### User Stories --- 1. As a scared person in this pandemic I stocked up way too many stuff. I'd like a place where I can post about these surplus goods so people who are in need collect them. --- 2. As a person who didn't stock up in this pandemic and only finds empty shelves in the shops, I'd like a place to see what other people are giving away so I can find essentials. --- 3. As a person that can't find toilet paper in the shops, I'd like to limit my search so I can find what I need. --- #### Website | Home | Form | All Posts | | -------- | -------- | -------- | | ![](https://i.imgur.com/7I2ymjO.png =300x)| ![](https://i.imgur.com/c4jyn9B.png =300x) | ![](https://i.imgur.com/lKGxn13.png =300x) | --- ## Planning --- ### Mobbing on Miro is fun! ![](https://i.imgur.com/7VOO1K2.png =700x) --- ### DAY 1 - Design sprint: wireframing, user flow diagram on Miro - Set up the boilerplate - Got bogged down installing databases after lunch before finalizing design - Mobbed on the schemas - Issues added to Project Board - Not much coding before end of day --- ### DAY 2 #### Morning - Review issues to baseline objectives for day - Quick discussion on best way to approach learning on subject that is on everyones learning objectives - Split onto: - Ina & Joe: schema completion, request handling and serving static assets () - Gio & Roger: Finishing the static files and starting to query the db --- ### Afternoon - PostgreSQL testing fun :1234: :exploding_head: ![](https://media.giphy.com/media/AS7Cki8Jx7THKvkhV8/giphy.gif); --- ## Learning objectives --- ### Gio - Better understanding of Postgres in Node architecture - Database testing --- ### Ina - Get more comfortable with Postgres - Testing database - Database queries --- ### Joe - Able to deploy a database project on Heroku and understand using EVs - Understand how to safely query a database to get data and display it to DOM - We can use joins to access related data in different tables --- ### Roger - Understand deployment to heroku - Understand how to test, and TDD, database queries --- ## Things we are proud of - Ina's ilustration :heart: - Schema - Design & concept planning - README.md - package.json --- ```sql CREATE TABLE users ( id SERIAL PRIMARY KEY, username VARCHAR(255) NOT NULL, postcode VARCHAR(8) ); CREATE TABLE category ( id SERIAL PRIMARY KEY, category VARCHAR(20) ); CREATE TABLE posts ( id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, time TIMESTAMPTZ, category INTEGER, post TEXT NOT NULL, user_id INTEGER ); ``` --- ```javascript // Get all listings from the posts table function getAllListings() { return db.query( `SELECT posts.id, users.username, posts.title, posts.time, users.postcode, posts.post FROM users RIGHT JOIN posts ON users.id = posts.user_id ORDER BY posts.time DESC ` ).then(result => { return result.rows; }); } ``` --- ## Struggles - Jumping into implementation before finalizing plan of action - Applying the TDD process when creating DB queries - Understanding the correct flow for async testing - Not switching to something else while we waited for help 20/20/20! --- ## What we learned ![](https://media.giphy.com/media/8dYmJ6Buo3lYY/giphy.gif =400x) --- ### Roger --- #### You lot are lovely! ![](https://media.giphy.com/media/Ql6WCH22Grmpi/giphy.gif) --- ##### You can't be too careful with setup instructions in README.md - Any errors or ambiguity will cause a world of pain for you users. - Best to check and test setup instructions, in multiple environments where possible! ![](https://media.giphy.com/media/RSOUOj8H9A3Xq/giphy.gif) --- ##### Testing async code requires good understanding of promises and the way they need to flow together. - I thought I had that. - I didn't! 🤪 ![](https://media.giphy.com/media/521JLj0YGzz6AEWsZ5/giphy.gif =400x) --- #### The wrong way to do it ```javascript function deleteListing(id) { db.query("DELETE FROM posts WHERE id = $1", [id]) .then(result => { return result.rowCount === 1; }); ``` ```javascript test("Check if delete(1) doesn't crash and delete's something!", t => { build() .then( () => { let result = model.deleteListing(1) // Nooooo! t.equal(result, true); t.end(); }) }) ``` --- #### The right way ```javascript function deleteListing(id) { return db.query("DELETE FROM posts WHERE id = $1", [id]) .then(result => { return result.rowCount === 1; }); ``` ```javascript test("Check if delete(1) doesn't crash and delete's something!", t => { build() .then( () => { model.deleteListing(1) .then(result => { t.equal(result, true); t.end(); }) }) }); ``` --- ### Gio - Promises hate me - Ina is an amazing artist! - Roger loves TDD - Joe is a wonderful leader - Learning as a group is the main goal! --- ### Ina - Learning comes first, always. - TDD is helpful when you're struggling. --- ### Joe - Improve scrum master skills I have ![yoda](https://media1.giphy.com/media/pvDp7Ewpzt0o8/200.gif?cid=e1bb72ff2392bfca1d2bcdefdc666d09f1c7fc838732903f&rid=200.gif) --- Like a project manager... but with 5% of the power - Important to proactively check in with everyone - Even more important when you are remote working --- Has to be some point on Thursday where you check learning objectives. --- - Trust in the process - It's not always about you :) --- Teaching others is really rewarding - Solidified learning from Week 4 ![](https://media0.giphy.com/media/BlVnrxJgTGsUw/200.gif?cid=e1bb72ff6cd3378202881219af0f1b62eaf62b1f8c142b0a&rid=200.gif) --- ### Thank you & any questions? ![](https://media.giphy.com/media/pyEDsTDy2aIR5SXkBD/giphy.gif) ---
{"metaMigratedAt":"2023-06-15T06:03:54.391Z","metaMigratedFrom":"Content","title":"FAKM Week-5 Presentation","breaks":true,"contributors":"[{\"id\":\"b6a31e78-07d2-4282-beaf-ce34bf42c9b2\",\"add\":1305,\"del\":306},{\"id\":\"0e4f99ec-9dff-4b8d-9f98-aa3f5444e9ce\",\"add\":3270,\"del\":514},{\"id\":\"62face64-5436-4acc-9a7e-1c0da8ae85ba\",\"add\":282,\"del\":109},{\"id\":\"fc28ac9f-05b4-4c0c-ba0f-978abbf9d995\",\"add\":2294,\"del\":109}]"}
    166 views
   Owned this note