blob: 0e201dbd0d8f4d4770d459d3abc4960fedf8ae2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import _ from 'lodash';
import { HookContext } from '@feathersjs/feathers';
const raiseNewVerifedPolls = async (context: HookContext): Promise<HookContext> => {
// Raise unseen verified polls to the very top
context.result = _.sortBy(
context.result,
poll => !(poll.author.verified && !poll.userChoice)
);
return context;
};
const lowerOldPolls = async (context: HookContext): Promise<HookContext> => {
// Move all seen polls down
context.result = _.sortBy(
context.result,
poll => !!poll.userChoice
);
return context;
};
export default {
after: {
find: [raiseNewVerifedPolls, lowerOldPolls]
}
};
|