Skip to content

Commit

Permalink
Merge pull request #109 from fac19/project-card-route
Browse files Browse the repository at this point in the history
fix project fetch route
  • Loading branch information
hannahgooding authored May 27, 2020
2 parents c0cdbd2 + e6edf1c commit 5ea26f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions wip-rest-api/src/database/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ BEGIN;
INSERT INTO steps
(project_id, step_name, step_description, step_link)
VALUES
('1', '1 1st sketch', '1 The trunk', '/images/1.jpg'),
('2', '2 1st sketch', '2 The tail', '/images/2.jpg'),
('1', '1 2nd sketch', '1 The leaves', '/images/3.jpg'),
('4', '4 1st sketch', '4 Their nose', '/images/4.jpg'),
('1', '1 3rd sketch', '1 Some roots', '/images/5.jpg'),
('5', '5 1st sketch', '5 Viruses', '/images/6.jpg'),
('4', '4 2nd sketch', '4 Their feet', '/images/7.jpg'),
('3', '3 1st sketch', '3 round and bright', '/images/8.jpg'),
('2', '2 2nd sketch', '2 A cute nose', '/images/9.jpg'),
('1', '1 4th sketch', '1 someone hugging it', '/images/10.jpg');
('1', '1 1st sketch', '1 The trunk', 'https://i.imgur.com/rk5C1fQ.jpg'),
('2', '2 1st sketch', '2 The tail', 'https://media.giphy.com/media/NkJEXWDr7KsG4/giphy.gif'),
('1', '1 2nd sketch', '1 The leaves', 'https://i.imgur.com/TCpcGRJ.jpg'),
('4', '4 1st sketch', '4 Their nose', 'https://i.imgur.com/UBLi3O3.jpg'),
('1', '1 3rd sketch', '1 Some roots', 'https://i.imgur.com/d23lKC6.jpg'),
('5', '5 1st sketch', '5 Viruses', 'https://media.giphy.com/media/JRsY1oIVA7IetTkKVO/giphy.gif'),
('4', '4 2nd sketch', '4 Their feet', 'https://media.giphy.com/media/11FH5Vq7WPglmE/giphy.gif'),
('3', '3 1st sketch', '3 round and bright', 'https://media.giphy.com/media/XgtJCYMbPvMe4/giphy.gif'),
('2', '2 2nd sketch', '2 A cute nose', 'https://media.giphy.com/media/1DMfMOWF8Piec/giphy.gif'),
('1', '1 4th sketch', '1 someone hugging it', 'https://i.imgur.com/Xu5BUft.jpg');

CREATE TABLE feedback
(
Expand Down
2 changes: 1 addition & 1 deletion wip-rest-api/src/model/projects-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const db = require("../database/connection.js");
function getWatchedProjectsFromDb(userId) {
return db
.query(
"SELECT * FROM projects JOIN user_watch ON projects.id=user_watch.project_id WHERE user_watch.user_id=($1);",
"SELECT username, projects.id, project_name, steps.date, step_link FROM projects JOIN user_watch ON project_id=projects.id JOIN users ON user_watch.user_id=users.id JOIN steps ON projects.id=steps.project_id WHERE user_watch.user_id=($1);",
[userId]
)
.then((projects) => projects.rows);
Expand Down
4 changes: 2 additions & 2 deletions wip-rest-api/src/test/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ describe("Database tests for projects", () => {

test("Get all watched projects returns array of correct length", async () => {
await projectsmodel.getWatchedProjectsFromDb("2").then((projects) => {
expect(projects.length).toEqual(4);
expect(projects.length).toEqual(9);
});
});

test("Get info from watched projects", async () => {
await projectsmodel.getWatchedProjectsFromDb("2").then((projects) => {
expect(projects[2].project_name).toEqual("A friend");
expect(projects[2].project_name).toEqual("A tree");
});
});

Expand Down

0 comments on commit 5ea26f5

Please sign in to comment.