|
1 | 1 | /* eslint no-underscore-dangle: ["error", { "allow": ["_id"] }] */ |
2 | 2 | import { Types } from 'mongoose'; |
3 | 3 |
|
| 4 | +import Activity from './Activity'; |
| 5 | + |
4 | 6 | const statesVoting = ['Beschlussempfehlung liegt vor']; |
5 | 7 | const statesCompleted = [ |
6 | 8 | 'Zurückgezogen', |
@@ -49,7 +51,9 @@ export default { |
49 | 51 | vote: async ( |
50 | 52 | parent, |
51 | 53 | { procedure: procedureId, selection }, |
52 | | - { VoteModel, ProcedureModel, user }, |
| 54 | + { |
| 55 | + VoteModel, ProcedureModel, ActivityModel, user, |
| 56 | + }, |
53 | 57 | ) => { |
54 | 58 | if (!user) { |
55 | 59 | throw new Error('No Auth!'); |
@@ -86,6 +90,11 @@ export default { |
86 | 90 | } |
87 | 91 | await VoteModel.findByIdAndUpdate(vote._id, { ...voteUpdate, state }); |
88 | 92 | } |
| 93 | + await Activity.Mutation.increaseActivity( |
| 94 | + parent, |
| 95 | + { procedureId }, |
| 96 | + { ProcedureModel, ActivityModel, user }, |
| 97 | + ); |
89 | 98 | return VoteModel.aggregate([ |
90 | 99 | { $match: { procedure: procedure._id } }, |
91 | 100 | { $addFields: { voted: { $in: [user._id, '$users'] } } }, |
|
0 commit comments