fac-15 / breaking_bread

An app to help organise Wednesday’s community lunch at Space4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🥖 Breaking Bread 🍞

Created by: @onwordi @teenie-quaggard @jcharnley @lucyewright

An app to help organise Wednesday's community lunch at Space4!

💾 Instructions to run app

  1. In your terminal: git clone git@github.com:fac-15/breaking_bread.git
  2. Make sure you are on the staging branch
  3. Run server by typing npm run dev in your terminal
  4. Open up chrome and navigate to http://localhost:5001

📝 Planning:

📋Process

1. Decided on concept 🤨

2. Created entity table relationship diagram/schema ENT Diagram

--- 1️⃣ --- --- --- --- --- ♾ MANY ♾ --- --- --- --- --- 1️⃣ ---

3. 📓 Set up file structure (note that we have not yet added test files in this diagram);

4. 🔎 Searched and found typos (front and back end) and got the server running and all files communicating!

5. ❓Set up our testing database ❌🔜✅

  • We first set up local server & then got confused and tried to host a test database on Heroku
  • test databases DO NOT need to be hosted on Heroku!

6.

🥴 Problems:

  • Working out what our schema relationships were.
  • Getting our tests up and running with confidence we weren't about to ERASE EVERYTHING!
  • Creating the test database.
    • First we tried to create our test db on Heroku however we could not excute the test script due to errors, we changed tactics and made one locally.
    • We had missed out the ssl and user keys in the options object within our connection.js file.
  • We also ran into trouble testing the date format as it would print the date,time & time zone.
  • Our XMLhtml response request did not return data from our databases
  • Linking our databases together to auto populate the FK columns according to primary key (foreign key)

Accomplishment

We were able to popluate our booking table with a people id & if a person has paid or not by using the data from the people's table and the connected (PK FK)

const postData = (fname, lname, org, pay) => {
  dbConnection.query(
    "INSERT INTO people (first_name, last_name, organisation) VALUES ($1, $2, $3) RETURNING id",
    [fname, lname, org],
    (err, peopleRes) => {
      if (err) return err;
      dbConnection.query(
        "INSERT INTO bookings (lunch_id, people_id, paid) VALUES ($1, $2, $3)",
        [1, peopleRes.rows[0].id, pay],
        err => {
          console.log("am i working");
          if (err) return err;
        }
      );
    }
  );
};



const postUserHandler = (request, response) => {
  console.log("IM WORKING postUserHandler");
  let data = "";
  request.on("data", chunk => {
    data += chunk;
  });
  request.on("end", () => {
    const { fname, lname, org, pay } = qs.parse(data);
    console.log("f", fname, "l", lname, "org", org, "pay", pay);

    postData(fname, lname, org, pay, err => {
      if (err) return serverError(err, response);
      response.writeHead(302, { Location: "/" });
      response.end();
    });
  });
};

💬 Stretch goals:

1. Multiple upcoming dates. ✅

2. Eventually we will need to filter lunches displayed to only show upcoming dates!

3. Carosel form display.

4. Votes for upcoming cuisine.

  • (Would involve creating another table.)

5. On form completion, show the lunch you have booked and who is going.

6.

About

An app to help organise Wednesday’s community lunch at Space4


Languages

Language:JavaScript 67.1%Language:HTML 22.0%Language:PLpgSQL 10.8%