@shaxpir/duiduidui-models 1.5.11 → 1.5.13
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/Phrase.d.ts +1 -0
- package/dist/models/Term.d.ts +8 -8
- package/dist/models/Term.js +36 -22
- package/package.json +1 -1
package/dist/models/Phrase.d.ts
CHANGED
package/dist/models/Term.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface TermSummary {
|
|
|
18
18
|
review_count: number;
|
|
19
19
|
implied_review_count: number;
|
|
20
20
|
last_review_utc: CompactDateTime;
|
|
21
|
-
|
|
21
|
+
user_tag_count: number;
|
|
22
22
|
}
|
|
23
23
|
export interface TermPayload extends BayesianScore {
|
|
24
24
|
text: string;
|
|
@@ -30,8 +30,8 @@ export interface TermPayload extends BayesianScore {
|
|
|
30
30
|
beta: number;
|
|
31
31
|
theta: number;
|
|
32
32
|
uncertainty: number;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
user_tags: string[];
|
|
34
|
+
user_tag_count: number;
|
|
35
35
|
reviews: ReviewLike[];
|
|
36
36
|
review_count: number;
|
|
37
37
|
last_review_utc: CompactDateTime;
|
|
@@ -55,7 +55,7 @@ export declare class Term extends Content {
|
|
|
55
55
|
static makeTermId(userId: ContentId, text: string, senseRank: number): ContentId;
|
|
56
56
|
private _reviewsView;
|
|
57
57
|
private _impliedReviewsView;
|
|
58
|
-
private
|
|
58
|
+
private _userTagsView;
|
|
59
59
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
60
60
|
static forUserPhrase(userId: ContentId, text: string, senseRank: number, difficulty: number, phraseId?: number): Term;
|
|
61
61
|
static forUserPhrase(userId: ContentId, phrase: Phrase): Term;
|
|
@@ -69,11 +69,11 @@ export declare class Term extends Content {
|
|
|
69
69
|
get theta(): number;
|
|
70
70
|
get uncertainty(): number;
|
|
71
71
|
get starredAt(): CompactDateTime | null;
|
|
72
|
-
get
|
|
73
|
-
get
|
|
72
|
+
get userTags(): string[];
|
|
73
|
+
get userTagCount(): number;
|
|
74
74
|
private _updateTagCount;
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
addUserTag(value: string): void;
|
|
76
|
+
removeUserTag(value: string): void;
|
|
77
77
|
get lastReviewUtc(): CompactDateTime | null;
|
|
78
78
|
setStarredAt(value: CompactDateTime | null): void;
|
|
79
79
|
updateBayesianScore(alpha: number, beta: number, theta: number): void;
|
package/dist/models/Term.js
CHANGED
|
@@ -16,7 +16,7 @@ class Term extends Content_1.Content {
|
|
|
16
16
|
super(doc, shouldAcquire, shareSync);
|
|
17
17
|
this._reviewsView = new ArrayView_1.ArrayView(this, ['payload', 'reviews']);
|
|
18
18
|
this._impliedReviewsView = new ArrayView_1.ArrayView(this, ['payload', 'implied_reviews']);
|
|
19
|
-
this.
|
|
19
|
+
this._userTagsView = new ArrayView_1.ArrayView(this, ['payload', 'user_tags']);
|
|
20
20
|
}
|
|
21
21
|
static forUserPhrase(userId, textOrPhrase, senseRank, difficulty, phraseId) {
|
|
22
22
|
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
@@ -65,8 +65,8 @@ class Term extends Content_1.Content {
|
|
|
65
65
|
notes: phrase.notes,
|
|
66
66
|
examples: phrase.examples,
|
|
67
67
|
keywords: phrase.keywords,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
user_tags: phrase.tags || [],
|
|
69
|
+
user_tag_count: (phrase.tags || []).length,
|
|
70
70
|
starred_at: null,
|
|
71
71
|
alpha: 0.5,
|
|
72
72
|
beta: 0.5,
|
|
@@ -98,8 +98,8 @@ class Term extends Content_1.Content {
|
|
|
98
98
|
difficulty: phrase.difficulty,
|
|
99
99
|
phrase_id: phrase.id,
|
|
100
100
|
starred_at: null,
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
user_tags: [],
|
|
102
|
+
user_tag_count: 0,
|
|
103
103
|
alpha: 0.5,
|
|
104
104
|
beta: 0.5,
|
|
105
105
|
theta: 0.5,
|
|
@@ -148,36 +148,50 @@ class Term extends Content_1.Content {
|
|
|
148
148
|
this.checkDisposed("Term.starredAt");
|
|
149
149
|
return this.payload.starred_at;
|
|
150
150
|
}
|
|
151
|
-
get
|
|
152
|
-
this.checkDisposed("Term.
|
|
153
|
-
return this.
|
|
151
|
+
get userTags() {
|
|
152
|
+
this.checkDisposed("Term.userTags");
|
|
153
|
+
return this._userTagsView.values;
|
|
154
154
|
}
|
|
155
|
-
get
|
|
156
|
-
this.checkDisposed("Term.
|
|
157
|
-
return this.payload.
|
|
155
|
+
get userTagCount() {
|
|
156
|
+
this.checkDisposed("Term.userTagCount");
|
|
157
|
+
return this.payload.user_tag_count;
|
|
158
158
|
}
|
|
159
159
|
_updateTagCount() {
|
|
160
|
-
const newCount = this.
|
|
161
|
-
if (this.payload.
|
|
160
|
+
const newCount = this._userTagsView.length;
|
|
161
|
+
if (this.payload.user_tag_count !== newCount) {
|
|
162
162
|
const batch = new Operation_1.BatchOperation(this);
|
|
163
|
-
batch.setPathValue(['payload', '
|
|
163
|
+
batch.setPathValue(['payload', 'user_tag_count'], newCount);
|
|
164
164
|
batch.commit();
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
|
|
168
|
-
this.checkDisposed("Term.
|
|
169
|
-
|
|
167
|
+
addUserTag(value) {
|
|
168
|
+
this.checkDisposed("Term.addUserTag");
|
|
169
|
+
console.log('[Term.addUserTag] Adding tag:', value);
|
|
170
|
+
console.log('[Term.addUserTag] Current tags:', this._userTagsView.values);
|
|
171
|
+
const index = this._userTagsView.indexOf(value);
|
|
170
172
|
if (index === -1) {
|
|
171
|
-
this.
|
|
173
|
+
this._userTagsView.push(value);
|
|
172
174
|
this._updateTagCount();
|
|
175
|
+
console.log('[Term.addUserTag] Tag added, new tags:', this._userTagsView.values);
|
|
176
|
+
console.log('[Term.addUserTag] Document data after add:', JSON.stringify(this.doc.data.payload.user_tags));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
console.log('[Term.addUserTag] Tag already exists, skipping');
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
|
-
|
|
176
|
-
this.checkDisposed("Term.
|
|
177
|
-
|
|
182
|
+
removeUserTag(value) {
|
|
183
|
+
this.checkDisposed("Term.removeUserTag");
|
|
184
|
+
console.log('[Term.removeUserTag] Removing tag:', value);
|
|
185
|
+
console.log('[Term.removeUserTag] Current tags:', this._userTagsView.values);
|
|
186
|
+
const index = this._userTagsView.indexOf(value);
|
|
178
187
|
if (index !== -1) {
|
|
179
|
-
this.
|
|
188
|
+
this._userTagsView.removeAt(index);
|
|
180
189
|
this._updateTagCount();
|
|
190
|
+
console.log('[Term.removeUserTag] Tag removed, new tags:', this._userTagsView.values);
|
|
191
|
+
console.log('[Term.removeUserTag] Document data after remove:', JSON.stringify(this.doc.data.payload.user_tags));
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
console.log('[Term.removeUserTag] Tag not found, skipping');
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
197
|
get lastReviewUtc() {
|