agrs-sequelize-sdk 1.1.98 → 1.2.0

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.
Files changed (57) hide show
  1. package/agrs-sequelize/LICENSE +21 -0
  2. package/agrs-sequelize/README.md +179 -0
  3. package/agrs-sequelize/index.js +169 -0
  4. package/agrs-sequelize/jq.exe +0 -0
  5. package/agrs-sequelize/models/ActivityHistory.js +73 -0
  6. package/agrs-sequelize/models/Ad.js +209 -0
  7. package/agrs-sequelize/models/AdAccount.js +91 -0
  8. package/agrs-sequelize/models/AdAccountValues.js +26 -0
  9. package/agrs-sequelize/models/AdHistory.js +30 -0
  10. package/agrs-sequelize/models/AdPerformance.js +84 -0
  11. package/agrs-sequelize/models/AdPerformanceHourly.js +66 -0
  12. package/agrs-sequelize/models/AdSet.js +140 -0
  13. package/agrs-sequelize/models/AdSetHistory.js +30 -0
  14. package/agrs-sequelize/models/AdsetPerformance.js +116 -0
  15. package/agrs-sequelize/models/Article.js +156 -0
  16. package/agrs-sequelize/models/Buyers.js +26 -0
  17. package/agrs-sequelize/models/Campaign.js +136 -0
  18. package/agrs-sequelize/models/CampaignCreationLog.js +86 -0
  19. package/agrs-sequelize/models/CampaignHistory.js +33 -0
  20. package/agrs-sequelize/models/Channel.js +55 -0
  21. package/agrs-sequelize/models/CodefuelCampaign.js +159 -0
  22. package/agrs-sequelize/models/CodefuelCampaignKWHistory.js +41 -0
  23. package/agrs-sequelize/models/CodefuelKeywords.js +35 -0
  24. package/agrs-sequelize/models/CurrencyRate.js +27 -0
  25. package/agrs-sequelize/models/Domain.js +26 -0
  26. package/agrs-sequelize/models/ExplorAdsChannel.js +62 -0
  27. package/agrs-sequelize/models/Feed.js +34 -0
  28. package/agrs-sequelize/models/Files.js +73 -0
  29. package/agrs-sequelize/models/Folders.js +133 -0
  30. package/agrs-sequelize/models/KeywordPerformance.js +99 -0
  31. package/agrs-sequelize/models/KeywordRotationState.js +51 -0
  32. package/agrs-sequelize/models/Pages.js +74 -0
  33. package/agrs-sequelize/models/PipelineExecution.js +46 -0
  34. package/agrs-sequelize/models/RSOCFeedCampaign.js +302 -0
  35. package/agrs-sequelize/models/RsocKeywordPerformance.js +111 -0
  36. package/agrs-sequelize/models/Rule.js +39 -0
  37. package/agrs-sequelize/models/RulesValues.js +56 -0
  38. package/agrs-sequelize/models/SupportedLocale.js +24 -0
  39. package/agrs-sequelize/models/TonicCampaign.js +97 -0
  40. package/agrs-sequelize/models/Users.js +111 -0
  41. package/agrs-sequelize/models/Vertical.js +26 -0
  42. package/agrs-sequelize/models/newFiles.js +68 -0
  43. package/agrs-sequelize/models/pixel.js +33 -0
  44. package/agrs-sequelize/models/pixels.js +33 -0
  45. package/agrs-sequelize/package-lock.json +405 -0
  46. package/agrs-sequelize/package.json +19 -0
  47. package/agrs-sequelize/run.ps1 +98 -0
  48. package/agrs-sequelize/run.sh +214 -0
  49. package/migrations/20240321000000-add-performance-indexes.js +73 -0
  50. package/models/Ad.js +73 -9
  51. package/models/AdPerformance.js +84 -84
  52. package/models/AdSet.js +144 -0
  53. package/models/Campaign.js +135 -136
  54. package/models/RSOCFeedCampaign.js +1 -10
  55. package/models/pixel.js +5 -1
  56. package/models/pixels.js +5 -1
  57. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "agrs-sequelize-sdk",
