agrs-sequelize-sdk 1.4.57 → 1.4.59

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 (120) hide show
  1. package/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -85
  2. package/migrations/2026-05-17-add-platform-to-ad.js +19 -19
  3. package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -19
  4. package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -19
  5. package/migrations/2026-05-17-add-platform-to-adset.js +19 -19
  6. package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -19
  7. package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -19
  8. package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -19
  9. package/migrations/2026-05-17-add-platform-to-article.js +19 -19
  10. package/migrations/2026-05-17-add-platform-to-campaign.js +19 -19
  11. package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -19
  12. package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -19
  13. package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -19
  14. package/migrations/2026-05-17-add-platform-to-pages.js +19 -19
  15. package/migrations/2026-05-17-add-platform-to-presets.js +19 -19
  16. package/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -18
  17. package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -65
  18. package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -55
  19. package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -55
  20. package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -16
  21. package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -16
  22. package/migrations/2026-05-18-add-review-status-to-ad.js +36 -36
  23. package/migrations/2026-05-18-create-canonical-insights.js +84 -84
  24. package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -68
  25. package/migrations/2026-05-18-create-tiktok-identities.js +71 -71
  26. package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -143
  27. package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -309
  28. package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -99
  29. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  30. package/migrations/change-adset-name-to-text.js +79 -79
  31. package/models/AICampaignQueue.js +151 -152
  32. package/models/AIGenerationLog.js +85 -85
  33. package/models/AIGenerationRequest.js +212 -212
  34. package/models/AdAccountValues.js +25 -25
  35. package/models/AdHistory.js +30 -30
  36. package/models/AdPerformance.js +104 -104
  37. package/models/AdSet.js +295 -295
  38. package/models/AdSetHistory.js +30 -30
  39. package/models/AdsetPerformance.js +137 -137
  40. package/models/AiArticleRetryQueue.js +157 -157
  41. package/models/AiCreationRetryQueue.js +134 -134
  42. package/models/ApiAuditLog.js +127 -127
  43. package/models/ApiToken.js +67 -67
  44. package/models/Article.js +222 -222
  45. package/models/AutomationRule.js +179 -179
  46. package/models/BannerTemplate.js +129 -129
  47. package/models/Buyers.js +25 -25
  48. package/models/Campaign.js +168 -168
  49. package/models/CampaignActionHistory.js +101 -101
  50. package/models/CampaignCreationLog.js +340 -340
  51. package/models/CampaignCreationLogV2.js +392 -392
  52. package/models/CampaignHistory.js +33 -33
  53. package/models/CampaignTag.js +46 -46
  54. package/models/CampaignTagAssignment.js +48 -48
  55. package/models/CanonicalInsights.js +68 -68
  56. package/models/Channel.js +55 -55
  57. package/models/Domain.js +44 -44
  58. package/models/DynamicFeed.js +218 -218
  59. package/models/ExplorAdsChannel.js +61 -61
  60. package/models/FacebookRetryQueue.js +163 -163
  61. package/models/Feed.js +33 -33
  62. package/models/FeedArticleConfiguration.js +80 -80
  63. package/models/FrontStoryChannel.js +59 -59
  64. package/models/FrontStoryChannelV2.js +60 -60
  65. package/models/GenericFlowRequest.js +114 -114
  66. package/models/MidoWebChannel.js +47 -47
  67. package/models/MineBrandBlocklist.js +56 -56
  68. package/models/MineBrandConfig.js +26 -26
  69. package/models/MineChannel.js +47 -47
  70. package/models/MineRedirectDomain.js +42 -42
  71. package/models/MineWebhookEvent.js +53 -53
  72. package/models/Pages.js +117 -117
  73. package/models/PipelineExecution.js +59 -59
  74. package/models/PolicyDogsCreativeCache.js +50 -50
  75. package/models/PolicyDogsImageCache.js +30 -30
  76. package/models/Presets.js +40 -40
  77. package/models/PublicApiBatch.js +155 -155
  78. package/models/PublicApiBatchItem.js +166 -166
  79. package/models/PublicApiIdempotencyCache.js +135 -135
  80. package/models/RSOCFeedCampaign.js +387 -387
  81. package/models/RSOCFeedConfig.js +46 -46
  82. package/models/RSOCRedirectWsCode.js +22 -22
  83. package/models/RsocKeywordPerformance.js +110 -110
  84. package/models/RuleAction.js +90 -90
  85. package/models/RuleCondition.js +137 -137
  86. package/models/RuleExecution.js +107 -107
  87. package/models/RulesValues.js +56 -56
  88. package/models/SingularChannel.js +31 -31
  89. package/models/SnapchatAd.js +69 -69
  90. package/models/SnapchatAdSquad.js +92 -92
  91. package/models/SnapchatCampaign.js +69 -69
  92. package/models/SnapchatChannel.js +31 -31
  93. package/models/SnapchatPublicProfiles.js +67 -67
  94. package/models/SupportedLocale.js +23 -23
  95. package/models/SyncHistory.js +249 -249
  96. package/models/TTQChannel.js +42 -42
  97. package/models/Team.js +43 -43
  98. package/models/TemplateMetadata.js +260 -260
  99. package/models/Tier2_AdAccounts.js +110 -110
  100. package/models/Tier2_Assets.js +70 -70
  101. package/models/Tier2_BusinessManagers.js +105 -105
  102. package/models/Tier2_CreditLines.js +99 -99
  103. package/models/Tier2_Pages.js +91 -91
  104. package/models/Tier2_Pixels.js +82 -82
  105. package/models/Tier2_Tokens.js +64 -64
  106. package/models/Tier2_UserAdAccounts.js +83 -83
  107. package/models/TikTokAd.js +71 -71
  108. package/models/TikTokAdGroup.js +82 -82
  109. package/models/TikTokCampaign.js +71 -71
  110. package/models/TiktokChannel.js +31 -31
  111. package/models/TiktokIdentities.js +65 -65
  112. package/models/TokenRotationState.js +121 -121
  113. package/models/TonicRSOCKeywordPerformance.js +122 -122
  114. package/models/Users.js +204 -204
  115. package/models/Vertical.js +25 -25
  116. package/models/newFiles.js +137 -137
  117. package/package.json +19 -21
  118. package/run.sh +214 -214
  119. package/services/sequelizeService.js +110 -110
  120. package/tarzo-skalio-integration-docs.md +691 -691
