Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break everything #105

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ checks:
config:
threshold: 50
exclude_patterns:
- '**/__tests__/*'
- '**/__tests__/'
- 'spec/'
- '**/*.spec.js'
- '**/*.spec.jsx'
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
push:
branches:
- master
- break-everything

# The jobs that will be run, usually in parallel
jobs:
Expand Down Expand Up @@ -37,6 +37,13 @@ jobs:
env:
# An environment variable, the value is a GitHub repo secret
CC_TEST_REPORTER_ID: ${{ secrets.CodeClimateReporterId }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
REACT_APP_SENTRY_DSN: ${{ secrets.REACT_APP_SENTRY_DSN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
AUDIENCE_URL: ${{ secrets.AUDIENCE_URL }}
AUTH0URI: ${{ secrets.AUTH0URI }}
TEST_DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
with:
# Run our `coverage` script in our `package.json`
coverageCommand: yarn coverage
Expand Down
3 changes: 1 addition & 2 deletions __tests__/resolvers/comments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ describe('Comments Resolvers 🌸', () => {
id: '9',
},
});
// console.log('Failed response ***', failedRes.errors[0].message);
expect(failedRes.errors[0].message).toMatch('No data to display!... 💩');
console.log('Failed response ***', failedRes.errors[0].message);
});

it('Gets comment nested with user 🤡', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/resolvers/heatmap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Heatmap Resolvers 🌸', () => {
userId: 'auth0|5dc999e4d958d80e7bb7b597',
},
});
console.log('Failed response ***', failedRes.errors[0].message);
// console.log('Failed response ***', failedRes.errors[0].message);
expect(failedRes.errors[0].message).toMatch('No data to display!... 💩');
});

