Skip to content

Commit

Permalink
Merge pull request #2078 from ioioio8888/master
Browse files Browse the repository at this point in the history
Problem: Cannot easily get Like/Dislike Coin per User
  • Loading branch information
gsovereignty authored Jun 10, 2019
2 parents 08c66c2 + e9381e1 commit 156fd79
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
14 changes: 11 additions & 3 deletions imports/api/coins/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
import {
ActivityLog, Bounties, REWARDCOEFFICIENT, UserData,
Currencies, PendingCurrencies, RejectedCurrencies, ChangedCurrencies,
HashAlgorithm, developmentValidationEnabledFalse, CoinPerf
HashAlgorithm, developmentValidationEnabledFalse, CoinPerf, UserPerf
} from '/imports/api/indexDB.js';
import { rewardCurrencyCreator } from '/imports/api/utilities.js';
import { quality } from '/imports/api/utilities'
Expand Down Expand Up @@ -724,7 +724,8 @@ Meteor.methods({
if (doc != undefined) {
if (doc.downVoted != undefined) {
if (_.include(doc.downVoted, this.userId)) {
CoinPerf.update({ "_id": coinId }, { $pull: { downVoted: this.userId } })
CoinPerf.update({ "_id": coinId }, { $pull: { downVoted: this.userId } });
UserPerf.update({ "_id": this.userId}, { $pull: { dislikedCoin: coinId } });
//remove opposite vote
}
}
Expand All @@ -733,21 +734,28 @@ Meteor.methods({
$addToSet: { appealVoted: this.userId },
$inc: { appeal: 1, appealNumber: 1 }
});
UserPerf.upsert({ "_id": this.userId }, {
$addToSet: { likedCoin: coinId }
});
// voting up
break;
case 'down':
if (doc != undefined) {
if (doc.appealVoted != undefined) {
if (_.include(doc.appealVoted, this.userId)) {
CoinPerf.update({ "_id": coinId }, { $pull: { appealVoted: this.userId } })
UserPerf.update({ "_id": this.userId}, { $pull: { likedCoin: coinId } })
//remove opposite vote
}
}
}
CoinPerf.upsert({ _id: coinId }, {
CoinPerf.upsert({ "_id": coinId }, {
$addToSet: { downVoted: this.userId },
$inc: { appeal: -1, appealNumber: 1 }
});
UserPerf.upsert({ "_id": this.userId }, {
$addToSet: { dislikedCoin: coinId }
});
// voting down
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions imports/api/indexDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AppLogs } from './miscellaneous/appLogs'
import { UserData } from './users/userData.js'
import { ProfileImages } from './users/profileImages'
import { UsersStats } from './users/usersStats'
import { UserPerf } from './users/userLikedCoin'

import { Bounties } from './bounties/bounties.js'
import { BountyTypes } from './bounties/bountyTypes.js'
Expand Down Expand Up @@ -91,6 +92,7 @@ export {
UserData,
UsersStats,
ProfileImages,
UserPerf,

Ratings,
RatingsTemplates,
Expand Down
11 changes: 9 additions & 2 deletions imports/api/users/server/publications.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meteor } from 'meteor/meteor'
import { UserData, ProfileImages, UsersStats } from '/imports/api/indexDB.js'
import { UserData, ProfileImages, UsersStats, UserPerf } from '/imports/api/indexDB.js'

Meteor.publish('profileimages', () => ProfileImages.find({}))

Expand Down Expand Up @@ -169,4 +169,11 @@ import { UserData, ProfileImages, UsersStats } from '/imports/api/indexDB.js'

Meteor.publish("usersStats", ()=>{
return UsersStats.find({}, {fields: {userIds: 1, created: 1}})
})
})


Meteor.publish('userPerf', () => {
return UserPerf.find({
})
}
)
7 changes: 7 additions & 0 deletions imports/api/users/userLikedCoin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';


const UserPerf = new Mongo.Collection('userPerf');

export { UserPerf }

0 comments on commit 156fd79

Please sign in to comment.