3
+ "version": "1.1.98",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "start": "node index.js",
7
+ "sync": "node services/sequelizeService.js",
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "description": "",
14
+ "dependencies": {
15
+ "pg": "^8.13.0",
16
+ "pg-hstore": "^2.3.4",
17
+ "sequelize": "^6.37.4"
18
+ }
19
+ }
@@ -0,0 +1,98 @@
1
+ # Ensure the script is run as an Administrator
2
+ #If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
3
+ # Write-Host "This script must be run as an administrator." -ForegroundColor Red
4
+ # Write-Host "Right-click on the script and select 'Run as Administrator'."
5
+ # Exit 1
6
+ #}
7
+
8
+ # Check if jq is installed
9
+ $jqPath = Get-Command jq -ErrorAction SilentlyContinue
10
+
11
+ if (-not $jqPath) {
12
+ Write-Host "jq not found. Downloading jq manually..."
13
+ $jqUrl = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe"
14
+ $jqDestination = "$env:TEMP\jq.exe"
15
+
16
+ try {
17
+ Invoke-WebRequest -Uri $jqUrl -OutFile $jqDestination
18
+ Move-Item -Path $jqDestination -Destination "$env:SystemRoot\System32\jq.exe" -Force
19
+ Write-Host "jq installed manually."
20
+ } catch {
21
+ Write-Host "Failed to download or move jq. Please ensure you have the necessary permissions."
22
+ Exit 1
23
+ }
24
+ }
25
+
26
+ # Step 1: Check if logged in to NPM
27
+ try {
28
+ $npmUsername = npm whoami 2>&1
29
+ if ($npmUsername -match "ERR") {
30
+ Write-Host "Not logged in. Please log in to NPM."
31
+ npm login
32
+ if ($LASTEXITCODE -ne 0) {
33
+ Write-Host "NPM login failed. Exiting..."
34
+ Exit 1
35
+ }
36
+ } else {
37
+ Write-Host "Already logged in to NPM as $npmUsername"
38
+ }
39
+ } catch {
40
+ Write-Host "Error while checking NPM login status."
41
+ Exit 1
42
+ }
43
+
44
+ # Step 2: Increment version in package.json
45
+ $packageJson = Get-Content -Raw -Path "package.json" | ConvertFrom-Json
46
+ $currentVersion = $packageJson.version
47
+
48
+ if (-not $currentVersion) {
49
+ Write-Host "Could not find version in package.json"
50
+ Exit 1
51
+ }
52
+
53
+ # Split version into major, minor, patch
54
+ $versionParts = $currentVersion -split '\.'
55
+
56
+ $major = [int]$versionParts[0]
57
+ $minor = [int]$versionParts[1]
58
+ $patch = [int]$versionParts[2]
59
+
60
+ # Increment version numbers with three-digit logic
61
+ if ($patch -eq 99) {
62
+ $patch = 0
63
+ if ($minor -eq 99) {
64
+ $minor = 0
65
+ $major++
66
+ } else {
67
+ $minor++
68
+ }
69
+ } else {
70
+ $patch++
71
+ }
72
+
73
+ $newVersion = "$major.$minor.$patch"
74
+
75
+ # Update the version in package.json while maintaining indentation
76
+ $packageJson.version = $newVersion
77
+ $packageJson | ConvertTo-Json -Depth 100 | Set-Content -Path "package.json"
78
+
79
+ Write-Host "Version updated from $currentVersion to $newVersion"
80
+
81
+ # Step 3: Publish the package to NPM
82
+ npm publish
83
+ if ($LASTEXITCODE -ne 0) {
84
+ Write-Host "NPM publish failed. Exiting..."
85
+ Exit 1
86
+ }
87
+
88
+ # Step 4: Commit the changes and push to GitHub
89
+ git add .
90
+ git commit -m "Bump version to $newVersion"
91
+ git push origin main
92
+
93
+ if ($LASTEXITCODE -ne 0) {
94
+ Write-Host "Failed to push changes to GitHub. Exiting..."
95
+ Exit 1
96
+ }
97
+
98
+ Write-Host "Version $newVersion published and changes pushed to GitHub successfully!"
@@ -0,0 +1,214 @@
1
+ # #!/bin/bash
2
+
3
+ # # Check if root is only required for jq installation
4
+ # require_root_for_jq=0
5
+
6
+ # # Check if jq is installed
7
+ # if ! command -v jq &> /dev/null; then
8
+ # echo "jq not found. Installing jq..."
9
+ # require_root_for_jq=1
10
+ # if command -v apt-get &> /dev/null; then
11
+ # sudo apt-get update && sudo apt-get install -y jq
12
+ # elif command -v brew &> /dev/null; then
13
+ # brew install jq
14
+ # else
15
+ # echo "Please install jq manually."
16
+ # exit 1
17
+ # fi
18
+ # fi
19
+
20
+ # # Only require root if jq installation was needed
21
+ # if [[ $require_root_for_jq -eq 1 && $EUID -ne 0 ]]; then
22
+ # echo "This script must be run as root for jq installation. Please use sudo."
23
+ # exit 1
24
+ # fi
25
+
26
+ # # Step 1: Check if logged in to NPM
27
+ # npmUsername=$(npm whoami 2>&1)
28
+ # if [[ $npmUsername == *"ERR"* ]]; then
29
+ # echo "Not logged in. Please log in to NPM."
30
+ # npm login
31
+ # if [[ $? -ne 0 ]]; then
32
+ # echo "NPM login failed. Exiting..."
33
+ # exit 1
34
+ # fi
35
+ # else
36
+ # echo "Already logged in to NPM as $npmUsername"
37
+ # fi
38
+
39
+ # # Step 2: Increment version in package.json
40
+ # if [[ ! -f package.json ]]; then
41
+ # echo "package.json not found. Exiting..."
42
+ # exit 1
43
+ # fi
44
+
45
+ # currentVersion=$(jq -r '.version' package.json)
46
+
47
+ # if [[ -z "$currentVersion" ]]; then
48
+ # echo "Could not find version in package.json"
49
+ # exit 1
50
+ # fi
51
+
52
+ # # Split version into major, minor, patch
53
+ # IFS='.' read -r major minor patch <<< "$currentVersion"
54
+
55
+ # # Increment version numbers with three-digit logic
56
+ # if [[ $patch -eq 99 ]]; then
57
+ # patch=0
58
+ # if [[ $minor -eq 99 ]]; then
59
+ # minor=0
60
+ # ((major++))
61
+ # else
62
+ # ((minor++))
63
+ # fi
64
+ # else
65
+ # ((patch++))
66
+ # fi
67
+
68
+ # newVersion="$major.$minor.$patch"
69
+
70
+ # # Update the version in package.json while maintaining formatting
71
+ # jq --arg version "$newVersion" '.version = $version' package.json > tmp.json && mv tmp.json package.json
72
+ # echo "Version updated from $currentVersion to $newVersion"
73
+
74
+ # # Step 3: Publish the package to NPM
75
+ # npm publish
76
+ # if [[ $? -ne 0 ]]; then
77
+ # echo "NPM publish failed. Exiting..."
78
+ # exit 1
79
+ # fi
80
+
81
+ # # Step 4: Commit the changes and push to GitHub
82
+ # git add .
83
+ # git commit -m "Bump version to $newVersion"
84
+ # git push origin main
85
+
86
+ # if [[ $? -ne 0 ]]; then
87
+ # echo "Failed to push changes to GitHub. Exiting..."
88
+ # exit 1
89
+ # fi
90
+
91
+ # echo "Version $newVersion published and changes pushed to GitHub successfully!"
92
+
93
+
94
+ #!/bin/bash
95
+
96
+ # Check if root is only required for jq installation
97
+ require_root_for_jq=0
98
+
99
+ # Check if jq is installed
100
+ if ! command -v jq &> /dev/null; then
101
+ echo "jq not found. Installing jq..."
102
+ require_root_for_jq=1
103
+ if command -v apt-get &> /dev/null; then
104
+ sudo apt-get update && sudo apt-get install -y jq
105
+ elif command -v brew &> /dev/null; then
106
+ brew install jq
107
+ else
108
+ echo "Please install jq manually."
109
+ exit 1
110
+ fi
111
+ fi
112
+
113
+ # Only require root if jq installation was needed
114
+ if [[ $require_root_for_jq -eq 1 && $EUID -ne 0 ]]; then
115
+ echo "This script must be run as root for jq installation. Please use sudo."
116
+ exit 1
117
+ fi
118
+
119
+ # Step 1: Check if logged in to NPM
120
+ npmUsername=$(npm whoami 2>&1)
121
+ if [[ $npmUsername == *"ERR"* ]]; then
122
+ echo "Not logged in. Please log in to NPM."
123
+ npm login
124
+ if [[ $? -ne 0 ]]; then
125
+ echo "NPM login failed. Exiting..."
126
+ exit 1
127
+ fi
128
+ else
129
+ echo "Already logged in to NPM as $npmUsername"
130
+ fi
131
+
132
+ # Step 2: Check the latest published version from NPM
133
+ packageName=$(jq -r '.name' package.json)
134
+ if [[ -z "$packageName" ]]; then
135
+ echo "Could not find package name in package.json"
136
+ exit 1
137
+ fi
138
+
139
+ latestPublishedVersion=$(npm view "$packageName" version)
140
+ if [[ $? -ne 0 ]]; then
141
+ echo "Failed to fetch the latest published version. Exiting..."
142
+ exit 1
143
+ fi
144
+
145
+ echo "Latest published version on NPM: $latestPublishedVersion"
146
+
147
+ # Step 3: Increment version in package.json
148
+ if [[ ! -f package.json ]]; then
149
+ echo "package.json not found. Exiting..."
150
+ exit 1
151
+ fi
152
+
153
+ currentVersion=$(jq -r '.version' package.json)
154
+
155
+ if [[ -z "$currentVersion" ]]; then
156
+ echo "Could not find version in package.json"
157
+ exit 1
158
+ fi
159
+
160
+ # Split version into major, minor, patch
161
+ IFS='.' read -r major minor patch <<< "$currentVersion"
162
+
163
+ # Increment version numbers with three-digit logic
164
+ if [[ $patch -eq 99 ]]; then
165
+ patch=0
166
+ if [[ $minor -eq 99 ]]; then
167
+ minor=0
168
+ ((major++))
169
+ else
170
+ ((minor++))
171
+ fi
172
+ else
173
+ ((patch++))
174
+ fi
175
+
176
+ newVersion="$major.$minor.$patch"
177
+
178
+ # Ensure the new version is greater than the latest published version
179
+ if [[ "$(printf '%s\n' "$newVersion" "$latestPublishedVersion" | sort -V | tail -1)" != "$newVersion" ]]; then
180
+ echo "Error: New version ($newVersion) is not greater than the latest published version ($latestPublishedVersion)."
181
+ echo "Please manually update the version in package.json or adjust the script logic."
182
+ exit 1
183
+ fi
184
+
185
+ # Update the version in package.json while maintaining formatting
186
+ jq --arg version "$newVersion" '.version = $version' package.json > tmp.json && mv tmp.json package.json
187
+ echo "Version updated from $currentVersion to $newVersion"
188
+
189
+ # Step 4: Publish the package to NPM
190
+ npm publish
191
+ if [[ $? -ne 0 ]]; then
192
+ echo "NPM publish failed. Exiting..."
193
+ exit 1
194
+ fi
195
+
196
+ # Step 5: Commit the changes and push to GitHub
197
+ git add .
198
+ git commit -m "Bump version to $newVersion"
199
+
200
+ # Pull latest changes to ensure there are no conflicts
201
+ git pull origin main --rebase
202
+ if [[ $? -ne 0 ]]; then
203
+ echo "Git pull failed. Please resolve conflicts manually. Exiting..."
204
+ exit 1
205
+ fi
206
+
207
+ # Push changes to remote
208
+ git push origin main
209
+ if [[ $? -ne 0 ]]; then
210
+ echo "Failed to push changes to GitHub. Exiting..."
211
+ exit 1
212
+ fi
213
+
214
+ echo "Version $newVersion published and changes pushed to GitHub successfully!"
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ // Add indexes for AdPerformance table
6
+ await queryInterface.addIndex("AdPerformance", ["Date", "AdID"], {
7
+ name: "ad_performance_date_adid_idx",
8
+ unique: true,
9
+ });
10
+
11
+ await queryInterface.addIndex("AdPerformance", ["Date"], {
12
+ name: "ad_performance_date_idx",
13
+ });
14
+
15
+ // Add indexes for Ad table
16
+ await queryInterface.addIndex("Ad", ["AdSetID"], {
17
+ name: "ad_adsetid_idx",
18
+ });
19
+
20
+ await queryInterface.addIndex("Ad", ["AGRS_CID"], {
21
+ name: "ad_agrs_cid_idx",
22
+ });
23
+
24
+ await queryInterface.addIndex("Ad", ["Status"], {
25
+ name: "ad_status_idx",
26
+ });
27
+
28
+ // Add indexes for AdSet table
29
+ await queryInterface.addIndex("AdSet", ["CampaignID"], {
30
+ name: "adset_campaignid_idx",
31
+ });
32
+
33
+ await queryInterface.addIndex("AdSet", ["Status"], {
34
+ name: "adset_status_idx",
35
+ });
36
+
37
+ // Add indexes for Campaign table
38
+ await queryInterface.addIndex("Campaign", ["AdAccountID"], {
39
+ name: "campaign_adaccountid_idx",
40
+ });
41
+
42
+ await queryInterface.addIndex("Campaign", ["Status"], {
43
+ name: "campaign_status_idx",
44
+ });
45
+
46
+ await queryInterface.addIndex("Campaign", ["CreatedTime"], {
47
+ name: "campaign_createdtime_idx",
48
+ });
49
+ },
50
+
51
+ down: async (queryInterface, Sequelize) => {
52
+ // Remove indexes in reverse order
53
+ await queryInterface.removeIndex("Campaign", "campaign_createdtime_idx");
54
+ await queryInterface.removeIndex("Campaign", "campaign_status_idx");
55
+ await queryInterface.removeIndex("Campaign", "campaign_adaccountid_idx");
56
+
57
+ await queryInterface.removeIndex("AdSet", "adset_status_idx");
58
+ await queryInterface.removeIndex("AdSet", "adset_campaignid_idx");
59
+
60
+ await queryInterface.removeIndex("Ad", "ad_status_idx");
61
+ await queryInterface.removeIndex("Ad", "ad_agrs_cid_idx");
62
+ await queryInterface.removeIndex("Ad", "ad_adsetid_idx");
63
+
64
+ await queryInterface.removeIndex(
65
+ "AdPerformance",
66
+ "ad_performance_date_idx"
67
+ );
68
+ await queryInterface.removeIndex(
69
+ "AdPerformance",
70
+ "ad_performance_date_adid_idx"
71
+ );
72
+ },
73
+ };
package/models/Ad.js CHANGED
@@ -21,6 +21,10 @@ module.exports = (sequelize, DataTypes) => {
21
21
  creativeId: {
22
22
  type: DataTypes.STRING,
23
23
  allowNull: true,
24
+ // references: {
25
+ // model: "AdCreatives", // Assuming you have an AdCreative model
26
+ // key: "id",
27
+ // },
24
28
  },
25
29
  pixelId: {
26
30
  type: DataTypes.STRING,
@@ -40,27 +44,27 @@ module.exports = (sequelize, DataTypes) => {
40
44
  defaultValue: "SINGLE",
41
45
  },
42
46
  imageHashes: {
43
- type: DataTypes.ARRAY(DataTypes.STRING),
47
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of image hashes
44
48
  allowNull: true,
45
49
  },
46
50
  videoIds: {
47
- type: DataTypes.ARRAY(DataTypes.STRING),
51
+ type: DataTypes.ARRAY(DataTypes.STRING), // Array of video IDs
48
52
  allowNull: true,
49
53
  },
50
54
  messages: {
51
- type: DataTypes.ARRAY(DataTypes.TEXT),
55
+ type: DataTypes.ARRAY(DataTypes.TEXT), // Array of primary text messages
52
56
  allowNull: true,
53
57
  },
54
58
  headlines: {
55
- type: DataTypes.ARRAY(DataTypes.TEXT),
59
+ type: DataTypes.ARRAY(DataTypes.TEXT), // Array of headlines
56
60
  allowNull: true,
57
61
  },
58
62
  websiteUrl: {
59
- type: DataTypes.TEXT,
63
+ type: DataTypes.TEXT, // Increase limit for longer URLs
60
64
  allowNull: true,
61
65
  },
62
66
  pageId: {
63
- type: DataTypes.STRING(256),
67
+ type: DataTypes.STRING(256), // Increase limit for longer URLs
64
68
  allowNull: true,
65
69
  },
66
70
  actionTypes: {
@@ -94,14 +98,17 @@ module.exports = (sequelize, DataTypes) => {
94
98
  type: DataTypes.STRING,
95
99
  allowNull: true,
96
100
  },
101
+ // add effective_status field
97
102
  effectiveStatus: {
98
103
  type: DataTypes.STRING,
99
104
  allowNull: true,
100
105
  },
106
+ // add issues_info field
101
107
  issuesInfo: {
102
108
  type: DataTypes.JSONB,
103
109
  allowNull: true,
104
110
  },
111
+ // add ad_review_feedback
105
112
  adReviewFeedback: {
106
113
  type: DataTypes.JSONB,
107
114
  allowNull: true,
@@ -115,27 +122,44 @@ module.exports = (sequelize, DataTypes) => {
115
122
  tableName: "Ad",
116
123
  indexes: [
117
124
  {
118
- fields: ["AdSetID"],
125
+ fields: ["AdSetID"], // Index on AdSetID for faster join
119
126
  },
120
127
  ],
121
128
  }
122
129
  );
123
130
 
131
+ // Ad.associate = (models) => {
132
+ // Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
133
+
134
+ // // Association with CodefuelCampaign using AGRS_CID
135
+ // Ad.belongsTo(models.CodefuelCampaign, {
136
+ // foreignKey: "AGRS_CID",
137
+ // targetKey: "AGRSCID",
138
+ // as: "CodefuelCampaign",
139
+ // constraints: false, // Disable FK constraint at the DB level
140
+ // });
141
+
142
+ // Ad.hasMany(models.AdPerformance, {
143
+ // foreignKey: "AdID",
144
+ // });
145
+ // };
146
+
124
147
  Ad.associate = (models) => {
125
148
  Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
126
149
 
150
+ // Add dynamic relations to either CodefuelCampaign or RSOCFeedCampaign
127
151
  Ad.belongsTo(models.CodefuelCampaign, {
128
152
  foreignKey: "AGRS_CID",
129
153
  targetKey: "AGRSCID",
130
154
  as: "CodefuelCampaign",
131
- constraints: false,
155
+ constraints: false, // Disable FK constraint
132
156
  });
133
157
 
134
158
  Ad.belongsTo(models.RSOCFeedCampaign, {
135
159
  foreignKey: "AGRS_CID",
136
160
  targetKey: "AGRS_CID",
137
161
  as: "RSOCFeedCampaign",
138
- constraints: false,
162
+ constraints: false, // Disable FK constraint
139
163
  });
140
164
 
141
165
  Ad.hasMany(models.AdPerformance, {
@@ -143,6 +167,46 @@ module.exports = (sequelize, DataTypes) => {
143
167
  });
144
168
  };
145
169
 
170
+ // // Method to dynamically fetch related campaign
171
+ // Ad.prototype.getRelatedCampaign = async function () {
172
+ // if (!this.AGRS_CID) return null;
173
+
174
+ // const codefuelCampaign = await sequelize.models.CodefuelCampaign.findOne({
175
+ // where: { AGRSCID: this.AGRS_CID },
176
+ // });
177
+
178
+ // if (codefuelCampaign) {
179
+ // return {
180
+ // type: "CodefuelCampaign",
181
+ // data: codefuelCampaign,
182
+ // };
183
+ // }
184
+
185
+ // const tonicCampaign = await sequelize.models.TonicCampaign.findOne({
186
+ // where: { AGRSCID: this.AGRS_CID },
187
+ // });
188
+
189
+ // if (tonicCampaign) {
190
+ // return {
191
+ // type: "TonicCampaign",
192
+ // data: tonicCampaign,
193
+ // };
194
+ // }
195
+
196
+ // // do the same with RSOCFeedCampaign
197
+ // const rsocFeedCampaign = await sequelize.models.RSOCFeedCampaign.findOne({
198
+ // where: { AGRS_CID: this.AGRS_CID },
199
+ // });
200
+
201
+ // if (rsocFeedCampaign) {
202
+ // return {
203
+ // type: "RSOCFeedCampaign",
204
+ // data: rsocFeedCampaign,
205
+ // };
206
+ // }
207
+ // return null;
208
+ // };
209
+
146
210
  Ad.prototype.getRelatedCampaign = async function () {
147
211
  if (!this.AGRS_CID) return null;
148
212