@nina-protocol/nina-db 0.0.60 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/Release.js +6 -1
- package/package.json +1 -1
- package/src/models/Release.js +5 -1
package/dist/models/Release.js
CHANGED
|
@@ -100,15 +100,20 @@ export default class Release extends Model {
|
|
|
100
100
|
return release;
|
|
101
101
|
};
|
|
102
102
|
static processRevenueShares = async (releaseData, releaseRecord) => {
|
|
103
|
+
console.log('processRevenueShares', releaseData, releaseRecord);
|
|
103
104
|
const royaltyRecipients = releaseData.account?.royaltyRecipients || releaseData.royaltyRecipients;
|
|
104
105
|
for await (let recipient of royaltyRecipients) {
|
|
105
106
|
try {
|
|
106
107
|
if (recipient.recipientAuthority.toBase58() !== "11111111111111111111111111111111") {
|
|
107
108
|
const recipientAccount = await Account.findOrCreate(recipient.recipientAuthority.toBase58());
|
|
108
109
|
const revenueShares = (await recipientAccount.$relatedQuery('revenueShares')).map(revenueShare => revenueShare.id);
|
|
109
|
-
|
|
110
|
+
console.log('recipient', recipient);
|
|
111
|
+
if (!revenueShares.includes(releaseRecord.id) && recipient.percentShares > 0) {
|
|
110
112
|
await Account.relatedQuery('revenueShares').for(recipientAccount.id).relate(releaseRecord.id);
|
|
111
113
|
}
|
|
114
|
+
else if (revenueShares.includes(releaseRecord.id) && recipient.percentShares === 0) {
|
|
115
|
+
await Account.relatedQuery('revenueShares').for(recipientAccount.id).unrelate().where('id', releaseRecord.id);
|
|
116
|
+
}
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
catch (error) {
|
package/package.json
CHANGED
package/src/models/Release.js
CHANGED
|
@@ -112,14 +112,18 @@ export default class Release extends Model {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
static processRevenueShares = async (releaseData, releaseRecord) => {
|
|
115
|
+
console.log('processRevenueShares', releaseData, releaseRecord)
|
|
115
116
|
const royaltyRecipients = releaseData.account?.royaltyRecipients || releaseData.royaltyRecipients
|
|
116
117
|
for await (let recipient of royaltyRecipients) {
|
|
117
118
|
try {
|
|
118
119
|
if (recipient.recipientAuthority.toBase58() !== "11111111111111111111111111111111") {
|
|
119
120
|
const recipientAccount = await Account.findOrCreate(recipient.recipientAuthority.toBase58());
|
|
120
121
|
const revenueShares = (await recipientAccount.$relatedQuery('revenueShares')).map(revenueShare => revenueShare.id);
|
|
121
|
-
|
|
122
|
+
console.log('recipient', recipient)
|
|
123
|
+
if (!revenueShares.includes(releaseRecord.id) && recipient.percentShares > 0) {
|
|
122
124
|
await Account.relatedQuery('revenueShares').for(recipientAccount.id).relate(releaseRecord.id);
|
|
125
|
+
} else if (revenueShares.includes(releaseRecord.id) && recipient.percentShares === 0) {
|
|
126
|
+
await Account.relatedQuery('revenueShares').for(recipientAccount.id).unrelate().where('id', releaseRecord.id);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
} catch (error) {
|