Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mugli committed Aug 15, 2019
1 parent 6af1eeb commit f21c38e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/graphql-resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ exports.ActionStatus = objectType({
}
});

const getResultFeed = async (redis, feedName, nextCursor, limit) => {
const deserializeTask = t => {
const r = JSON.parse(t);
if (r.data) {
r.data = JSON.stringify(r.data);
}

if (r.result) {
r.result = JSON.stringify(r.result);
}

return r;
};

const getResultLikeFeed = async (redis, feedName, nextCursor, limit) => {
const start = nextCursor ? Number(Base64.decode(nextCursor)) : 0;
const oneMore = start + limit;

Expand All @@ -32,19 +45,6 @@ const getResultFeed = async (redis, feedName, nextCursor, limit) => {
};
};

const deserializeTask = t => {
const r = JSON.parse(t);
if (r.data) {
r.data = JSON.stringify(r.data);
}

if (r.result) {
r.result = JSON.stringify(r.result);
}

return r;
};

exports.DeadList = objectType({
name: 'DeadList',
definition(t) {
Expand All @@ -66,7 +66,7 @@ exports.DeadList = objectType({
})
},
resolve(root, { nextCursor, limit }, { redis }) {
return getResultFeed(redis, orkidDefaults.DEADLIST, nextCursor, limit);
return getResultLikeFeed(redis, orkidDefaults.DEADLIST, nextCursor, limit);
}
});
}
Expand All @@ -93,7 +93,7 @@ exports.ResultList = objectType({
})
},
resolve(root, { nextCursor, limit }, { redis }) {
return getResultFeed(redis, orkidDefaults.RESULTLIST, nextCursor, limit);
return getResultLikeFeed(redis, orkidDefaults.RESULTLIST, nextCursor, limit);
}
});
}
Expand All @@ -120,7 +120,7 @@ exports.FailedList = objectType({
})
},
resolve(root, { nextCursor, limit }, { redis }) {
return getResultFeed(redis, orkidDefaults.FAILEDLIST, nextCursor, limit);
return getResultLikeFeed(redis, orkidDefaults.FAILEDLIST, nextCursor, limit);
}
});
}
Expand Down

0 comments on commit f21c38e

Please sign in to comment.