Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qnaplus",
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"private": true,
"author": "battlesqui_d",
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/src/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export const mergeByKey = <
B extends Record<K, PropertyKey>,
>(
key: K,
a: A[],
b: B[],
current: A[],
updated: B[],
): (A | B | (A & B))[] => {
const map = new Map<PropertyKey, A | B | (A & B)>();
for (const item of a) {
for (const item of current) {
map.set(item[key], item);
}
for (const item of b) {
for (const item of updated) {
const existing = map.get(item[key]);
map.set(item[key], existing ? { ...existing, ...item } : item);
}
Expand Down
4 changes: 2 additions & 2 deletions services/updater/src/update_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const updateStorage = async (
if (seasonQuestions === null) {
return;
}
const updatedSeasonQuestions = mergeByKey("id", updates, seasonQuestions).toSorted(
const updatedSeasonQuestions = mergeByKey("id", seasonQuestions, updates).toSorted(
(a, b) => Number.parseInt(b.id) - Number.parseInt(a.id),
);
await update(logger, updatedSeasonQuestions, SEASON_QUESTIONS_KEY);
Expand All @@ -52,7 +52,7 @@ export const updateStorage = async (
if (questions === null) {
return;
}
const updatedQuestions = mergeByKey("id", updatedSeasonQuestions, questions).toSorted(
const updatedQuestions = mergeByKey("id", questions, updatedSeasonQuestions).toSorted(
(a, b) => Number.parseInt(b.id) - Number.parseInt(a.id),
);
await update(logger, updatedQuestions, ALL_QUESTIONS_KEY);
Expand Down
Loading