agrs-sequelize-sdk 1.2.12 → 1.2.14
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/models/AdAccountValues.js +25 -25
- package/models/AdHistory.js +30 -30
- package/models/AdPerformance.js +84 -84
- package/models/AdSetHistory.js +30 -30
- package/models/AdsetPerformance.js +116 -116
- package/models/Article.js +156 -156
- package/models/Buyers.js +25 -25
- package/models/Campaign.js +135 -135
- package/models/CampaignCreationLog.js +86 -86
- package/models/CampaignCreationLogNew.js +141 -141
- package/models/CampaignHistory.js +33 -33
- package/models/Channel.js +55 -55
- package/models/Domain.js +25 -25
- package/models/ExplorAdsChannel.js +61 -61
- package/models/Feed.js +33 -33
- package/models/Pages.js +73 -73
- package/models/PipelineExecution.js +46 -46
- package/models/RSOCFeedCampaign.js +303 -298
- package/models/RsocKeywordPerformance.js +110 -110
- package/models/RulesValues.js +56 -56
- package/models/SupportedLocale.js +23 -23
- package/models/Vertical.js +25 -25
- package/models/newFiles.js +68 -68
- package/package.json +21 -19
- package/run.sh +214 -214
- package/utils/loggerUtils.js +497 -497
- package/controllers/campaignCreationLogsController.js +0 -264
- package/migrations/20240321000000-add-performance-indexes.js +0 -73
- package/routes/api.js +0 -18
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdAccountValues = sequelize.define(
|
|
3
|
-
"AdAccountValues",
|
|
4
|
-
{
|
|
5
|
-
id: {
|
|
6
|
-
type: DataTypes.UUID,
|
|
7
|
-
defaultValue: DataTypes.UUIDV4,
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
},
|
|
10
|
-
name: {
|
|
11
|
-
type: DataTypes.STRING,
|
|
12
|
-
allowNull: false,
|
|
13
|
-
},
|
|
14
|
-
code: {
|
|
15
|
-
type: DataTypes.STRING,
|
|
16
|
-
allowNull: false,
|
|
17
|
-
unique: true,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
tableName: "AdAccountValues",
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
return AdAccountValues;
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AdAccountValues = sequelize.define(
|
|
3
|
+
"AdAccountValues",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
defaultValue: DataTypes.UUIDV4,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
code: {
|
|
15
|
+
type: DataTypes.STRING,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
unique: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
tableName: "AdAccountValues",
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return AdAccountValues;
|
|
26
26
|
};
|
package/models/AdHistory.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdHistory = sequelize.define(
|
|
3
|
-
"AdHistory",
|
|
4
|
-
{
|
|
5
|
-
HistoryID: {
|
|
6
|
-
type: DataTypes.UUID,
|
|
7
|
-
defaultValue: DataTypes.UUIDV4,
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
},
|
|
10
|
-
AdID: {
|
|
11
|
-
type: DataTypes.STRING,
|
|
12
|
-
allowNull: false,
|
|
13
|
-
},
|
|
14
|
-
DataSnapshot: {
|
|
15
|
-
type: DataTypes.JSONB, // Store the full Ad row as a JSON object
|
|
16
|
-
allowNull: false,
|
|
17
|
-
},
|
|
18
|
-
timestamp: {
|
|
19
|
-
type: DataTypes.DATE,
|
|
20
|
-
defaultValue: DataTypes.NOW,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
tableName: "AdHistory",
|
|
25
|
-
timestamps: false, // Disable Sequelize timestamps
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
return AdHistory;
|
|
30
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AdHistory = sequelize.define(
|
|
3
|
+
"AdHistory",
|
|
4
|
+
{
|
|
5
|
+
HistoryID: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
defaultValue: DataTypes.UUIDV4,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
AdID: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
DataSnapshot: {
|
|
15
|
+
type: DataTypes.JSONB, // Store the full Ad row as a JSON object
|
|
16
|
+
allowNull: false,
|
|
17
|
+
},
|
|
18
|
+
timestamp: {
|
|
19
|
+
type: DataTypes.DATE,
|
|
20
|
+
defaultValue: DataTypes.NOW,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
tableName: "AdHistory",
|
|
25
|
+
timestamps: false, // Disable Sequelize timestamps
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return AdHistory;
|
|
30
|
+
};
|
package/models/AdPerformance.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdPerformance = sequelize.define(
|
|
3
|
-
"AdPerformance",
|
|
4
|
-
{
|
|
5
|
-
Date: {
|
|
6
|
-
type: DataTypes.DATEONLY,
|
|
7
|
-
primaryKey: true,
|
|
8
|
-
},
|
|
9
|
-
AdID: {
|
|
10
|
-
type: DataTypes.STRING,
|
|
11
|
-
allowNull: false,
|
|
12
|
-
primaryKey: true,
|
|
13
|
-
},
|
|
14
|
-
AmountSpent: {
|
|
15
|
-
type: DataTypes.FLOAT,
|
|
16
|
-
allowNull: true,
|
|
17
|
-
},
|
|
18
|
-
Impressions: {
|
|
19
|
-
type: DataTypes.INTEGER,
|
|
20
|
-
allowNull: true,
|
|
21
|
-
},
|
|
22
|
-
LinkClicks: {
|
|
23
|
-
type: DataTypes.INTEGER,
|
|
24
|
-
allowNull: true,
|
|
25
|
-
},
|
|
26
|
-
Revenue: {
|
|
27
|
-
type: DataTypes.FLOAT,
|
|
28
|
-
allowNull: true,
|
|
29
|
-
},
|
|
30
|
-
AdClicks: {
|
|
31
|
-
type: DataTypes.INTEGER,
|
|
32
|
-
allowNull: true,
|
|
33
|
-
},
|
|
34
|
-
Sessions: {
|
|
35
|
-
type: DataTypes.INTEGER,
|
|
36
|
-
allowNull: true,
|
|
37
|
-
},
|
|
38
|
-
ViewContent: {
|
|
39
|
-
// New field
|
|
40
|
-
type: DataTypes.INTEGER,
|
|
41
|
-
allowNull: true,
|
|
42
|
-
},
|
|
43
|
-
Search: {
|
|
44
|
-
// New field
|
|
45
|
-
type: DataTypes.INTEGER,
|
|
46
|
-
allowNull: true,
|
|
47
|
-
},
|
|
48
|
-
Purchase: {
|
|
49
|
-
// New field
|
|
50
|
-
type: DataTypes.INTEGER,
|
|
51
|
-
allowNull: true,
|
|
52
|
-
},
|
|
53
|
-
originalSpend: {
|
|
54
|
-
type: DataTypes.FLOAT,
|
|
55
|
-
allowNull: true,
|
|
56
|
-
},
|
|
57
|
-
originRevenue: {
|
|
58
|
-
type: DataTypes.FLOAT,
|
|
59
|
-
allowNull: true,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
tableName: "AdPerformance",
|
|
64
|
-
indexes: [
|
|
65
|
-
{
|
|
66
|
-
unique: true,
|
|
67
|
-
fields: ["AdID", "Date"], // Composite unique index
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
fields: ["Date"], // Index on Date for faster range queries
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
fields: ["AdID"], // Index on AdID for faster join
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
AdPerformance.associate = (models) => {
|
|
80
|
-
AdPerformance.belongsTo(models.Ad, { foreignKey: "AdID" });
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return AdPerformance;
|
|
84
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AdPerformance = sequelize.define(
|
|
3
|
+
"AdPerformance",
|
|
4
|
+
{
|
|
5
|
+
Date: {
|
|
6
|
+
type: DataTypes.DATEONLY,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
},
|
|
9
|
+
AdID: {
|
|
10
|
+
type: DataTypes.STRING,
|
|
11
|
+
allowNull: false,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
},
|
|
14
|
+
AmountSpent: {
|
|
15
|
+
type: DataTypes.FLOAT,
|
|
16
|
+
allowNull: true,
|
|
17
|
+
},
|
|
18
|
+
Impressions: {
|
|
19
|
+
type: DataTypes.INTEGER,
|
|
20
|
+
allowNull: true,
|
|
21
|
+
},
|
|
22
|
+
LinkClicks: {
|
|
23
|
+
type: DataTypes.INTEGER,
|
|
24
|
+
allowNull: true,
|
|
25
|
+
},
|
|
26
|
+
Revenue: {
|
|
27
|
+
type: DataTypes.FLOAT,
|
|
28
|
+
allowNull: true,
|
|
29
|
+
},
|
|
30
|
+
AdClicks: {
|
|
31
|
+
type: DataTypes.INTEGER,
|
|
32
|
+
allowNull: true,
|
|
33
|
+
},
|
|
34
|
+
Sessions: {
|
|
35
|
+
type: DataTypes.INTEGER,
|
|
36
|
+
allowNull: true,
|
|
37
|
+
},
|
|
38
|
+
ViewContent: {
|
|
39
|
+
// New field
|
|
40
|
+
type: DataTypes.INTEGER,
|
|
41
|
+
allowNull: true,
|
|
42
|
+
},
|
|
43
|
+
Search: {
|
|
44
|
+
// New field
|
|
45
|
+
type: DataTypes.INTEGER,
|
|
46
|
+
allowNull: true,
|
|
47
|
+
},
|
|
48
|
+
Purchase: {
|
|
49
|
+
// New field
|
|
50
|
+
type: DataTypes.INTEGER,
|
|
51
|
+
allowNull: true,
|
|
52
|
+
},
|
|
53
|
+
originalSpend: {
|
|
54
|
+
type: DataTypes.FLOAT,
|
|
55
|
+
allowNull: true,
|
|
56
|
+
},
|
|
57
|
+
originRevenue: {
|
|
58
|
+
type: DataTypes.FLOAT,
|
|
59
|
+
allowNull: true,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
tableName: "AdPerformance",
|
|
64
|
+
indexes: [
|
|
65
|
+
{
|
|
66
|
+
unique: true,
|
|
67
|
+
fields: ["AdID", "Date"], // Composite unique index
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
fields: ["Date"], // Index on Date for faster range queries
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
fields: ["AdID"], // Index on AdID for faster join
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
AdPerformance.associate = (models) => {
|
|
80
|
+
AdPerformance.belongsTo(models.Ad, { foreignKey: "AdID" });
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return AdPerformance;
|
|
84
|
+
};
|
package/models/AdSetHistory.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdSetHistory = sequelize.define(
|
|
3
|
-
"AdSetHistory",
|
|
4
|
-
{
|
|
5
|
-
HistoryID: {
|
|
6
|
-
type: DataTypes.UUID,
|
|
7
|
-
defaultValue: DataTypes.UUIDV4,
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
},
|
|
10
|
-
AdSetID: {
|
|
11
|
-
type: DataTypes.STRING,
|
|
12
|
-
allowNull: false,
|
|
13
|
-
},
|
|
14
|
-
DataSnapshot: {
|
|
15
|
-
type: DataTypes.JSONB, // Store the full AdSet row as a JSON object
|
|
16
|
-
allowNull: false,
|
|
17
|
-
},
|
|
18
|
-
timestamp: {
|
|
19
|
-
type: DataTypes.DATE,
|
|
20
|
-
defaultValue: DataTypes.NOW,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
tableName: "AdSetHistory",
|
|
25
|
-
timestamps: false,
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
return AdSetHistory;
|
|
30
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AdSetHistory = sequelize.define(
|
|
3
|
+
"AdSetHistory",
|
|
4
|
+
{
|
|
5
|
+
HistoryID: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
defaultValue: DataTypes.UUIDV4,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
AdSetID: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
DataSnapshot: {
|
|
15
|
+
type: DataTypes.JSONB, // Store the full AdSet row as a JSON object
|
|
16
|
+
allowNull: false,
|
|
17
|
+
},
|
|
18
|
+
timestamp: {
|
|
19
|
+
type: DataTypes.DATE,
|
|
20
|
+
defaultValue: DataTypes.NOW,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
tableName: "AdSetHistory",
|
|
25
|
+
timestamps: false,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return AdSetHistory;
|
|
30
|
+
};
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdSetPerformance = sequelize.define(
|
|
3
|
-
"AdSetPerformance",
|
|
4
|
-
{
|
|
5
|
-
AdSetID: {
|
|
6
|
-
type: DataTypes.STRING,
|
|
7
|
-
allowNull: false,
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
// Part of the composite primary key identifying the AdSet
|
|
10
|
-
},
|
|
11
|
-
Date: {
|
|
12
|
-
type: DataTypes.DATEONLY,
|
|
13
|
-
allowNull: false,
|
|
14
|
-
primaryKey: true,
|
|
15
|
-
// Part of the composite primary key representing the performance date
|
|
16
|
-
},
|
|
17
|
-
ChannelID: {
|
|
18
|
-
type: DataTypes.STRING,
|
|
19
|
-
allowNull: true,
|
|
20
|
-
// Optional identifier for the channel, extracted from AdSet name if available
|
|
21
|
-
},
|
|
22
|
-
StyleID: {
|
|
23
|
-
type: DataTypes.STRING,
|
|
24
|
-
allowNull: true,
|
|
25
|
-
// Optional identifier for the style, extracted from AdSet name if available
|
|
26
|
-
},
|
|
27
|
-
Spend: {
|
|
28
|
-
type: DataTypes.FLOAT,
|
|
29
|
-
defaultValue: 0,
|
|
30
|
-
// Total spend on the AdSet from the source platform (e.g., Facebook)
|
|
31
|
-
},
|
|
32
|
-
Impressions: {
|
|
33
|
-
type: DataTypes.INTEGER,
|
|
34
|
-
defaultValue: 0,
|
|
35
|
-
// Number of impressions recorded by the source platform
|
|
36
|
-
},
|
|
37
|
-
LinkClicks: {
|
|
38
|
-
type: DataTypes.INTEGER,
|
|
39
|
-
defaultValue: 0,
|
|
40
|
-
// Number of link clicks recorded by the source platform
|
|
41
|
-
},
|
|
42
|
-
ViewContent: {
|
|
43
|
-
type: DataTypes.INTEGER,
|
|
44
|
-
defaultValue: 0,
|
|
45
|
-
// Number of view content events recorded by the source platform
|
|
46
|
-
},
|
|
47
|
-
Search: {
|
|
48
|
-
type: DataTypes.INTEGER,
|
|
49
|
-
defaultValue: 0,
|
|
50
|
-
// Number of search events recorded by the source platform
|
|
51
|
-
},
|
|
52
|
-
Purchase: {
|
|
53
|
-
type: DataTypes.INTEGER,
|
|
54
|
-
defaultValue: 0,
|
|
55
|
-
// Number of purchase events recorded by the source platform
|
|
56
|
-
},
|
|
57
|
-
ExternalRevenue: {
|
|
58
|
-
type: DataTypes.FLOAT,
|
|
59
|
-
defaultValue: 0,
|
|
60
|
-
// Revenue data from an external source (e.g., analytics or monetization platforms)
|
|
61
|
-
},
|
|
62
|
-
ExternalImpressions: {
|
|
63
|
-
type: DataTypes.INTEGER,
|
|
64
|
-
defaultValue: 0,
|
|
65
|
-
// Number of impressions recorded by an external source
|
|
66
|
-
},
|
|
67
|
-
ExternalClicks: {
|
|
68
|
-
type: DataTypes.INTEGER,
|
|
69
|
-
defaultValue: 0,
|
|
70
|
-
// Number of clicks recorded by an external source
|
|
71
|
-
},
|
|
72
|
-
ExternalRequests: {
|
|
73
|
-
type: DataTypes.INTEGER,
|
|
74
|
-
defaultValue: 0,
|
|
75
|
-
// Number of requests recorded by an external source
|
|
76
|
-
},
|
|
77
|
-
ROI: {
|
|
78
|
-
type: DataTypes.FLOAT,
|
|
79
|
-
defaultValue: 0,
|
|
80
|
-
// Calculated Return on Investment (ExternalRevenue / Spend)
|
|
81
|
-
},
|
|
82
|
-
agrscid: {
|
|
83
|
-
type: DataTypes.STRING,
|
|
84
|
-
allowNull: true,
|
|
85
|
-
// Optional identifier for the AdSet, extracted from AdSet url if available
|
|
86
|
-
},
|
|
87
|
-
originalRevenue: {
|
|
88
|
-
type: DataTypes.FLOAT,
|
|
89
|
-
defaultValue: 0,
|
|
90
|
-
// Original revenue value before any modifications or calculations
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
tableName: "AdSetPerformance",
|
|
95
|
-
timestamps: false, // No need for createdAt/updatedAt timestamps
|
|
96
|
-
indexes: [
|
|
97
|
-
{
|
|
98
|
-
unique: true,
|
|
99
|
-
fields: ["AdSetID", "Date"],
|
|
100
|
-
// Composite unique index to ensure one record per AdSet per date
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// Define associations with other models
|
|
107
|
-
AdSetPerformance.associate = (models) => {
|
|
108
|
-
AdSetPerformance.belongsTo(models.AdSet, {
|
|
109
|
-
foreignKey: "AdSetID",
|
|
110
|
-
targetKey: "AdSetID",
|
|
111
|
-
// Links to the AdSet model for additional AdSet details
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
return AdSetPerformance;
|
|
116
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AdSetPerformance = sequelize.define(
|
|
3
|
+
"AdSetPerformance",
|
|
4
|
+
{
|
|
5
|
+
AdSetID: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
// Part of the composite primary key identifying the AdSet
|
|
10
|
+
},
|
|
11
|
+
Date: {
|
|
12
|
+
type: DataTypes.DATEONLY,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
primaryKey: true,
|
|
15
|
+
// Part of the composite primary key representing the performance date
|
|
16
|
+
},
|
|
17
|
+
ChannelID: {
|
|
18
|
+
type: DataTypes.STRING,
|
|
19
|
+
allowNull: true,
|
|
20
|
+
// Optional identifier for the channel, extracted from AdSet name if available
|
|
21
|
+
},
|
|
22
|
+
StyleID: {
|
|
23
|
+
type: DataTypes.STRING,
|
|
24
|
+
allowNull: true,
|
|
25
|
+
// Optional identifier for the style, extracted from AdSet name if available
|
|
26
|
+
},
|
|
27
|
+
Spend: {
|
|
28
|
+
type: DataTypes.FLOAT,
|
|
29
|
+
defaultValue: 0,
|
|
30
|
+
// Total spend on the AdSet from the source platform (e.g., Facebook)
|
|
31
|
+
},
|
|
32
|
+
Impressions: {
|
|
33
|
+
type: DataTypes.INTEGER,
|
|
34
|
+
defaultValue: 0,
|
|
35
|
+
// Number of impressions recorded by the source platform
|
|
36
|
+
},
|
|
37
|
+
LinkClicks: {
|
|
38
|
+
type: DataTypes.INTEGER,
|
|
39
|
+
defaultValue: 0,
|
|
40
|
+
// Number of link clicks recorded by the source platform
|
|
41
|
+
},
|
|
42
|
+
ViewContent: {
|
|
43
|
+
type: DataTypes.INTEGER,
|
|
44
|
+
defaultValue: 0,
|
|
45
|
+
// Number of view content events recorded by the source platform
|
|
46
|
+
},
|
|
47
|
+
Search: {
|
|
48
|
+
type: DataTypes.INTEGER,
|
|
49
|
+
defaultValue: 0,
|
|
50
|
+
// Number of search events recorded by the source platform
|
|
51
|
+
},
|
|
52
|
+
Purchase: {
|
|
53
|
+
type: DataTypes.INTEGER,
|
|
54
|
+
defaultValue: 0,
|
|
55
|
+
// Number of purchase events recorded by the source platform
|
|
56
|
+
},
|
|
57
|
+
ExternalRevenue: {
|
|
58
|
+
type: DataTypes.FLOAT,
|
|
59
|
+
defaultValue: 0,
|
|
60
|
+
// Revenue data from an external source (e.g., analytics or monetization platforms)
|
|
61
|
+
},
|
|
62
|
+
ExternalImpressions: {
|
|
63
|
+
type: DataTypes.INTEGER,
|
|
64
|
+
defaultValue: 0,
|
|
65
|
+
// Number of impressions recorded by an external source
|
|
66
|
+
},
|
|
67
|
+
ExternalClicks: {
|
|
68
|
+
type: DataTypes.INTEGER,
|
|
69
|
+
defaultValue: 0,
|
|
70
|
+
// Number of clicks recorded by an external source
|
|
71
|
+
},
|
|
72
|
+
ExternalRequests: {
|
|
73
|
+
type: DataTypes.INTEGER,
|
|
74
|
+
defaultValue: 0,
|
|
75
|
+
// Number of requests recorded by an external source
|
|
76
|
+
},
|
|
77
|
+
ROI: {
|
|
78
|
+
type: DataTypes.FLOAT,
|
|
79
|
+
defaultValue: 0,
|
|
80
|
+
// Calculated Return on Investment (ExternalRevenue / Spend)
|
|
81
|
+
},
|
|
82
|
+
agrscid: {
|
|
83
|
+
type: DataTypes.STRING,
|
|
84
|
+
allowNull: true,
|
|
85
|
+
// Optional identifier for the AdSet, extracted from AdSet url if available
|
|
86
|
+
},
|
|
87
|
+
originalRevenue: {
|
|
88
|
+
type: DataTypes.FLOAT,
|
|
89
|
+
defaultValue: 0,
|
|
90
|
+
// Original revenue value before any modifications or calculations
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
tableName: "AdSetPerformance",
|
|
95
|
+
timestamps: false, // No need for createdAt/updatedAt timestamps
|
|
96
|
+
indexes: [
|
|
97
|
+
{
|
|
98
|
+
unique: true,
|
|
99
|
+
fields: ["AdSetID", "Date"],
|
|
100
|
+
// Composite unique index to ensure one record per AdSet per date
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Define associations with other models
|
|
107
|
+
AdSetPerformance.associate = (models) => {
|
|
108
|
+
AdSetPerformance.belongsTo(models.AdSet, {
|
|
109
|
+
foreignKey: "AdSetID",
|
|
110
|
+
targetKey: "AdSetID",
|
|
111
|
+
// Links to the AdSet model for additional AdSet details
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return AdSetPerformance;
|
|
116
|
+
};
|