Expand Down
6 changes: 6 additions & 0 deletions __tests__/resolvers/projects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ query Projects {
private
name
description
category
figma
invision
mainImg
Expand All @@ -52,6 +53,7 @@ const projectQuery = `
private
name
description
category
figma
invision
mainImg
Expand Down Expand Up @@ -92,6 +94,7 @@ const addProjectMutation = `
private
name
description
category
mainImg
}
}
Expand All @@ -104,6 +107,7 @@ const updateProjectMutation = `
userId
name
description
category
mainImg
}
}
Expand Down Expand Up @@ -219,6 +223,7 @@ describe('Projects Resolvers 🌸', () => {
private: true,
name: 'testing',
description: 'i am a tester for the update',
category: 'Web Design',
mainImg: 'wwwkjhbnkjnbcxc',
},
},
Expand All @@ -241,6 +246,7 @@ describe('Projects Resolvers 🌸', () => {
userId: 'abc1225475645456',
name: 'testing updates',
description: 'i am a tester for the update again',
category: 'UI Design',
mainImg: 'wwwkjhbnkjnbcxcasdf',
},
},
Expand Down
5 changes: 5 additions & 0 deletions __utils__/projectsResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const projects = [
private: false,
name: 'My Public Post',
description: 'Description',
category: 'Web Design',
figma: null,
invision: null,
mainImg: 'https://i.imgur.com/EMlwt0i.png',
Expand All @@ -13,6 +14,7 @@ const projects = [
private: false,
name: 'My Other Public Post',
description: 'Other Description',
category: 'Web Design',
figma: null,
invision: null,
mainImg: 'https://i.imgur.com/jidEDG6.png',
Expand All @@ -24,6 +26,7 @@ const project = {
private: false,
name: 'My Public Post',
description: 'Description',
category: 'Web Design',
figma: null,
invision: null,
mainImg: 'https://i.imgur.com/EMlwt0i.png',
Expand Down Expand Up @@ -56,6 +59,7 @@ const addProject = {
private: true,
name: 'testing',
description: 'i am a tester for the update',
category: 'Web Design',
mainImg: 'wwwkjhbnkjnbcxc',
};

Expand All @@ -64,6 +68,7 @@ const updateProject = {
userId: 'abc1225475645456',
name: 'testing updates',
description: 'i am a tester for the update again',
category: 'UI Design',
mainImg: 'wwwkjhbnkjnbcxcasdf',
};

Expand Down
1 change: 1 addition & 0 deletions data/migrations/20200605175556_projects_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports.up = function (knex) {
tbl.boolean('private').defaultTo(false);
tbl.string('name').notNullable();
tbl.text('description');
tbl.text('category');
tbl.string('figma');
tbl.string('invision');
tbl.string('mainImg');
Expand Down
2 changes: 2 additions & 0 deletions data/seeds/02_projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ exports.seed = function (knex) {
userId: 'auth0|5d83b8d3d8e1cf0df49647e3',
name: 'My Public Post',
description: 'Description',
category: 'Web Design',
mainImg: 'https://i.imgur.com/EMlwt0i.png',
},
{
userId: 'auth0|5d83b8d3d8e1cf0df49647e3',
name: 'My Other Public Post',
description: 'Other Description',
category: 'Web Design',
mainImg: 'https://i.imgur.com/jidEDG6.png',
},
]);
Expand Down
2 changes: 0 additions & 2 deletions repl.js

This file was deleted.

4 changes: 2 additions & 2 deletions resolvers/Comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const Comment = {
try {
const user = await db('users').where({ id: comment.userId }).first();
if (!user) throw new Error('Something went wrong... 💩');
console.log(user);
// console.log(user);
return user;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand Down
2 changes: 1 addition & 1 deletion resolvers/Query/Search.js → resolvers/Mutation/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function search(_, { searchText }) {

return { projects, users };
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
}
Expand Down
31 changes: 27 additions & 4 deletions resolvers/Mutation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Mutation = {
// console.log(user);
return user[0];
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand Down Expand Up @@ -114,7 +114,7 @@ const Mutation = {
if (!followers) return false;
return true;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand All @@ -134,7 +134,7 @@ const Mutation = {

async addHeatmap(_, { data }) {
const heatmap = await db('heatmap').insert(data).returning('*');
console.log(heatmap);
// console.log(heatmap);
return heatmap[0];
},

Expand All @@ -143,7 +143,7 @@ const Mutation = {
.update(data)
.where('id', data.id)
.returning('*');
console.log(heatmap);
// console.log(heatmap);
return heatmap[0];
},

Expand All @@ -154,6 +154,29 @@ const Mutation = {
return res(true);
});
},

async search(_, { searchText }) {
const userText = searchText.replace(/\s+/g, '').toLowerCase();
const projectText = searchText.toLowerCase();
try {
const users = await db('users')
.select('*')
.whereRaw(`LOWER(username) LIKE ?`, [`%${userText}%`])
.orWhereRaw(`LOWER(CONCAT("firstName", "lastName")) LIKE ?`, [
`%${userText}%`,
]);

const projects = await db('projects')
.select('*')
.whereRaw(`LOWER(name) LIKE ?`, [`%${projectText}%`])
.andWhere('private', false);

return { projects, users };
} catch (err) {
// console.log(err);
return err;
}
},
};

module.exports = { Mutation };
4 changes: 2 additions & 2 deletions resolvers/Project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Project = {
// console.log(comments);
return comments;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand All @@ -20,7 +20,7 @@ const Project = {
// console.log(photos);
return photos;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand Down
2 changes: 1 addition & 1 deletion resolvers/Query/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function comment(_, { id }) {
// console.log(data);
return data;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
}
Expand Down
4 changes: 2 additions & 2 deletions resolvers/Query/Heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function heatmapById(_, { id }) {
// console.log(data);
return data;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
}
Expand All @@ -18,7 +18,7 @@ async function heatmapByUserId(_, { userId }) {
if (data == 0) throw new Error('No data to display!... 💩');
return data;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
}
Expand Down
12 changes: 11 additions & 1 deletion resolvers/Query/Projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@ async function project(_, { id }) {
}
}

module.exports = { projects, project };
async function category(_, { category }) {
console.log('category', category);
try {
const projectCat = await db('projects').where({ category });
return projectCat;
} catch (err) {
return err;
}
}

module.exports = { projects, project, category };
2 changes: 1 addition & 1 deletion resolvers/Query/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function user(_, { id }) {
if (!user) throw new Error('No user with this id exists... 💩');
return user;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
}
Expand Down
11 changes: 6 additions & 5 deletions resolvers/Query/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { users, user, doesUserExist } = require('./Users');
const { project, projects } = require('./Projects');
const { searchUsers, searchProjects, search } = require('./Search');
const { project, projects, category } = require('./Projects');
// const { searchUsers, searchProjects, search } = require('./Search');
const { heatmapById, heatmapByUserId } = require('./Heatmap');
const { comment } = require('./Comment');

Expand All @@ -11,10 +11,11 @@ const Query = {
doesUserExist,
project,
projects,
category,
comment,
search,
searchUsers,
searchProjects,
// search,
// searchUsers,
// searchProjects,
heatmapById,
heatmapByUserId,
},
Expand Down
8 changes: 4 additions & 4 deletions resolvers/User/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const User = {
if (!projects) throw new Error('Something went wrong... 💩');
return projects;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand All @@ -18,12 +18,12 @@ const User = {
.where({ followerId: user.id })
.join('users', 'followers.followingId', 'users.id')
.select('*');
console.log('User ID:', user.id);
// console.log('User ID:', user.id);
if (!followers) throw new Error('Something went wrong... 💩');
console.log('followers', followers);
// console.log('followers', followers);
return followers;
} catch (err) {
console.log(err);
// console.log(err);
return err;
}
},
Expand Down
4 changes: 3 additions & 1 deletion schema/Inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const inputTypes = gql`
firstName: String
lastName: String
username: String
email: String!
email: String
location: String
bio: String
website: String
Expand All @@ -18,6 +18,7 @@ const inputTypes = gql`
private: Boolean!
name: String!
description: String!
category: String
figma: String
invision: String
mainImg: String
Expand All @@ -29,6 +30,7 @@ const inputTypes = gql`
privateProjects: String
name: String!
description: String!
category: String
figma: String
invision: String
mainImg: String
Expand Down
Loading