@shaxpir/duiduidui-models 1.4.24 → 1.4.26
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/models/Metric.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { CompactDate } from "@shaxpir/shaxpir-common";
|
|
|
3
3
|
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
5
5
|
export declare enum MetricName {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
REVIEW_COUNT = "review_count",
|
|
7
|
+
MINUTES_STUDYING = "minutes_studying"
|
|
8
8
|
}
|
|
9
9
|
export interface MetricEntry {
|
|
10
10
|
date: CompactDate;
|
package/dist/models/Metric.js
CHANGED
|
@@ -14,8 +14,8 @@ const Operation_1 = require("./Operation");
|
|
|
14
14
|
dayjs_1.default.extend(utc_1.default);
|
|
15
15
|
var MetricName;
|
|
16
16
|
(function (MetricName) {
|
|
17
|
-
MetricName["
|
|
18
|
-
MetricName["
|
|
17
|
+
MetricName["REVIEW_COUNT"] = "review_count";
|
|
18
|
+
MetricName["MINUTES_STUDYING"] = "minutes_studying";
|
|
19
19
|
})(MetricName || (exports.MetricName = MetricName = {}));
|
|
20
20
|
class Metric extends Content_1.Content {
|
|
21
21
|
static makeMetricId(userId, metricName) {
|
package/dist/models/Session.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { MultiTime } from "@shaxpir/shaxpir-common";
|
|
|
3
3
|
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentBody, ContentId, ContentMeta, ContentRef } from "./Content";
|
|
5
5
|
import { Review } from './Review';
|
|
6
|
+
import { ArrayView } from './ArrayView';
|
|
6
7
|
export interface SessionPayload {
|
|
7
8
|
start: MultiTime;
|
|
8
9
|
end: MultiTime;
|
|
@@ -28,6 +29,7 @@ export declare class Session extends Content {
|
|
|
28
29
|
get tzOffset(): number;
|
|
29
30
|
get durationMinutes(): number;
|
|
30
31
|
get deviceId(): ContentId;
|
|
32
|
+
get reviews(): ArrayView<Review>;
|
|
31
33
|
modelUpdated(): Promise<void>;
|
|
32
34
|
addReview(review: Review): void;
|
|
33
35
|
}
|
package/dist/models/Session.js
CHANGED
|
@@ -79,6 +79,10 @@ class Session extends Content_1.Content {
|
|
|
79
79
|
this.checkDisposed("Session.deviceId");
|
|
80
80
|
return this.payload.device_id;
|
|
81
81
|
}
|
|
82
|
+
get reviews() {
|
|
83
|
+
this.checkDisposed("Session.reviews");
|
|
84
|
+
return this._reviewsView;
|
|
85
|
+
}
|
|
82
86
|
async modelUpdated() {
|
|
83
87
|
this.checkDisposed("Session.modelUpdated");
|
|
84
88
|
await super.modelUpdated();
|
|
@@ -90,16 +94,24 @@ class Session extends Content_1.Content {
|
|
|
90
94
|
const workspace = await this.shareSync.acquire(ContentKind_1.ContentKind.WORKSPACE, workspaceId);
|
|
91
95
|
const sessionsOnDate = await workspace.acquireSessionsFromDate(sessionId, date);
|
|
92
96
|
workspace.release();
|
|
93
|
-
let
|
|
97
|
+
let minutesStudyingOnDate = 0;
|
|
98
|
+
let reviewCountOnDate = 0;
|
|
94
99
|
for (let i = 0, len = sessionsOnDate.length; i < len; i++) {
|
|
95
100
|
const sessionOnDate = sessionsOnDate[i];
|
|
96
|
-
|
|
101
|
+
minutesStudyingOnDate += sessionOnDate.durationMinutes;
|
|
102
|
+
reviewCountOnDate += sessionOnDate.reviews.length;
|
|
97
103
|
sessionOnDate.release();
|
|
98
104
|
}
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
// Update minutes studying metric
|
|
106
|
+
const minutesStudyingMetricId = Metric_1.Metric.makeMetricId(userId, Metric_1.MetricName.MINUTES_STUDYING);
|
|
107
|
+
const minutesStudyingMetric = await shareSync.acquire(ContentKind_1.ContentKind.METRIC, minutesStudyingMetricId);
|
|
108
|
+
minutesStudyingMetric.setDateAmount(date, minutesStudyingOnDate);
|
|
109
|
+
minutesStudyingMetric.release();
|
|
110
|
+
// Update review count metric
|
|
111
|
+
const reviewCountMetricId = Metric_1.Metric.makeMetricId(userId, Metric_1.MetricName.REVIEW_COUNT);
|
|
112
|
+
const reviewCountMetric = await shareSync.acquire(ContentKind_1.ContentKind.METRIC, reviewCountMetricId);
|
|
113
|
+
reviewCountMetric.setDateAmount(date, reviewCountOnDate);
|
|
114
|
+
reviewCountMetric.release();
|
|
103
115
|
}
|
|
104
116
|
addReview(review) {
|
|
105
117
|
this.checkDisposed("Session.addReview");
|
package/dist/models/Workspace.js
CHANGED
|
@@ -57,7 +57,7 @@ class Workspace extends Content_1.Content {
|
|
|
57
57
|
const sessionCreatedAt = this.sessions.get(i);
|
|
58
58
|
const sessionCreatedLocalDate = shaxpir_common_1.Time.dateFrom(sessionCreatedAt.local_time);
|
|
59
59
|
if (localDate == sessionCreatedLocalDate) {
|
|
60
|
-
const sessionRef = Session_1.Session.makeSessionRef(
|
|
60
|
+
const sessionRef = Session_1.Session.makeSessionRef(this.owner, sessionCreatedAt);
|
|
61
61
|
const session = await shareSync.acquire(ContentKind_1.ContentKind.SESSION, sessionRef);
|
|
62
62
|
sessions.push(session);
|
|
63
63
|
}
|