agrs-sequelize-sdk 1.1.95 → 1.1.97
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/Ad.js +9 -73
- package/models/AdSet.js +0 -144
- package/models/RSOCFeedCampaign.js +10 -1
- package/package.json +1 -1
- package/agrs-sequelize/LICENSE +0 -21
- package/agrs-sequelize/README.md +0 -179
- package/agrs-sequelize/index.js +0 -169
- package/agrs-sequelize/jq.exe +0 -0
- package/agrs-sequelize/models/ActivityHistory.js +0 -73
- package/agrs-sequelize/models/Ad.js +0 -209
- package/agrs-sequelize/models/AdAccount.js +0 -91
- package/agrs-sequelize/models/AdAccountValues.js +0 -26
- package/agrs-sequelize/models/AdHistory.js +0 -30
- package/agrs-sequelize/models/AdPerformance.js +0 -84
- package/agrs-sequelize/models/AdPerformanceHourly.js +0 -66
- package/agrs-sequelize/models/AdSet.js +0 -140
- package/agrs-sequelize/models/AdSetHistory.js +0 -30
- package/agrs-sequelize/models/AdsetPerformance.js +0 -116
- package/agrs-sequelize/models/Article.js +0 -156
- package/agrs-sequelize/models/Buyers.js +0 -26
- package/agrs-sequelize/models/Campaign.js +0 -136
- package/agrs-sequelize/models/CampaignCreationLog.js +0 -86
- package/agrs-sequelize/models/CampaignHistory.js +0 -33
- package/agrs-sequelize/models/Channel.js +0 -55
- package/agrs-sequelize/models/CodefuelCampaign.js +0 -159
- package/agrs-sequelize/models/CodefuelCampaignKWHistory.js +0 -41
- package/agrs-sequelize/models/CodefuelKeywords.js +0 -35
- package/agrs-sequelize/models/CurrencyRate.js +0 -27
- package/agrs-sequelize/models/Domain.js +0 -26
- package/agrs-sequelize/models/ExplorAdsChannel.js +0 -62
- package/agrs-sequelize/models/Feed.js +0 -34
- package/agrs-sequelize/models/Files.js +0 -73
- package/agrs-sequelize/models/Folders.js +0 -133
- package/agrs-sequelize/models/KeywordPerformance.js +0 -99
- package/agrs-sequelize/models/KeywordRotationState.js +0 -51
- package/agrs-sequelize/models/Pages.js +0 -74
- package/agrs-sequelize/models/PipelineExecution.js +0 -46
- package/agrs-sequelize/models/RSOCFeedCampaign.js +0 -302
- package/agrs-sequelize/models/RsocKeywordPerformance.js +0 -111
- package/agrs-sequelize/models/Rule.js +0 -39
- package/agrs-sequelize/models/RulesValues.js +0 -56
- package/agrs-sequelize/models/SupportedLocale.js +0 -24
- package/agrs-sequelize/models/TonicCampaign.js +0 -97
- package/agrs-sequelize/models/Users.js +0 -111
- package/agrs-sequelize/models/Vertical.js +0 -26
- package/agrs-sequelize/models/newFiles.js +0 -68
- package/agrs-sequelize/models/pixel.js +0 -33
- package/agrs-sequelize/models/pixels.js +0 -33
- package/agrs-sequelize/package-lock.json +0 -405
- package/agrs-sequelize/package.json +0 -19
- package/agrs-sequelize/run.ps1 +0 -98
- package/agrs-sequelize/run.sh +0 -214
package/agrs-sequelize/index.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
const Sequelize = require("sequelize");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
// const env = process.env.NODE_ENV || "development";
|
|
6
|
-
class DBModels {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
this.config = config;
|
|
9
|
-
this.db = {};
|
|
10
|
-
|
|
11
|
-
// Initialize Sequelize
|
|
12
|
-
const sequelize = new Sequelize(
|
|
13
|
-
this.config.database,
|
|
14
|
-
this.config.username,
|
|
15
|
-
this.config.password,
|
|
16
|
-
{
|
|
17
|
-
host: this.config.host,
|
|
18
|
-
dialect: this.config.dialect,
|
|
19
|
-
port: this.config.port,
|
|
20
|
-
logging: false, // Enable logging to console
|
|
21
|
-
dialectOptions: {
|
|
22
|
-
ssl: {
|
|
23
|
-
require: true, // Require SSL
|
|
24
|
-
rejectUnauthorized: false, // For self-signed or unverified certificates
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
pool: {
|
|
28
|
-
max: 200, // Increase from 50, but stay under max_connections (200)
|
|
29
|
-
min: 5, // Increase minimum connections
|
|
30
|
-
acquire: 60000, // Double acquire timeout
|
|
31
|
-
idle: 30000, // Align with idle_in_transaction_session_timeout
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
retry: {
|
|
35
|
-
max: 5,
|
|
36
|
-
timeout: 60000,
|
|
37
|
-
match: [
|
|
38
|
-
/Connection terminated/,
|
|
39
|
-
/Connection timed out/,
|
|
40
|
-
/Operation timeout/,
|
|
41
|
-
/password authentication failed/,
|
|
42
|
-
/canceling authentication/,
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// Load all models
|
|
49
|
-
fs.readdirSync(path.join(__dirname, "models"))
|
|
50
|
-
.filter((file) => {
|
|
51
|
-
return file.indexOf(".") !== 0 && file.slice(-3) === ".js";
|
|
52
|
-
})
|
|
53
|
-
.forEach((file) => {
|
|
54
|
-
const model = require(path.join(__dirname, "models", file))(
|
|
55
|
-
sequelize,
|
|
56
|
-
Sequelize.DataTypes
|
|
57
|
-
);
|
|
58
|
-
this.db[model.name] = model;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Set up associations
|
|
62
|
-
Object.keys(this.db).forEach((modelName) => {
|
|
63
|
-
if (this.db[modelName].associate) {
|
|
64
|
-
this.db[modelName].associate(this.db);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Export the db object with Sequelize and models
|
|
69
|
-
this.db.sequelize = sequelize;
|
|
70
|
-
this.db.Sequelize = Sequelize;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = DBModels;
|
|
75
|
-
|
|
76
|
-
// const Sequelize = require("sequelize");
|
|
77
|
-
// const path = require("path");
|
|
78
|
-
// const fs = require("fs");
|
|
79
|
-
|
|
80
|
-
// class DBModels {
|
|
81
|
-
// constructor(config) {
|
|
82
|
-
// this.config = config;
|
|
83
|
-
// this.db = {};
|
|
84
|
-
|
|
85
|
-
// const sequelize = new Sequelize(
|
|
86
|
-
// this.config.database,
|
|
87
|
-
// this.config.username,
|
|
88
|
-
// this.config.password,
|
|
89
|
-
// {
|
|
90
|
-
// host: this.config.host,
|
|
91
|
-
// dialect: this.config.dialect,
|
|
92
|
-
// port: this.config.port,
|
|
93
|
-
// logging: false,
|
|
94
|
-
// dialectOptions: {
|
|
95
|
-
// ssl: {
|
|
96
|
-
// require: true,
|
|
97
|
-
// rejectUnauthorized: false,
|
|
98
|
-
// },
|
|
99
|
-
// statement_timeout: 30000,
|
|
100
|
-
// idle_in_transaction_session_timeout: 30000,
|
|
101
|
-
// connectTimeout: 30000,
|
|
102
|
-
// },
|
|
103
|
-
// pool: {
|
|
104
|
-
// max: 50, // Quarter of max connections (200)
|
|
105
|
-
// min: 0, // Start from 0 and scale up as needed
|
|
106
|
-
// acquire: 30000, // Maximum time to wait for a connection
|
|
107
|
-
// idle: 10000, // How long a connection can remain idle
|
|
108
|
-
// },
|
|
109
|
-
// retry: {
|
|
110
|
-
// max: 3,
|
|
111
|
-
// timeout: 20000,
|
|
112
|
-
// match: [
|
|
113
|
-
// /Connection terminated/,
|
|
114
|
-
// /Connection timed out/,
|
|
115
|
-
// /Operation timeout/,
|
|
116
|
-
// /ECONNRESET/,
|
|
117
|
-
// /PROTOCOL_CONNECTION_LOST/,
|
|
118
|
-
// ],
|
|
119
|
-
// },
|
|
120
|
-
// }
|
|
121
|
-
// );
|
|
122
|
-
|
|
123
|
-
// // Add connection monitoring listeners
|
|
124
|
-
// sequelize.connectionManager.on("acquire", function (connection) {
|
|
125
|
-
// console.log("Connection %d acquired", connection.threadId);
|
|
126
|
-
// });
|
|
127
|
-
|
|
128
|
-
// sequelize.connectionManager.on("release", function (connection) {
|
|
129
|
-
// console.log("Connection %d released", connection.threadId);
|
|
130
|
-
// });
|
|
131
|
-
|
|
132
|
-
// // Load all models
|
|
133
|
-
// fs.readdirSync(path.join(__dirname, "models"))
|
|
134
|
-
// .filter((file) => {
|
|
135
|
-
// return file.indexOf(".") !== 0 && file.slice(-3) === ".js";
|
|
136
|
-
// })
|
|
137
|
-
// .forEach((file) => {
|
|
138
|
-
// const model = require(path.join(__dirname, "models", file))(
|
|
139
|
-
// sequelize,
|
|
140
|
-
// Sequelize.DataTypes
|
|
141
|
-
// );
|
|
142
|
-
// this.db[model.name] = model;
|
|
143
|
-
// });
|
|
144
|
-
|
|
145
|
-
// // Set up associations
|
|
146
|
-
// Object.keys(this.db).forEach((modelName) => {
|
|
147
|
-
// if (this.db[modelName].associate) {
|
|
148
|
-
// this.db[modelName].associate(this.db);
|
|
149
|
-
// }
|
|
150
|
-
// });
|
|
151
|
-
|
|
152
|
-
// // Export the db object with Sequelize and models
|
|
153
|
-
// this.db.sequelize = sequelize;
|
|
154
|
-
// this.db.Sequelize = Sequelize;
|
|
155
|
-
// }
|
|
156
|
-
|
|
157
|
-
// // Add method for pool monitoring
|
|
158
|
-
// async getConnectionPoolStats() {
|
|
159
|
-
// const pool = this.db.sequelize.connectionManager.pool;
|
|
160
|
-
// return {
|
|
161
|
-
// all: pool.size,
|
|
162
|
-
// available: pool.available,
|
|
163
|
-
// borrowed: pool.borrowed,
|
|
164
|
-
// pending: pool.pending,
|
|
165
|
-
// };
|
|
166
|
-
// }
|
|
167
|
-
// }
|
|
168
|
-
|
|
169
|
-
// module.exports = DBModels;
|
package/agrs-sequelize/jq.exe
DELETED
|
Binary file
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// models/ActivityHistory.js
|
|
2
|
-
module.exports = (sequelize, DataTypes) => {
|
|
3
|
-
const ActivityHistory = sequelize.define(
|
|
4
|
-
"ActivityHistory",
|
|
5
|
-
{
|
|
6
|
-
ActivityHistoryID: {
|
|
7
|
-
type: DataTypes.INTEGER,
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
autoIncrement: true,
|
|
10
|
-
},
|
|
11
|
-
AssociatedModelType: {
|
|
12
|
-
type: DataTypes.STRING,
|
|
13
|
-
allowNull: false, // Could be 'Ad', 'AdSet', 'Campaign', etc.
|
|
14
|
-
},
|
|
15
|
-
AssociatedModelID: {
|
|
16
|
-
type: DataTypes.STRING,
|
|
17
|
-
allowNull: false, // ID of the associated model
|
|
18
|
-
},
|
|
19
|
-
ActorID: {
|
|
20
|
-
type: DataTypes.STRING,
|
|
21
|
-
allowNull: true,
|
|
22
|
-
},
|
|
23
|
-
ActorName: {
|
|
24
|
-
type: DataTypes.STRING,
|
|
25
|
-
allowNull: true,
|
|
26
|
-
},
|
|
27
|
-
ApplicationName: {
|
|
28
|
-
type: DataTypes.STRING,
|
|
29
|
-
allowNull: true,
|
|
30
|
-
},
|
|
31
|
-
DateTimeInTimeZone: {
|
|
32
|
-
type: DataTypes.DATE,
|
|
33
|
-
allowNull: true,
|
|
34
|
-
},
|
|
35
|
-
EventType: {
|
|
36
|
-
type: DataTypes.STRING,
|
|
37
|
-
allowNull: true,
|
|
38
|
-
},
|
|
39
|
-
ObjectName: {
|
|
40
|
-
type: DataTypes.STRING,
|
|
41
|
-
allowNull: true,
|
|
42
|
-
},
|
|
43
|
-
ObjectType: {
|
|
44
|
-
type: DataTypes.STRING,
|
|
45
|
-
allowNull: true,
|
|
46
|
-
},
|
|
47
|
-
TranslatedEventType: {
|
|
48
|
-
type: DataTypes.STRING,
|
|
49
|
-
allowNull: true,
|
|
50
|
-
},
|
|
51
|
-
ObjectID: {
|
|
52
|
-
type: DataTypes.STRING,
|
|
53
|
-
allowNull: true,
|
|
54
|
-
},
|
|
55
|
-
ExtraData: {
|
|
56
|
-
type: DataTypes.JSONB,
|
|
57
|
-
allowNull: true,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
tableName: "ActivityHistory",
|
|
62
|
-
indexes: [
|
|
63
|
-
{
|
|
64
|
-
unique: true,
|
|
65
|
-
name: "unique_index_on_date_object_event", // Custom name
|
|
66
|
-
fields: ["DateTimeInTimeZone", "ObjectID", "EventType"],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return ActivityHistory;
|
|
73
|
-
};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const Ad = sequelize.define(
|
|
3
|
-
"Ad",
|
|
4
|
-
{
|
|
5
|
-
AdID: {
|
|
6
|
-
type: DataTypes.STRING,
|
|
7
|
-
primaryKey: true,
|
|
8
|
-
},
|
|
9
|
-
AdName: {
|
|
10
|
-
type: DataTypes.STRING,
|
|
11
|
-
allowNull: false,
|
|
12
|
-
},
|
|
13
|
-
AdSetID: {
|
|
14
|
-
type: DataTypes.STRING,
|
|
15
|
-
allowNull: false,
|
|
16
|
-
references: {
|
|
17
|
-
model: "AdSet",
|
|
18
|
-
key: "AdSetID",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
creativeId: {
|
|
22
|
-
type: DataTypes.STRING,
|
|
23
|
-
allowNull: true,
|
|
24
|
-
},
|
|
25
|
-
pixelId: {
|
|
26
|
-
type: DataTypes.STRING,
|
|
27
|
-
allowNull: true,
|
|
28
|
-
},
|
|
29
|
-
startTime: {
|
|
30
|
-
type: DataTypes.DATE,
|
|
31
|
-
allowNull: true,
|
|
32
|
-
},
|
|
33
|
-
endTime: {
|
|
34
|
-
type: DataTypes.DATE,
|
|
35
|
-
allowNull: true,
|
|
36
|
-
},
|
|
37
|
-
format: {
|
|
38
|
-
type: DataTypes.STRING,
|
|
39
|
-
allowNull: false,
|
|
40
|
-
defaultValue: "SINGLE",
|
|
41
|
-
},
|
|
42
|
-
imageHashes: {
|
|
43
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
44
|
-
allowNull: true,
|
|
45
|
-
},
|
|
46
|
-
videoIds: {
|
|
47
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
48
|
-
allowNull: true,
|
|
49
|
-
},
|
|
50
|
-
messages: {
|
|
51
|
-
type: DataTypes.ARRAY(DataTypes.TEXT),
|
|
52
|
-
allowNull: true,
|
|
53
|
-
},
|
|
54
|
-
headlines: {
|
|
55
|
-
type: DataTypes.ARRAY(DataTypes.TEXT),
|
|
56
|
-
allowNull: true,
|
|
57
|
-
},
|
|
58
|
-
websiteUrl: {
|
|
59
|
-
type: DataTypes.TEXT,
|
|
60
|
-
allowNull: true,
|
|
61
|
-
},
|
|
62
|
-
pageId: {
|
|
63
|
-
type: DataTypes.STRING(256),
|
|
64
|
-
allowNull: true,
|
|
65
|
-
},
|
|
66
|
-
actionTypes: {
|
|
67
|
-
type: DataTypes.STRING,
|
|
68
|
-
allowNull: true,
|
|
69
|
-
defaultValue: "offsite_conversion",
|
|
70
|
-
},
|
|
71
|
-
Status: {
|
|
72
|
-
type: DataTypes.STRING,
|
|
73
|
-
allowNull: true,
|
|
74
|
-
},
|
|
75
|
-
publish: {
|
|
76
|
-
type: DataTypes.BOOLEAN,
|
|
77
|
-
allowNull: true,
|
|
78
|
-
defaultValue: true,
|
|
79
|
-
},
|
|
80
|
-
createdTime: {
|
|
81
|
-
type: DataTypes.DATE,
|
|
82
|
-
allowNull: true,
|
|
83
|
-
},
|
|
84
|
-
AGRS_CID: {
|
|
85
|
-
type: DataTypes.STRING,
|
|
86
|
-
allowNull: true,
|
|
87
|
-
},
|
|
88
|
-
Draft: {
|
|
89
|
-
type: DataTypes.BOOLEAN,
|
|
90
|
-
allowNull: true,
|
|
91
|
-
defaultValue: false,
|
|
92
|
-
},
|
|
93
|
-
UserCreated: {
|
|
94
|
-
type: DataTypes.STRING,
|
|
95
|
-
allowNull: true,
|
|
96
|
-
},
|
|
97
|
-
effectiveStatus: {
|
|
98
|
-
type: DataTypes.STRING,
|
|
99
|
-
allowNull: true,
|
|
100
|
-
},
|
|
101
|
-
issuesInfo: {
|
|
102
|
-
type: DataTypes.JSONB,
|
|
103
|
-
allowNull: true,
|
|
104
|
-
},
|
|
105
|
-
adReviewFeedback: {
|
|
106
|
-
type: DataTypes.JSONB,
|
|
107
|
-
allowNull: true,
|
|
108
|
-
},
|
|
109
|
-
waiting: {
|
|
110
|
-
type: DataTypes.BOOLEAN,
|
|
111
|
-
defaultValue: false,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
tableName: "Ad",
|
|
116
|
-
indexes: [
|
|
117
|
-
{
|
|
118
|
-
fields: ["AdSetID"],
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
Ad.associate = (models) => {
|
|
125
|
-
Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
|
|
126
|
-
|
|
127
|
-
Ad.belongsTo(models.CodefuelCampaign, {
|
|
128
|
-
foreignKey: "AGRS_CID",
|
|
129
|
-
targetKey: "AGRSCID",
|
|
130
|
-
as: "CodefuelCampaign",
|
|
131
|
-
constraints: false,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
Ad.belongsTo(models.RSOCFeedCampaign, {
|
|
135
|
-
foreignKey: "AGRS_CID",
|
|
136
|
-
targetKey: "AGRS_CID",
|
|
137
|
-
as: "RSOCFeedCampaign",
|
|
138
|
-
constraints: false,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
Ad.hasMany(models.AdPerformance, {
|
|
142
|
-
foreignKey: "AdID",
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
Ad.prototype.getRelatedCampaign = async function () {
|
|
147
|
-
if (!this.AGRS_CID) return null;
|
|
148
|
-
|
|
149
|
-
// Try fetching related CodefuelCampaign
|
|
150
|
-
const codefuelCampaign = await sequelize.models.CodefuelCampaign.findOne({
|
|
151
|
-
where: { AGRSCID: this.AGRS_CID },
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (codefuelCampaign) {
|
|
155
|
-
return {
|
|
156
|
-
type: "CodefuelCampaign",
|
|
157
|
-
data: codefuelCampaign,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Try fetching related RSOCFeedCampaign
|
|
162
|
-
const rsocFeedCampaign = await sequelize.models.RSOCFeedCampaign.findOne({
|
|
163
|
-
where: { AGRS_CID: this.AGRS_CID },
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
if (rsocFeedCampaign) {
|
|
167
|
-
return {
|
|
168
|
-
type: "RSOCFeedCampaign",
|
|
169
|
-
data: rsocFeedCampaign,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return null;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
Ad.addHook("afterCreate", async (ad, options) => {
|
|
177
|
-
if (ad.publish === false) {
|
|
178
|
-
// If publish is false on creation, save a snapshot to AdHistory
|
|
179
|
-
await sequelize.models.AdHistory.create({
|
|
180
|
-
AdID: ad.AdID,
|
|
181
|
-
DataSnapshot: ad.toJSON(), // Save the full Ad data as JSON
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
Ad.addHook("beforeUpdate", async (ad, options) => {
|
|
187
|
-
if (ad.changed("publish")) {
|
|
188
|
-
if (ad.previous("publish") === true && ad.publish === false) {
|
|
189
|
-
// Save current state to AdHistory
|
|
190
|
-
await sequelize.models.AdHistory.create({
|
|
191
|
-
AdID: ad.AdID,
|
|
192
|
-
DataSnapshot: ad._previousDataValues, // Save the full Ad data as JSON
|
|
193
|
-
});
|
|
194
|
-
} else if (ad.previous("publish") === false && ad.publish === true) {
|
|
195
|
-
// Delete the latest history entry
|
|
196
|
-
const latestHistory = await sequelize.models.AdHistory.findOne({
|
|
197
|
-
where: { AdID: ad.AdID },
|
|
198
|
-
order: [["timestamp", "DESC"]], // Get the latest history entry
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
if (latestHistory) {
|
|
202
|
-
await latestHistory.destroy();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
return Ad;
|
|
209
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdAccount = sequelize.define(
|
|
3
|
-
"AdAccount",
|
|
4
|
-
{
|
|
5
|
-
AdAccountID: {
|
|
6
|
-
type: DataTypes.STRING,
|
|
7
|
-
primaryKey: true,
|
|
8
|
-
},
|
|
9
|
-
AdAccountName: {
|
|
10
|
-
type: DataTypes.STRING,
|
|
11
|
-
allowNull: false,
|
|
12
|
-
},
|
|
13
|
-
AdAccountTimeZone: {
|
|
14
|
-
type: DataTypes.STRING,
|
|
15
|
-
allowNull: false,
|
|
16
|
-
},
|
|
17
|
-
Currency: {
|
|
18
|
-
type: DataTypes.STRING,
|
|
19
|
-
allowNull: false,
|
|
20
|
-
},
|
|
21
|
-
Rate: {
|
|
22
|
-
type: DataTypes.FLOAT,
|
|
23
|
-
allowNull: false,
|
|
24
|
-
},
|
|
25
|
-
UTCOffset: {
|
|
26
|
-
type: DataTypes.INTEGER,
|
|
27
|
-
allowNull: false,
|
|
28
|
-
},
|
|
29
|
-
Draft: {
|
|
30
|
-
type: DataTypes.BOOLEAN,
|
|
31
|
-
allowNull: true,
|
|
32
|
-
},
|
|
33
|
-
account_status: {
|
|
34
|
-
type: DataTypes.INTEGER,
|
|
35
|
-
allowNull: true,
|
|
36
|
-
},
|
|
37
|
-
// includeInUpdate: bool
|
|
38
|
-
IncludeInUpdate: {
|
|
39
|
-
type: DataTypes.BOOLEAN,
|
|
40
|
-
allowNull: true,
|
|
41
|
-
},
|
|
42
|
-
BusinessManager: {
|
|
43
|
-
type: DataTypes.STRING,
|
|
44
|
-
allowNull: true,
|
|
45
|
-
},
|
|
46
|
-
Reporting: {
|
|
47
|
-
type: DataTypes.BOOLEAN,
|
|
48
|
-
defaultValue: true,
|
|
49
|
-
allowNull: true,
|
|
50
|
-
},
|
|
51
|
-
Users: {
|
|
52
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
53
|
-
allowNull: false,
|
|
54
|
-
defaultValue: [],
|
|
55
|
-
},
|
|
56
|
-
feedProvider: {
|
|
57
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
58
|
-
allowNull: false,
|
|
59
|
-
defaultValue: [], // Default value is an empty array
|
|
60
|
-
},
|
|
61
|
-
Archived: {
|
|
62
|
-
type: DataTypes.BOOLEAN,
|
|
63
|
-
allowNull: true,
|
|
64
|
-
},
|
|
65
|
-
disabled_reason: {
|
|
66
|
-
type: DataTypes.STRING,
|
|
67
|
-
allowNull: true,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
tableName: "AdAccount",
|
|
72
|
-
indexes: [
|
|
73
|
-
{
|
|
74
|
-
fields: ["AdAccountName"],
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
fields: ["Currency"],
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
AdAccount.associate = (models) => {
|
|
84
|
-
AdAccount.hasMany(models.Campaign, {
|
|
85
|
-
foreignKey: "AdAccountID",
|
|
86
|
-
as: "Campaigns",
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return AdAccount;
|
|
91
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
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,84 +0,0 @@
|
|
|
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
|
-
};
|