codebase-models 3.1.3 → 3.1.5
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/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/src/models/Client.d.ts +3 -1
- package/dist/src/models/Client.js +2 -0
- package/dist/src/models/OldReport.d.ts +48 -0
- package/dist/src/models/OldReport.js +107 -0
- package/dist/src/models/Provider.d.ts +1 -10
- package/dist/src/models/Provider.js +9 -9
- package/index.ts +2 -0
- package/package.json +1 -1
- package/src/models/Client.ts +5 -2
- package/src/models/OldReport.ts +102 -0
- package/src/models/Provider.ts +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -81,5 +81,6 @@ import ThreadMessage from "./src/models/ThreadMessage";
|
|
|
81
81
|
import Provider from "./src/models/Provider";
|
|
82
82
|
import ApiLog from "./src/models/ApiLog";
|
|
83
83
|
import { ProviderType } from "./src/models/Provider";
|
|
84
|
+
import OldReport from "./src/models/OldReport";
|
|
84
85
|
export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
|
|
85
|
-
export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Provider, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, CustomQuery, SavedSegment, TestTimeline, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserOrganization, Package, Invitation, Thread, ThreadMessage, ApiLog, ProviderType, };
|
|
86
|
+
export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Provider, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, CustomQuery, SavedSegment, TestTimeline, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserOrganization, Package, Invitation, Thread, ThreadMessage, ApiLog, ProviderType, OldReport, };
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BqPreCompiledData = exports.PrecalculationFilters = exports.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.TestTimeline = exports.SavedSegment = exports.CustomQuery = exports.Role = exports.ReadNotification = exports.Portfolio = exports.PageTestType = exports.PageElement = exports.Page = exports.Notification = exports.NewIdeas = exports.LandingPages = exports.HypothesisSheet = exports.Hypothesis = exports.Goal = exports.Feedback = exports.Faq = exports.CVRReport = exports.ClientSurvey = exports.ClientStrategy = exports.ClientRetention = exports.ClientNote = exports.ClientNextStep = exports.ClientLinks = exports.ClientLearning = exports.ClientAdditionalRevenue = exports.Announcement = exports.AppEvent = exports.User = exports.TestSequentialValue = exports.Test = exports.Provider = exports.Report = exports.ClientReportsTemp = exports.Client = exports.RolesConstants = exports.generateRandomIID = exports.connect = void 0;
|
|
16
|
-
exports.ProviderType = exports.ApiLog = exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserPermission = exports.CronConfig = exports.CronData = void 0;
|
|
16
|
+
exports.OldReport = exports.ProviderType = exports.ApiLog = exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserPermission = exports.CronConfig = exports.CronData = void 0;
|
|
17
17
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
18
18
|
const Client_1 = __importDefault(require("./src/models/Client"));
|
|
19
19
|
exports.Client = Client_1.default;
|
|
@@ -132,6 +132,8 @@ const ApiLog_1 = __importDefault(require("./src/models/ApiLog"));
|
|
|
132
132
|
exports.ApiLog = ApiLog_1.default;
|
|
133
133
|
const Provider_2 = require("./src/models/Provider");
|
|
134
134
|
Object.defineProperty(exports, "ProviderType", { enumerable: true, get: function () { return Provider_2.ProviderType; } });
|
|
135
|
+
const OldReport_1 = __importDefault(require("./src/models/OldReport"));
|
|
136
|
+
exports.OldReport = OldReport_1.default;
|
|
135
137
|
function seedRoles() {
|
|
136
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
139
|
const checkRoles = yield Role_1.default.countDocuments();
|
|
@@ -32,7 +32,7 @@ export interface IClient extends Document {
|
|
|
32
32
|
iid: string;
|
|
33
33
|
organization: mongoose.Schema.Types.ObjectId;
|
|
34
34
|
name: string;
|
|
35
|
-
|
|
35
|
+
url: string;
|
|
36
36
|
viewId?: string;
|
|
37
37
|
portfolioClient?: boolean;
|
|
38
38
|
gaproperties?: IProperty[];
|
|
@@ -47,6 +47,8 @@ export interface IClient extends Document {
|
|
|
47
47
|
NDAStatus?: boolean;
|
|
48
48
|
retainerValue: number;
|
|
49
49
|
useIntraDayTable: boolean;
|
|
50
|
+
slug?: string;
|
|
51
|
+
onboardingCompleted: boolean;
|
|
50
52
|
}
|
|
51
53
|
declare const Client: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
52
54
|
export default Client;
|
|
@@ -51,6 +51,7 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
51
51
|
unique: true,
|
|
52
52
|
default: () => (0, constant_1.generateRandomIID)(),
|
|
53
53
|
},
|
|
54
|
+
url: { type: String, required: true },
|
|
54
55
|
organization: {
|
|
55
56
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
56
57
|
ref: "organization",
|
|
@@ -86,6 +87,7 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
86
87
|
NDAStatus: { type: Boolean, default: false },
|
|
87
88
|
retainerValue: { type: Number },
|
|
88
89
|
useIntraDayTable: { type: Boolean },
|
|
90
|
+
onboardingCompleted: { type: Boolean, default: false },
|
|
89
91
|
}, {
|
|
90
92
|
timestamps: true,
|
|
91
93
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import mongoose, { Document } from "mongoose";
|
|
26
|
+
export interface IOldReport extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
name: string;
|
|
29
|
+
segmentName?: string;
|
|
30
|
+
reportLink?: string;
|
|
31
|
+
conclusion?: string;
|
|
32
|
+
variant?: string;
|
|
33
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
34
|
+
viewId?: string;
|
|
35
|
+
test?: mongoose.Schema.Types.ObjectId;
|
|
36
|
+
gaTestId?: string;
|
|
37
|
+
reportDetails?: mongoose.Schema.Types.Mixed;
|
|
38
|
+
learnings?: mongoose.Schema.Types.Mixed;
|
|
39
|
+
from?: Date;
|
|
40
|
+
to?: Date;
|
|
41
|
+
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
42
|
+
excludedFromCalculations?: boolean;
|
|
43
|
+
createdAt?: Date;
|
|
44
|
+
updatedAt?: Date;
|
|
45
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
46
|
+
}
|
|
47
|
+
declare const OldReport: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
48
|
+
export default OldReport;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
|
+
const constant_1 = require("../constant");
|
|
37
|
+
const OldReportSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
42
|
+
organizationId: {
|
|
43
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
44
|
+
ref: "organization",
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
name: { type: String, required: true },
|
|
48
|
+
segmentName: { type: String },
|
|
49
|
+
reportLink: { type: String },
|
|
50
|
+
conclusion: { type: String },
|
|
51
|
+
variant: { type: String },
|
|
52
|
+
client: {
|
|
53
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
54
|
+
ref: "client"
|
|
55
|
+
},
|
|
56
|
+
viewId: { type: String },
|
|
57
|
+
test: {
|
|
58
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
59
|
+
ref: "test"
|
|
60
|
+
},
|
|
61
|
+
gaTestId: { type: String },
|
|
62
|
+
reportDetails: { type: mongoose_1.default.Schema.Types.Mixed },
|
|
63
|
+
learnings: {
|
|
64
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
65
|
+
default: []
|
|
66
|
+
},
|
|
67
|
+
from: { type: Date },
|
|
68
|
+
to: { type: Date },
|
|
69
|
+
createdBy: {
|
|
70
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
71
|
+
ref: "user"
|
|
72
|
+
},
|
|
73
|
+
excludedFromCalculations: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
timestamps: true
|
|
79
|
+
});
|
|
80
|
+
OldReportSchema.pre('save', function (next) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (!this.iid) {
|
|
83
|
+
let unique = false;
|
|
84
|
+
while (!unique) {
|
|
85
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
86
|
+
const existing = yield mongoose_1.default.models.report.findOne({ iid: id });
|
|
87
|
+
if (!existing) {
|
|
88
|
+
this.iid = id;
|
|
89
|
+
unique = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
next();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
// Add compound indexes for better query performance
|
|
97
|
+
OldReportSchema.index({ client: 1, conclusion: 1 });
|
|
98
|
+
// ReportsSchema.index({ test: 1, to: -1 }); // For sorting reports by date
|
|
99
|
+
// OldReportSchema.index({ client: 1, test: 1 }); // For client-specific test reports
|
|
100
|
+
// OldReportSchema.index({ from: 1, to: 1 }); // For date range queries
|
|
101
|
+
// OldReportSchema.index({ client: 1, "reportDetails.implementedStatus": 1 }); // For implemented status queries
|
|
102
|
+
// ReportsSchema.index({ client: 1, "reportDetails.conclusionFactorStatusAll": 1 }); // For conclusion factor queries
|
|
103
|
+
// ReportsSchema.index({ client: 1, gaTestId: 1 }); // For GA test ID lookups
|
|
104
|
+
// ReportsSchema.index({ createdBy: 1, to: -1 }); // For user's reports
|
|
105
|
+
// ReportsSchema.index({ client: 1, excludedFromCalculations: 1 }); // For calculation exclusions
|
|
106
|
+
const OldReport = mongoose_1.default.models.oldreport || (0, mongoose_1.model)("oldreport", OldReportSchema);
|
|
107
|
+
exports.default = OldReport;
|
|
@@ -25,16 +25,7 @@
|
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export declare enum ProviderType {
|
|
27
27
|
SHOPIFY = "shopify",
|
|
28
|
-
BIGQUERY = "bigquery"
|
|
29
|
-
GOOGLE_ANALYTICS = "google_analytics",
|
|
30
|
-
GOOGLE_TAG_MANAGER = "google_tag_manager",
|
|
31
|
-
GOOGLE_ADS = "google_ads",
|
|
32
|
-
GOOGLE_SEARCH_CONSOLE = "google_search_console",
|
|
33
|
-
GOOGLE_SHEETS = "google_sheets",
|
|
34
|
-
GOOGLE_DOCS = "google_docs",
|
|
35
|
-
GOOGLE_DRIVE = "google_drive",
|
|
36
|
-
GOOGLE_MAIL = "google_mail",
|
|
37
|
-
GOOGLE_CALENDAR = "google_calendar"
|
|
28
|
+
BIGQUERY = "bigquery"
|
|
38
29
|
}
|
|
39
30
|
export interface IShopifyMetadata {
|
|
40
31
|
apiKey: string;
|
|
@@ -31,15 +31,15 @@ var ProviderType;
|
|
|
31
31
|
(function (ProviderType) {
|
|
32
32
|
ProviderType["SHOPIFY"] = "shopify";
|
|
33
33
|
ProviderType["BIGQUERY"] = "bigquery";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
// GOOGLE_ANALYTICS = "google_analytics",
|
|
35
|
+
// GOOGLE_TAG_MANAGER = "google_tag_manager",
|
|
36
|
+
// GOOGLE_ADS = "google_ads",
|
|
37
|
+
// GOOGLE_SEARCH_CONSOLE = "google_search_console",
|
|
38
|
+
// GOOGLE_SHEETS = "google_sheets",
|
|
39
|
+
// GOOGLE_DOCS = "google_docs",
|
|
40
|
+
// GOOGLE_DRIVE = "google_drive",
|
|
41
|
+
// GOOGLE_MAIL = "google_mail",
|
|
42
|
+
// GOOGLE_CALENDAR = "google_calendar",
|
|
43
43
|
// Add more provider types as needed
|
|
44
44
|
})(ProviderType || (exports.ProviderType = ProviderType = {}));
|
|
45
45
|
const ProviderSchema = new mongoose_1.Schema({
|
package/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ import ThreadMessage from "./src/models/ThreadMessage";
|
|
|
58
58
|
import Provider from "./src/models/Provider";
|
|
59
59
|
import ApiLog from "./src/models/ApiLog";
|
|
60
60
|
import { ProviderType } from "./src/models/Provider";
|
|
61
|
+
import OldReport from "./src/models/OldReport";
|
|
61
62
|
async function seedRoles() {
|
|
62
63
|
const checkRoles = await Role.countDocuments();
|
|
63
64
|
if (checkRoles < RolesConstants.length) {
|
|
@@ -165,4 +166,5 @@ export {
|
|
|
165
166
|
ThreadMessage,
|
|
166
167
|
ApiLog,
|
|
167
168
|
ProviderType,
|
|
169
|
+
OldReport,
|
|
168
170
|
};
|
package/package.json
CHANGED
package/src/models/Client.ts
CHANGED
|
@@ -9,7 +9,6 @@ export interface IProperty extends Document {
|
|
|
9
9
|
viewId: string;
|
|
10
10
|
platform?: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
const PropertySchema: Schema = new Schema<IProperty>({
|
|
14
13
|
propertyname: { type: String, required: true },
|
|
15
14
|
viewId: { type: String, required: true },
|
|
@@ -19,7 +18,7 @@ export interface IClient extends Document {
|
|
|
19
18
|
iid: string;
|
|
20
19
|
organization: mongoose.Schema.Types.ObjectId;
|
|
21
20
|
name: string;
|
|
22
|
-
|
|
21
|
+
url: string;
|
|
23
22
|
viewId?: string;
|
|
24
23
|
portfolioClient?: boolean;
|
|
25
24
|
gaproperties?: IProperty[];
|
|
@@ -34,6 +33,8 @@ export interface IClient extends Document {
|
|
|
34
33
|
NDAStatus?: boolean;
|
|
35
34
|
retainerValue: number;
|
|
36
35
|
useIntraDayTable: boolean;
|
|
36
|
+
slug?: string;
|
|
37
|
+
onboardingCompleted: boolean;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
const ClientSchema: Schema = new Schema<IClient>(
|
|
@@ -44,6 +45,7 @@ const ClientSchema: Schema = new Schema<IClient>(
|
|
|
44
45
|
unique: true,
|
|
45
46
|
default: () => generateRandomIID(),
|
|
46
47
|
},
|
|
48
|
+
url: { type: String, required: true },
|
|
47
49
|
organization: {
|
|
48
50
|
type: mongoose.Schema.Types.ObjectId,
|
|
49
51
|
ref: "organization",
|
|
@@ -79,6 +81,7 @@ const ClientSchema: Schema = new Schema<IClient>(
|
|
|
79
81
|
NDAStatus: { type: Boolean, default: false },
|
|
80
82
|
retainerValue: { type: Number },
|
|
81
83
|
useIntraDayTable: { type: Boolean },
|
|
84
|
+
onboardingCompleted: { type: Boolean, default: false },
|
|
82
85
|
},
|
|
83
86
|
{
|
|
84
87
|
timestamps: true,
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import { generateRandomIID } from "../constant";
|
|
3
|
+
|
|
4
|
+
export interface IOldReport extends Document {
|
|
5
|
+
iid: string;
|
|
6
|
+
name: string;
|
|
7
|
+
segmentName?: string;
|
|
8
|
+
reportLink?: string;
|
|
9
|
+
conclusion?: string;
|
|
10
|
+
variant?: string;
|
|
11
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
12
|
+
viewId?: string;
|
|
13
|
+
test?: mongoose.Schema.Types.ObjectId;
|
|
14
|
+
gaTestId?: string;
|
|
15
|
+
reportDetails?: mongoose.Schema.Types.Mixed;
|
|
16
|
+
learnings?: mongoose.Schema.Types.Mixed;
|
|
17
|
+
from?: Date;
|
|
18
|
+
to?: Date;
|
|
19
|
+
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
20
|
+
excludedFromCalculations?: boolean;
|
|
21
|
+
createdAt?: Date;
|
|
22
|
+
updatedAt?: Date;
|
|
23
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const OldReportSchema = new Schema<IOldReport>(
|
|
27
|
+
{
|
|
28
|
+
iid: {
|
|
29
|
+
type: String,
|
|
30
|
+
trim: true,
|
|
31
|
+
},
|
|
32
|
+
organizationId: {
|
|
33
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
34
|
+
ref: "organization",
|
|
35
|
+
default: null,
|
|
36
|
+
},
|
|
37
|
+
name: { type: String, required: true },
|
|
38
|
+
segmentName: { type: String },
|
|
39
|
+
reportLink: { type: String },
|
|
40
|
+
conclusion: { type: String },
|
|
41
|
+
variant: { type: String },
|
|
42
|
+
client: {
|
|
43
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
44
|
+
ref: "client"
|
|
45
|
+
},
|
|
46
|
+
viewId: { type: String },
|
|
47
|
+
test: {
|
|
48
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
49
|
+
ref: "test"
|
|
50
|
+
},
|
|
51
|
+
gaTestId: { type: String },
|
|
52
|
+
reportDetails: { type: mongoose.Schema.Types.Mixed },
|
|
53
|
+
learnings: {
|
|
54
|
+
type: mongoose.Schema.Types.Mixed,
|
|
55
|
+
default: []
|
|
56
|
+
},
|
|
57
|
+
from: { type: Date },
|
|
58
|
+
to: { type: Date },
|
|
59
|
+
createdBy: {
|
|
60
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
61
|
+
ref: "user"
|
|
62
|
+
},
|
|
63
|
+
excludedFromCalculations: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
timestamps: true
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
OldReportSchema.pre('save', async function(next) {
|
|
74
|
+
if (!this.iid) {
|
|
75
|
+
let unique = false;
|
|
76
|
+
while (!unique) {
|
|
77
|
+
const id = generateRandomIID();
|
|
78
|
+
const existing = await mongoose.models.report.findOne({ iid: id });
|
|
79
|
+
if (!existing) {
|
|
80
|
+
this.iid = id;
|
|
81
|
+
unique = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
next();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// Add compound indexes for better query performance
|
|
90
|
+
OldReportSchema.index({ client: 1, conclusion: 1 });
|
|
91
|
+
// ReportsSchema.index({ test: 1, to: -1 }); // For sorting reports by date
|
|
92
|
+
// OldReportSchema.index({ client: 1, test: 1 }); // For client-specific test reports
|
|
93
|
+
// OldReportSchema.index({ from: 1, to: 1 }); // For date range queries
|
|
94
|
+
// OldReportSchema.index({ client: 1, "reportDetails.implementedStatus": 1 }); // For implemented status queries
|
|
95
|
+
// ReportsSchema.index({ client: 1, "reportDetails.conclusionFactorStatusAll": 1 }); // For conclusion factor queries
|
|
96
|
+
// ReportsSchema.index({ client: 1, gaTestId: 1 }); // For GA test ID lookups
|
|
97
|
+
// ReportsSchema.index({ createdBy: 1, to: -1 }); // For user's reports
|
|
98
|
+
// ReportsSchema.index({ client: 1, excludedFromCalculations: 1 }); // For calculation exclusions
|
|
99
|
+
|
|
100
|
+
const OldReport = mongoose.models.oldreport || model<IOldReport>("oldreport", OldReportSchema);
|
|
101
|
+
|
|
102
|
+
export default OldReport;
|
package/src/models/Provider.ts
CHANGED
|
@@ -5,15 +5,15 @@ import { generateRandomIID } from "../constant";
|
|
|
5
5
|
export enum ProviderType {
|
|
6
6
|
SHOPIFY = "shopify",
|
|
7
7
|
BIGQUERY = "bigquery",
|
|
8
|
-
GOOGLE_ANALYTICS = "google_analytics",
|
|
9
|
-
GOOGLE_TAG_MANAGER = "google_tag_manager",
|
|
10
|
-
GOOGLE_ADS = "google_ads",
|
|
11
|
-
GOOGLE_SEARCH_CONSOLE = "google_search_console",
|
|
12
|
-
GOOGLE_SHEETS = "google_sheets",
|
|
13
|
-
GOOGLE_DOCS = "google_docs",
|
|
14
|
-
GOOGLE_DRIVE = "google_drive",
|
|
15
|
-
GOOGLE_MAIL = "google_mail",
|
|
16
|
-
GOOGLE_CALENDAR = "google_calendar",
|
|
8
|
+
// GOOGLE_ANALYTICS = "google_analytics",
|
|
9
|
+
// GOOGLE_TAG_MANAGER = "google_tag_manager",
|
|
10
|
+
// GOOGLE_ADS = "google_ads",
|
|
11
|
+
// GOOGLE_SEARCH_CONSOLE = "google_search_console",
|
|
12
|
+
// GOOGLE_SHEETS = "google_sheets",
|
|
13
|
+
// GOOGLE_DOCS = "google_docs",
|
|
14
|
+
// GOOGLE_DRIVE = "google_drive",
|
|
15
|
+
// GOOGLE_MAIL = "google_mail",
|
|
16
|
+
// GOOGLE_CALENDAR = "google_calendar",
|
|
17
17
|
// Add more provider types as needed
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -84,7 +84,7 @@ const ProviderSchema = new Schema<IProvider>(
|
|
|
84
84
|
ref: "client",
|
|
85
85
|
required: true,
|
|
86
86
|
},
|
|
87
|
-
user: {
|
|
87
|
+
user: {
|
|
88
88
|
type: mongoose.Schema.Types.ObjectId,
|
|
89
89
|
ref: "user",
|
|
90
90
|
required: true,
|