feeds-fun 1.13.2 → 1.14.0
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/package.json +1 -1
- package/src/logic/api.ts +2 -2
- package/src/logic/types.ts +35 -36
package/package.json
CHANGED
package/src/logic/api.ts
CHANGED
|
@@ -76,7 +76,7 @@ export async function getLastEntries({period}: {period: number}) {
|
|
|
76
76
|
const entries = [];
|
|
77
77
|
|
|
78
78
|
for (let rawEntry of response.entries) {
|
|
79
|
-
const entry = t.entryFromJSON(rawEntry);
|
|
79
|
+
const entry = t.entryFromJSON(rawEntry, response.tagsMapping);
|
|
80
80
|
entries.push(entry);
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -92,7 +92,7 @@ export async function getEntriesByIds({ids}: {ids: t.EntryId[]}) {
|
|
|
92
92
|
const entries = [];
|
|
93
93
|
|
|
94
94
|
for (let rawEntry of response.entries) {
|
|
95
|
-
const entry = t.entryFromJSON(rawEntry);
|
|
95
|
+
const entry = t.entryFromJSON(rawEntry, response.tagsMapping);
|
|
96
96
|
entries.push(entry);
|
|
97
97
|
}
|
|
98
98
|
|
package/src/logic/types.ts
CHANGED
|
@@ -184,49 +184,48 @@ export class Entry {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
export function entryFromJSON(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
catalogedAt: string;
|
|
210
|
-
body: string | null;
|
|
211
|
-
}): Entry {
|
|
187
|
+
export function entryFromJSON(
|
|
188
|
+
rawEntry: {
|
|
189
|
+
id: string;
|
|
190
|
+
feedId: string;
|
|
191
|
+
title: string;
|
|
192
|
+
url: string;
|
|
193
|
+
tags: number[];
|
|
194
|
+
markers: string[];
|
|
195
|
+
score: number;
|
|
196
|
+
scoreContributions: {[key: number]: number};
|
|
197
|
+
publishedAt: string;
|
|
198
|
+
catalogedAt: string;
|
|
199
|
+
body: string | null;
|
|
200
|
+
},
|
|
201
|
+
tagsMapping: {[key: number]: string}
|
|
202
|
+
): Entry {
|
|
203
|
+
const contributions: {[key: string]: number} = {};
|
|
204
|
+
|
|
205
|
+
for (const key in rawEntry.scoreContributions) {
|
|
206
|
+
contributions[tagsMapping[key]] = rawEntry.scoreContributions[key];
|
|
207
|
+
}
|
|
208
|
+
|
|
212
209
|
return new Entry({
|
|
213
|
-
id: toEntryId(id),
|
|
214
|
-
feedId: toFeedId(feedId),
|
|
215
|
-
title,
|
|
216
|
-
url: toURL(url),
|
|
217
|
-
tags: tags,
|
|
218
|
-
markers: markers.map((m: string) => {
|
|
210
|
+
id: toEntryId(rawEntry.id),
|
|
211
|
+
feedId: toFeedId(rawEntry.feedId),
|
|
212
|
+
title: rawEntry.title,
|
|
213
|
+
url: toURL(rawEntry.url),
|
|
214
|
+
tags: rawEntry.tags.map((t: number) => tagsMapping[t]),
|
|
215
|
+
markers: rawEntry.markers.map((m: string) => {
|
|
219
216
|
if (m in e.reverseMarker) {
|
|
220
217
|
return e.reverseMarker[m];
|
|
221
218
|
}
|
|
222
219
|
|
|
223
220
|
throw new Error(`Unknown marker: ${m}`);
|
|
224
221
|
}),
|
|
225
|
-
score: score,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
222
|
+
score: rawEntry.score,
|
|
223
|
+
// map keys from int to string
|
|
224
|
+
scoreContributions: contributions,
|
|
225
|
+
publishedAt: new Date(rawEntry.publishedAt),
|
|
226
|
+
catalogedAt: new Date(rawEntry.catalogedAt),
|
|
227
|
+
|
|
228
|
+
body: rawEntry.body
|
|
230
229
|
});
|
|
231
230
|
}
|
|
232
231
|
|