Skip to content

Commit

Permalink
Last Harvest Date Tracking for Asset Retrieval (#357)
Browse files Browse the repository at this point in the history
**Pull Request Description**

This pull request introduces a new feature to enhance the asset
retrieval process within our application. The changes made in this PR
are as follows:

**1. campaign.controller.js:**
- Added a new variable called `lastHarvestDate` to
`controllers/campaign.controller.js`.

- Implemented an update operation for the `CampaignLink` model using
`await CampaignLink.updateOne()`. This update operation sets the
`lastHarvestDate` field to the value of `prom.lastHarvest` when a user
retrieves assets.

   - Sample code snippet:

await CampaignLink.updateOne({ id_prom: idProm }, { $set: {
lastHarvestDate: prom.lastHarvest } });
     ```

**2. campaignLink.model.js:**
- Added a new field `lastHarvestDate` of type `Number` to the
`model/campaignLink.model.js`.

These changes aim to provide valuable functionality for tracking and
managing the last harvest date of assets, which can be beneficial for
various aspects of our application. Please review the code and provide
feedback as necessary. Thank you!
  • Loading branch information
hichri-louay authored Oct 23, 2023
2 parents 388e1c6 + 8b4c28e commit 6e3725e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
38 changes: 18 additions & 20 deletions conf/wallets/campaign.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"crypto":{
"cipherparams":{
"iv":"c85de3790ddbc0f1ce85ccec534a374e"
},
"kdfparams":{
"dklen":32,
"salt":"7ab58e00047e5af6d1796fbd11c1a51a805024eca760537476a6243a499b0cf8",
"n":8192,
"r":8,
"p":1
},
"ciphertext":"fd60672fac0b482a2f1d636ba8028c98e257e6cdb8225959f8c60e62f27866b9",
"cipher":"aes-128-ctr",
"kdf":"scrypt",
"mac":"1bc7c2b104d5b3c59ae31afa15570a2e401b2e83b07a176b46d90f938b5a1717"
},
"version":3,
"id":"7f75f407-6588-4bdb-bb3a-86d0f3ed1b46",
"address":"129790e26b5b597a3d8f48ed50c1b8fa27e4e769"
}
"version": 3,
"id": "19945a1e-e7f1-4a4e-bb45-c08cb2c40acb",
"address": "64a453a062985cd56fc685c0ec9d820ef8460976",
"crypto": {
"ciphertext": "3cf0276f8b69d9600eb1c4853baf76301c56077590c8f25a37d72c1ec26fa0e2",
"cipherparams": { "iv": "3feb7943c5057e4bcbc007183ad70c9c" },
"cipher": "aes-128-ctr",
"kdf": "scrypt",
"kdfparams": {
"n": 8192,
"r": 8,
"p": 1,
"dklen": 32,
"salt": "68761f574d125aa5ddce2dbcbe7df17b2af8b5f03d942ec7ea2078a6751fe870"
},
"mac": "fc3bde4105da7fb4bc82c5e87adacb8e7a8c37b4b07e85382a3af41b773b18cd"
}
}
20 changes: 13 additions & 7 deletions controllers/campaign.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1336,13 +1336,17 @@ exports.gains = async (req, res) => {
let prom =
(!!tronWeb && (await ctr.proms(idProm).call())) ||
(await ctr.methods.proms(idProm).call())
if (prom.lastHarvest && date - prom.lastHarvest <= 86400) {
return responseHandler.makeResponseError(
res,
403,
"You didn't exceed the limits timing to harvest between 24H"
)
}


await CampaignLink.updateOne( { id_prom: idProm }, { $set: {lastHarvestDate: prom.lastHarvest} } )

if (prom.lastHarvest && date - prom.lastHarvest <= 86400) {
return responseHandler.makeResponseError(
res,
403,
"You didn't exceed the limits timing to harvest between 24H"
)
}
var linkedinData =
prom.typeSN == '5' &&
(await LinkedinProfile.findOne(
Expand Down Expand Up @@ -2391,6 +2395,8 @@ exports.getLinks = async (req, res) => {
.skip(skip)
.limit(limit)



let tronUserLinks =
(!!accountData.tronAddress &&
!!accountData.walletV2?.tronAddress &&
Expand Down
1 change: 1 addition & 0 deletions model/campaignLink.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const campaignLinkSchema = mongoose.Schema(
typeURL: { type: String },
appliedDate: { type: Number },
acceptedDate: { type: Number },
lastHarvestDate: { type: Number },
oracle: { type: String },
abosNumber: { type: Number, default: 0 },
instagramUserName: { type: String },
Expand Down

0 comments on commit 6e3725e

Please sign in to comment.