Skip to content

Commit

Permalink
chore: fix eslint and prettier issue (#165)
Browse files Browse the repository at this point in the history
* chore: fix eslint and prettier issue

* rename: live.query.js

* rename: _live.query.js

* rename: to rerun github actions

* rename: to rerun github actions
  • Loading branch information
120EE0692 authored Dec 20, 2022
1 parent 597c04c commit 4dc17d0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion server/schema/common/userDetail.input.type.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { GraphQLInputObjectType, GraphQLString, GraphQLID } = require('../scalars');
const StoreEnumType = require('./store.enum.type');

const userDetailInput = new GraphQLInputObjectType({
name: 'UserDetailInputType',
Expand Down
5 changes: 2 additions & 3 deletions server/schema/company/company.datasources.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ const create = async (name, location, logo, session, authToken, mid) => {
}
};

const find = async (query, limit, offset) =>
await CompanyModel.find(query).sort({ name: 'asc' }).skip(offset).limit(limit);
const find = (query, limit, offset) => CompanyModel.find(query).sort({ name: 'asc' }).skip(offset).limit(limit);

const findByID = () =>
new DataLoader(
async (ids) => {
(ids) => {
try {
const _company = ids.map((id) => CompanyModel.findById(id));
return _company;
Expand Down
2 changes: 1 addition & 1 deletion server/schema/live/live.datasources.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const update = async (

const findLiveByYearAndSemester = async (year, semester) => {
try {
const liveByYearAndSemester = await LiveModel.find({ year: year, semester: semester });
const liveByYearAndSemester = await LiveModel.find({ year, semester });
return liveByYearAndSemester;
} catch (error) {
throw APIError(null, error);
Expand Down
2 changes: 1 addition & 1 deletion server/schema/live/live.mutation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {
GraphQLObjectType,
GraphQLNonNull,
GraphQLInputObjectType,
// GraphQLInputObjectType,
GraphQLList,
GraphQLString,
GraphQLID,
Expand Down
2 changes: 1 addition & 1 deletion server/schema/live/live.query.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { GraphQLObjectType, GraphQLNonNull,GraphQLList, GraphQLString, GraphQLInt } = require('../scalars');
const { GraphQLObjectType, GraphQLNonNull, GraphQLList, GraphQLString, GraphQLInt } = require('../scalars');
const LiveType = require('./live.type');
const { getLiveByYearandSemester } = require('./live.resolver');

Expand Down
15 changes: 8 additions & 7 deletions server/schema/live/live.resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = {
getLiveByYearandSemester: async (
_parent,
{ year, semester },
{ mid, session, authToken, decodedToken, API: { Live, Company } }
{ session, authToken, decodedToken, API: { Live, Company } }
) => {
try {
if (!UserPermission.exists(session, authToken, decodedToken, 'live.read.all')) {
Expand All @@ -83,21 +83,22 @@ module.exports = {
const _companyIds = liveByYearAndSemester.reduce((prev, curr) => prev.add(curr.company.toString()), new Set());

const comapnyIds = Array.from(_companyIds);
console.log(comapnyIds);

const comapnies = await Company.findByIDs(comapnyIds);
console.log(comapnies);

const comapnies_map = new Map(comapnies.map((obj) => [obj.id, obj]));

const _liveByYearAndSemester = liveByYearAndSemester.map((curr) => {
return { ...curr._doc, company: comapnies_map.get(curr.company.toString()) };
});
const _liveByYearAndSemester = liveByYearAndSemester.map((curr) => ({
...curr._doc,
company: comapnies_map.get(curr.company.toString()),
}));

return _liveByYearAndSemester;
} catch (error) {
throw APIError(null, error);
}
},
deleteLiveData: async (_parent, { id }, { mid, session, authToken, decodedToken, API: { Live } }) => {
deleteLiveData: async (_parent, { id }, { session, authToken, decodedToken, API: { Live } }) => {
try {
if (!UserPermission.exists(session, authToken, decodedToken, 'live.write.all')) {
throw APIError('FORBIDDEN', null, {
Expand Down

0 comments on commit 4dc17d0

Please sign in to comment.