Skip to content

Commit

Permalink
#289 Feat: add charger restore formula basement
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanBlacky committed Jun 14, 2019
1 parent 13c7ab5 commit 8ecf603
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
14 changes: 14 additions & 0 deletions src/controllers/connector/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,23 @@ class Profile extends AbstractFeed {
{ chargers: true, _id: false },
{ lean: true }
);

profile.chargers = this._calculateChargers(profile);

return profile.chargers;
}

_calculateChargers(chargers) {
const chargerValues = {};

for (const charger of Object.keys(chargers)) {
// todo: wait for core team and add formula
chargerValues[charger] = chargers[charger].value;
}

return chargerValues;
}

async _detectSubscription(modelObject, currentUserId, requestedUserId) {
if (!currentUserId) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/prism/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Profile extends Abstract {
userId,
},
{
$set: { [path]: chargePercent },
$set: { [path]: { value: chargePercent, lastUpdated: Date.now() } },
}
);

Expand Down
40 changes: 32 additions & 8 deletions src/models/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,44 @@ module.exports = MongoDB.makeModel(
},
chargers: {
votes: {
type: Number,
default: 100,
value: {
type: Number,
default: 100,
},
lastUpdated: {
type: Date,
default: Date.now(),
},
},
posts: {
type: Number,
default: 100,
value: {
type: Number,
default: 100,
},
lastUpdated: {
type: Date,
default: Date.now(),
},
},
comments: {
type: Number,
default: 100,
value: {
type: Number,
default: 100,
},
lastUpdated: {
type: Date,
default: Date.now(),
},
},
postbw: {
type: Number,
default: 100,
value: {
type: Number,
default: 100,
},
lastUpdated: {
type: Date,
default: Date.now(),
},
},
},
personal: {
Expand Down

0 comments on commit 8ecf603

Please sign in to comment.