@@ -1,24 +1,24 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const SupportedLocale = sequelize.define('SupportedLocale', {
3
- country: {
4
- type: DataTypes.STRING,
5
- allowNull: false,
6
- },
7
- locale: {
8
- type: DataTypes.STRING,
9
- allowNull: false,
10
- },
11
- language: {
12
- type: DataTypes.STRING,
13
- allowNull: true,
14
- comment: 'Language code (e.g., en, es, fr)'
15
- }
16
- });
17
-
18
- // Define associations if needed in the future
19
- // SupportedLocale.associate = (models) => {
20
- // // e.g., SupportedLocale.hasMany(models.OtherModel);
21
- // };
22
-
23
- return SupportedLocale;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const SupportedLocale = sequelize.define('SupportedLocale', {
3
+ country: {
4
+ type: DataTypes.STRING,
5
+ allowNull: false,
6
+ },
7
+ locale: {
8
+ type: DataTypes.STRING,
9
+ allowNull: false,
10
+ },
11
+ language: {
12
+ type: DataTypes.STRING,
13
+ allowNull: true,
14
+ comment: 'Language code (e.g., en, es, fr)'
15
+ }
16
+ });
17
+
18
+ // Define associations if needed in the future
19
+ // SupportedLocale.associate = (models) => {
20
+ // // e.g., SupportedLocale.hasMany(models.OtherModel);
21
+ // };
22
+
23
+ return SupportedLocale;
24
24
  };
