@antelopejs/dms-database 0.0.9 → 0.0.10
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.
|
@@ -7,24 +7,20 @@ const query_history_table_1 = require("../tables/query_history.table");
|
|
|
7
7
|
class QueryHistoryModel extends (0, interface_database_decorators_1.BasicDataModel)(query_history_table_1.QueryHistoryRow, query_history_table_1.queryHistoryTableName) {
|
|
8
8
|
async addAndPrune(entry) {
|
|
9
9
|
await this.insert(entry);
|
|
10
|
-
const
|
|
10
|
+
const overflow = await this.table
|
|
11
11
|
.filter((d) => d.key("userId").eq(entry.userId))
|
|
12
12
|
.orderBy("executedAt", "desc")
|
|
13
|
+
.slice(constants_1.MAX_HISTORY_PER_USER)
|
|
13
14
|
.run();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
await this.delete(row._id);
|
|
17
|
-
}
|
|
15
|
+
for (const row of overflow) {
|
|
16
|
+
await this.delete(row._id);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
async listForUser(userId, limit, offset) {
|
|
21
20
|
const baseFilter = this.table.filter((d) => d.key("userId").eq(userId));
|
|
22
21
|
const [total, items] = await Promise.all([
|
|
23
22
|
baseFilter.count().run(),
|
|
24
|
-
baseFilter
|
|
25
|
-
.orderBy("executedAt", "desc")
|
|
26
|
-
.slice(offset, offset + limit)
|
|
27
|
-
.run(),
|
|
23
|
+
baseFilter.orderBy("executedAt", "desc").slice(offset, limit).run(),
|
|
28
24
|
]);
|
|
29
25
|
return { items, total };
|
|
30
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query_history.model.js","sourceRoot":"","sources":["../../../src/db/models/query_history.model.ts"],"names":[],"mappings":";;;AAAA,6FAA2E;AAC3E,qDAA6D;AAE7D,uEAGuC;AAEvC,MAAa,iBAAkB,SAAQ,IAAA,8CAAc,EACnD,qCAAe,EACf,2CAAqB,CACtB;IACC,KAAK,CAAC,WAAW,CAAC,KAA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,KAAK,CAAC,CAAC,GAAG,EAAE;SACpE,CAAC,CAAC;QAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF;AAhCD,8CAgCC"}
|
|
@@ -18,13 +18,13 @@ let QueryHistoryRow = class QueryHistoryRow extends interface_database_decorator
|
|
|
18
18
|
};
|
|
19
19
|
exports.QueryHistoryRow = QueryHistoryRow;
|
|
20
20
|
__decorate([
|
|
21
|
-
(0, interface_database_decorators_1.Index)(),
|
|
21
|
+
(0, interface_database_decorators_1.Index)({ group: "userId_executedAt" }),
|
|
22
22
|
(0, interface_database_decorators_1.Field)("string"),
|
|
23
23
|
(0, interface_database_decorators_1.Relation)({ to: () => db_1.User }),
|
|
24
24
|
__metadata("design:type", String)
|
|
25
25
|
], QueryHistoryRow.prototype, "userId", void 0);
|
|
26
26
|
__decorate([
|
|
27
|
-
(0, interface_database_decorators_1.Index)(),
|
|
27
|
+
(0, interface_database_decorators_1.Index)({ group: "userId_executedAt" }),
|
|
28
28
|
(0, interface_database_decorators_1.Field)("date"),
|
|
29
29
|
__metadata("design:type", Date)
|
|
30
30
|
], QueryHistoryRow.prototype, "executedAt", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query_history.table.js","sourceRoot":"","sources":["../../../src/db/tables/query_history.table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6FAMmD;AACnD,0DAAyD;AACzD,qDAAoD;AAEvC,QAAA,qBAAqB,GAAG,eAAe,CAAC;AAG9C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,qCAAK;CAwBzC,CAAA;AAxBY,0CAAe;AAIlB;IAHP,IAAA,qCAAK,
|
|
1
|
+
{"version":3,"file":"query_history.table.js","sourceRoot":"","sources":["../../../src/db/tables/query_history.table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6FAMmD;AACnD,0DAAyD;AACzD,qDAAoD;AAEvC,QAAA,qBAAqB,GAAG,eAAe,CAAC;AAG9C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,qCAAK;CAwBzC,CAAA;AAxBY,0CAAe;AAIlB;IAHP,IAAA,qCAAK,EAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;IACrC,IAAA,qCAAK,EAAC,QAAQ,CAAC;IACf,IAAA,wCAAQ,EAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,SAAI,EAAE,CAAC;;+CACN;AAIf;IAFP,IAAA,qCAAK,EAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;IACrC,IAAA,qCAAK,EAAC,MAAM,CAAC;8BACM,IAAI;mDAAC;AAGjB;IADP,IAAA,qCAAK,EAAC,KAAK,CAAC;;8CAC0B;AAG/B;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;+CACO;AAGf;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;iDACQ;AAGhB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;mDACW;AAGnB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;iDACS;0BAvBd,eAAe;IAD3B,IAAA,6CAAa,EAAC,6BAAqB,EAAE,uBAAW,CAAC;GACrC,eAAe,CAwB3B"}
|