@@ -1,250 +1,250 @@
1
- // models/SyncHistory.js
2
- module.exports = (sequelize, DataTypes) => {
3
- const SyncHistory = sequelize.define(
4
- "SyncHistory",
5
- {
6
- id: {
7
- type: DataTypes.INTEGER,
8
- primaryKey: true,
9
- autoIncrement: true,
10
- },
11
- syncId: {
12
- type: DataTypes.STRING,
13
- allowNull: false,
14
- unique: true,
15
- comment: "Unique identifier for the sync operation"
16
- },
17
- syncType: {
18
- type: DataTypes.ENUM('manual', 'quick_sync', 'group_sync', 'preset_sync', 'scheduled'),
19
- allowNull: false,
20
- defaultValue: 'manual',
21
- comment: "Type of sync operation performed"
22
- },
23
- initiatedBy: {
24
- type: DataTypes.STRING,
25
- allowNull: true,
26
- comment: "User who initiated the sync (username or user ID)"
27
- },
28
- startTime: {
29
- type: DataTypes.DATE,
30
- allowNull: false,
31
- comment: "When the sync operation started"
32
- },
33
- endTime: {
34
- type: DataTypes.DATE,
35
- allowNull: true,
36
- comment: "When the sync operation completed"
37
- },
38
- duration: {
39
- type: DataTypes.INTEGER,
40
- allowNull: true,
41
- comment: "Duration in milliseconds"
42
- },
43
- status: {
44
- type: DataTypes.ENUM('running', 'completed', 'failed', 'cancelled'),
45
- allowNull: false,
46
- defaultValue: 'running',
47
- comment: "Current status of the sync operation"
48
- },
49
- success: {
50
- type: DataTypes.BOOLEAN,
51
- allowNull: true,
52
- comment: "Whether the sync completed successfully"
53
- },
54
- totalTables: {
55
- type: DataTypes.INTEGER,
56
- allowNull: false,
57
- defaultValue: 0,
58
- comment: "Total number of tables in the sync"
59
- },
60
- successfulTables: {
61
- type: DataTypes.INTEGER,
62
- allowNull: false,
63
- defaultValue: 0,
64
- comment: "Number of tables synced successfully"
65
- },
66
- failedTables: {
67
- type: DataTypes.INTEGER,
68
- allowNull: false,
69
- defaultValue: 0,
70
- comment: "Number of tables that failed to sync"
71
- },
72
- totalRecords: {
73
- type: DataTypes.INTEGER,
74
- allowNull: false,
75
- defaultValue: 0,
76
- comment: "Total number of records synced"
77
- },
78
- tablesIncluded: {
79
- type: DataTypes.ARRAY(DataTypes.STRING),
80
- allowNull: false,
81
- defaultValue: [],
82
- comment: "List of tables included in this sync"
83
- },
84
- syncOptions: {
85
- type: DataTypes.JSONB,
86
- allowNull: true,
87
- comment: "Sync options used (truncateFirst, batchSize, etc.)"
88
- },
89
- errorCount: {
90
- type: DataTypes.INTEGER,
91
- allowNull: false,
92
- defaultValue: 0,
93
- comment: "Number of errors encountered"
94
- },
95
- errorSummary: {
96
- type: DataTypes.TEXT,
97
- allowNull: true,
98
- comment: "Brief summary of errors encountered"
99
- },
100
- detailedResults: {
101
- type: DataTypes.JSONB,
102
- allowNull: true,
103
- comment: "Detailed results for each table (success/failure, record counts, errors)"
104
- },
105
- safetyChecks: {
106
- type: DataTypes.JSONB,
107
- allowNull: true,
108
- comment: "Safety check results (hosts, direction, etc.)"
109
- },
110
- sourceHost: {
111
- type: DataTypes.STRING,
112
- allowNull: true,
113
- comment: "Production database host"
114
- },
115
- targetHost: {
116
- type: DataTypes.STRING,
117
- allowNull: true,
118
- comment: "Staging database host"
119
- },
120
- environment: {
121
- type: DataTypes.STRING,
122
- allowNull: true,
123
- comment: "Environment where sync was executed (development, staging, production)"
124
- },
125
- groupsOrPreset: {
126
- type: DataTypes.STRING,
127
- allowNull: true,
128
- comment: "If this was a group/preset sync, which one was used"
129
- }
130
- },
131
- {
132
- tableName: "SyncHistory",
133
- timestamps: true, // Adds createdAt and updatedAt
134
- indexes: [
135
- {
136
- fields: ["syncId"],
137
- unique: true
138
- },
139
- {
140
- fields: ["startTime"],
141
- name: "idx_sync_history_start_time"
142
- },
143
- {
144
- fields: ["status"],
145
- name: "idx_sync_history_status"
146
- },
147
- {
148
- fields: ["success"],
149
- name: "idx_sync_history_success"
150
- },
151
- {
152
- fields: ["syncType"],
153
- name: "idx_sync_history_type"
154
- },
155
- {
156
- fields: ["initiatedBy"],
157
- name: "idx_sync_history_user"
158
- },
159
- {
160
- fields: ["createdAt"],
161
- name: "idx_sync_history_created"
162
- }
163
- ]
164
- }
165
- );
166
-
167
- // Add model methods
168
- SyncHistory.prototype.getDurationInSeconds = function() {
169
- return this.duration ? (this.duration / 1000).toFixed(1) : null;
170
- };
171
-
172
- SyncHistory.prototype.getSuccessRate = function() {
173
- if (this.totalTables === 0) return 0;
174
- return ((this.successfulTables / this.totalTables) * 100).toFixed(1);
175
- };
176
-
177
- SyncHistory.prototype.isRunning = function() {
178
- return this.status === 'running';
179
- };
180
-
181
- SyncHistory.prototype.hasErrors = function() {
182
- return this.errorCount > 0;
183
- };
184
-
185
- // Static methods for common queries
186
- SyncHistory.getRecentHistory = async function(limit = 10) {
187
- return await this.findAll({
188
- order: [['startTime', 'DESC']],
189
- limit: limit
190
- });
191
- };
192
-
193
- SyncHistory.getRunningsyncs = async function() {
194
- return await this.findAll({
195
- where: { status: 'running' },
196
- order: [['startTime', 'DESC']]
197
- });
198
- };
199
-
200
- SyncHistory.getSuccessfulSyncs = async function(limit = 10) {
201
- return await this.findAll({
202
- where: { success: true },
203
- order: [['startTime', 'DESC']],
204
- limit: limit
205
- });
206
- };
207
-
208
- SyncHistory.getFailedSyncs = async function(limit = 10) {
209
- return await this.findAll({
210
- where: { success: false },
211
- order: [['startTime', 'DESC']],
212
- limit: limit
213
- });
214
- };
215
-
216
- SyncHistory.getSyncStats = async function() {
217
- const total = await this.count();
218
- const successful = await this.count({ where: { success: true } });
219
- const failed = await this.count({ where: { success: false } });
220
- const running = await this.count({ where: { status: 'running' } });
221
-
222
- const avgDuration = await this.findOne({
223
- attributes: [
224
- [sequelize.fn('AVG', sequelize.col('duration')), 'avgDuration']
225
- ],
226
- where: { success: true },
227
- raw: true
228
- });
229
-
230
- const totalRecords = await this.findOne({
231
- attributes: [
232
- [sequelize.fn('SUM', sequelize.col('totalRecords')), 'totalRecords']
233
- ],
234
- where: { success: true },
235
- raw: true
236
- });
237
-
238
- return {
239
- totalSyncs: total,
240
- successfulSyncs: successful,
241
- failedSyncs: failed,
242
- runningSyncs: running,
243
- successRate: total > 0 ? ((successful / total) * 100).toFixed(1) : 0,
244
- averageDuration: avgDuration?.avgDuration ? Math.round(avgDuration.avgDuration) : null,
245
- totalRecordsSynced: totalRecords?.totalRecords || 0
246
- };
247
- };
248
-
249
- return SyncHistory;
1
+ // models/SyncHistory.js
2
+ module.exports = (sequelize, DataTypes) => {
3
+ const SyncHistory = sequelize.define(
4
+ "SyncHistory",
5
+ {
6
+ id: {
7
+ type: DataTypes.INTEGER,
8
+ primaryKey: true,
9
+ autoIncrement: true,
10
+ },
11
+ syncId: {
12
+ type: DataTypes.STRING,
13
+ allowNull: false,
14
+ unique: true,
15
+ comment: "Unique identifier for the sync operation"
16
+ },
17
+ syncType: {
18
+ type: DataTypes.ENUM('manual', 'quick_sync', 'group_sync', 'preset_sync', 'scheduled'),
19
+ allowNull: false,
20
+ defaultValue: 'manual',
21
+ comment: "Type of sync operation performed"
22
+ },
23
+ initiatedBy: {
24
+ type: DataTypes.STRING,
25
+ allowNull: true,
26
+ comment: "User who initiated the sync (username or user ID)"
27
+ },
28
+ startTime: {
29
+ type: DataTypes.DATE,
30
+ allowNull: false,
31
+ comment: "When the sync operation started"
32
+ },
33
+ endTime: {
34
+ type: DataTypes.DATE,
35
+ allowNull: true,
36
+ comment: "When the sync operation completed"
37
+ },
38
+ duration: {
39
+ type: DataTypes.INTEGER,
40
+ allowNull: true,
41
+ comment: "Duration in milliseconds"
42
+ },
43
+ status: {
44
+ type: DataTypes.ENUM('running', 'completed', 'failed', 'cancelled'),
45
+ allowNull: false,
46
+ defaultValue: 'running',
47
+ comment: "Current status of the sync operation"
48
+ },
49
+ success: {
50
+ type: DataTypes.BOOLEAN,
51
+ allowNull: true,
52
+ comment: "Whether the sync completed successfully"
53
+ },
54
+ totalTables: {
55
+ type: DataTypes.INTEGER,
56
+ allowNull: false,
57
+ defaultValue: 0,
58
+ comment: "Total number of tables in the sync"
59
+ },
60
+ successfulTables: {
61
+ type: DataTypes.INTEGER,
62
+ allowNull: false,
63
+ defaultValue: 0,
64
+ comment: "Number of tables synced successfully"
65
+ },
66
+ failedTables: {
67
+ type: DataTypes.INTEGER,
68
+ allowNull: false,
69
+ defaultValue: 0,
70
+ comment: "Number of tables that failed to sync"
71
+ },
72
+ totalRecords: {
73
+ type: DataTypes.INTEGER,
74
+ allowNull: false,
75
+ defaultValue: 0,
76
+ comment: "Total number of records synced"
77
+ },
78
+ tablesIncluded: {
79
+ type: DataTypes.ARRAY(DataTypes.STRING),
80
+ allowNull: false,
81
+ defaultValue: [],
82
+ comment: "List of tables included in this sync"
83
+ },
84
+ syncOptions: {
85
+ type: DataTypes.JSONB,
86
+ allowNull: true,
87
+ comment: "Sync options used (truncateFirst, batchSize, etc.)"
88
+ },
89
+ errorCount: {
90
+ type: DataTypes.INTEGER,
91
+ allowNull: false,
92
+ defaultValue: 0,
93
+ comment: "Number of errors encountered"
94
+ },
95
+ errorSummary: {
96
+ type: DataTypes.TEXT,
97
+ allowNull: true,
98
+ comment: "Brief summary of errors encountered"
99
+ },
100
+ detailedResults: {
101
+ type: DataTypes.JSONB,
102
+ allowNull: true,
103
+ comment: "Detailed results for each table (success/failure, record counts, errors)"
104
+ },
105
+ safetyChecks: {
106
+ type: DataTypes.JSONB,
107
+ allowNull: true,
108
+ comment: "Safety check results (hosts, direction, etc.)"
109
+ },
110
+ sourceHost: {
111
+ type: DataTypes.STRING,
112
+ allowNull: true,
113
+ comment: "Production database host"
114
+ },
115
+ targetHost: {
116
+ type: DataTypes.STRING,
117
+ allowNull: true,
118
+ comment: "Staging database host"
119
+ },
120
+ environment: {
121
+ type: DataTypes.STRING,
122
+ allowNull: true,
123
+ comment: "Environment where sync was executed (development, staging, production)"
124
+ },
125
+ groupsOrPreset: {
126
+ type: DataTypes.STRING,
127
+ allowNull: true,
128
+ comment: "If this was a group/preset sync, which one was used"
129
+ }
130
+ },
131
+ {
132
+ tableName: "SyncHistory",
133
+ timestamps: true, // Adds createdAt and updatedAt
134
+ indexes: [
135
+ {
136
+ fields: ["syncId"],
137
+ unique: true
138
+ },
139
+ {
140
+ fields: ["startTime"],
141
+ name: "idx_sync_history_start_time"
142
+ },
143
+ {
144
+ fields: ["status"],
145
+ name: "idx_sync_history_status"
146
+ },
147
+ {
148
+ fields: ["success"],
149
+ name: "idx_sync_history_success"
150
+ },
151
+ {
152
+ fields: ["syncType"],
153
+ name: "idx_sync_history_type"
154
+ },
155
+ {
156
+ fields: ["initiatedBy"],
157
+ name: "idx_sync_history_user"
158
+ },
159
+ {
160
+ fields: ["createdAt"],
161
+ name: "idx_sync_history_created"
162
+ }
163
+ ]
164
+ }
165
+ );
166
+
167
+ // Add model methods
168
+ SyncHistory.prototype.getDurationInSeconds = function() {
169
+ return this.duration ? (this.duration / 1000).toFixed(1) : null;
170
+ };
171
+
172
+ SyncHistory.prototype.getSuccessRate = function() {
173
+ if (this.totalTables === 0) return 0;
174
+ return ((this.successfulTables / this.totalTables) * 100).toFixed(1);
175
+ };
176
+
177
+ SyncHistory.prototype.isRunning = function() {
178
+ return this.status === 'running';
179
+ };
180
+
181
+ SyncHistory.prototype.hasErrors = function() {
182
+ return this.errorCount > 0;
183
+ };
184
+
185
+ // Static methods for common queries
186
+ SyncHistory.getRecentHistory = async function(limit = 10) {
187
+ return await this.findAll({
188
+ order: [['startTime', 'DESC']],
189
+ limit: limit
190
+ });
191
+ };
192
+
193
+ SyncHistory.getRunningsyncs = async function() {
194
+ return await this.findAll({
195
+ where: { status: 'running' },
196
+ order: [['startTime', 'DESC']]
197
+ });
198
+ };
199
+
200
+ SyncHistory.getSuccessfulSyncs = async function(limit = 10) {
201
+ return await this.findAll({
202
+ where: { success: true },
203
+ order: [['startTime', 'DESC']],
204
+ limit: limit
205
+ });
206
+ };
207
+
208
+ SyncHistory.getFailedSyncs = async function(limit = 10) {
209
+ return await this.findAll({
210
+ where: { success: false },
211
+ order: [['startTime', 'DESC']],
212
+ limit: limit
213
+ });
214
+ };
215
+
216
+ SyncHistory.getSyncStats = async function() {
217
+ const total = await this.count();
218
+ const successful = await this.count({ where: { success: true } });
219
+ const failed = await this.count({ where: { success: false } });
220
+ const running = await this.count({ where: { status: 'running' } });
221
+
222
+ const avgDuration = await this.findOne({
223
+ attributes: [
224
+ [sequelize.fn('AVG', sequelize.col('duration')), 'avgDuration']
225
+ ],
226
+ where: { success: true },
227
+ raw: true
228
+ });
229
+
230
+ const totalRecords = await this.findOne({
231
+ attributes: [
232
+ [sequelize.fn('SUM', sequelize.col('totalRecords')), 'totalRecords']
233
+ ],
234
+ where: { success: true },
235
+ raw: true
236
+ });
237
+
238
+ return {
239
+ totalSyncs: total,
240
+ successfulSyncs: successful,
241
+ failedSyncs: failed,
242
+ runningSyncs: running,
243
+ successRate: total > 0 ? ((successful / total) * 100).toFixed(1) : 0,
244
+ averageDuration: avgDuration?.avgDuration ? Math.round(avgDuration.avgDuration) : null,
245
+ totalRecordsSynced: totalRecords?.totalRecords || 0
246
+ };
247
+ };
248
+
249
+ return SyncHistory;
250
250
  };
@@ -1,42 +1,42 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const TTQChannel = sequelize.define(
3
- "TTQChannel",
4
- {
5
- channelId: {
6
- type: DataTypes.STRING,
7
- allowNull: false,
8
- unique: true,
9
- },
10
- status: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- defaultValue: "free",
14
- validate: {
15
- isIn: [["free", "used", "archived"]],
16
- },
17
- },
18
- connectedCampaigns: {
19
- type: DataTypes.JSONB,
20
- allowNull: false,
21
- defaultValue: [],
22
- },
23
- },
24
- {
25
- tableName: "ttq_rsoc_channels",
26
- timestamps: true,
27
- }
28
- );
29
-
30
- TTQChannel.associate = (models) => {
31
- if (models.RSOCFeedCampaign) {
32
- TTQChannel.hasMany(models.RSOCFeedCampaign, {
33
- foreignKey: "channelId",
34
- sourceKey: "channelId",
35
- as: "RSOCFeedCampaigns",
36
- constraints: false,
37
- });
38
- }
39
- };
40
-
41
- return TTQChannel;
42
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const TTQChannel = sequelize.define(
3
+ "TTQChannel",
4
+ {
5
+ channelId: {
6
+ type: DataTypes.STRING,
7
+ allowNull: false,
8
+ unique: true,
9
+ },
10
+ status: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ defaultValue: "free",
14
+ validate: {
15
+ isIn: [["free", "used", "archived"]],
16
+ },
17
+ },
18
+ connectedCampaigns: {
19
+ type: DataTypes.JSONB,
20
+ allowNull: false,
21
+ defaultValue: [],
22
+ },
23
+ },
24
+ {
25
+ tableName: "ttq_rsoc_channels",
26
+ timestamps: true,
27
+ }
28
+ );
29
+
30
+ TTQChannel.associate = (models) => {
31
+ if (models.RSOCFeedCampaign) {
32
+ TTQChannel.hasMany(models.RSOCFeedCampaign, {
33
+ foreignKey: "channelId",
34
+ sourceKey: "channelId",
35
+ as: "RSOCFeedCampaigns",
36
+ constraints: false,
37
+ });
38
+ }
39
+ };
40
+
41
+ return TTQChannel;
42
+ };