Revert "perf: construct scyllaNote instead of querying"
This reverts commit eac2ff4a47
.
This commit is contained in:
parent
36455aa7dd
commit
7442ef873a
1 changed files with 14 additions and 20 deletions
|
@ -75,10 +75,10 @@ import { redisClient } from "@/db/redis.js";
|
||||||
import { Mutex } from "redis-semaphore";
|
import { Mutex } from "redis-semaphore";
|
||||||
import {
|
import {
|
||||||
parseHomeTimeline,
|
parseHomeTimeline,
|
||||||
|
parseScyllaNote,
|
||||||
prepared,
|
prepared,
|
||||||
scyllaClient,
|
scyllaClient,
|
||||||
type ScyllaNote,
|
ScyllaPoll,
|
||||||
type ScyllaPoll,
|
|
||||||
} from "@/db/scylla.js";
|
} from "@/db/scylla.js";
|
||||||
import { userByIdCache, userDenormalizedCache } from "../user-cache.js";
|
import { userByIdCache, userDenormalizedCache } from "../user-cache.js";
|
||||||
import { langmap } from "@/misc/langmap.js";
|
import { langmap } from "@/misc/langmap.js";
|
||||||
|
@ -843,7 +843,6 @@ async function insertNote(
|
||||||
width: file.properties.width ?? null,
|
width: file.properties.width ?? null,
|
||||||
height: file.properties.height ?? null,
|
height: file.properties.height ?? null,
|
||||||
});
|
});
|
||||||
const files = data.files?.map(fileMapper);
|
|
||||||
const replyText = data.reply?.text ?? null;
|
const replyText = data.reply?.text ?? null;
|
||||||
const replyCw = data.reply?.cw ?? null;
|
const replyCw = data.reply?.cw ?? null;
|
||||||
// TODO: move drive files to scylla or cache in redis/dragonfly
|
// TODO: move drive files to scylla or cache in redis/dragonfly
|
||||||
|
@ -906,7 +905,7 @@ async function insertNote(
|
||||||
insert.uri,
|
insert.uri,
|
||||||
insert.url,
|
insert.url,
|
||||||
insert.score ?? 0,
|
insert.score ?? 0,
|
||||||
files,
|
data.files?.map(fileMapper),
|
||||||
insert.visibleUserIds,
|
insert.visibleUserIds,
|
||||||
insert.mentions,
|
insert.mentions,
|
||||||
insert.mentionedRemoteUsers,
|
insert.mentionedRemoteUsers,
|
||||||
|
@ -958,22 +957,6 @@ async function insertNote(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const scyllaNote: ScyllaNote = {
|
|
||||||
...insert,
|
|
||||||
createdAtDate: insert.createdAt,
|
|
||||||
files: files ?? [],
|
|
||||||
poll,
|
|
||||||
replyText,
|
|
||||||
replyCw,
|
|
||||||
replyFiles: replyFiles ?? [],
|
|
||||||
renoteText,
|
|
||||||
renoteCw,
|
|
||||||
renoteFiles: renoteFiles ?? [],
|
|
||||||
noteEdit: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
return scyllaNote;
|
|
||||||
} else {
|
} else {
|
||||||
if (insert.hasPoll) {
|
if (insert.hasPoll) {
|
||||||
// Start transaction
|
// Start transaction
|
||||||
|
@ -1007,6 +990,17 @@ async function insertNote(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scyllaClient) {
|
||||||
|
const result = await scyllaClient.execute(
|
||||||
|
prepared.note.select.byId,
|
||||||
|
[insert.id],
|
||||||
|
{ prepare: true },
|
||||||
|
);
|
||||||
|
if (result.rowLength > 0) {
|
||||||
|
return parseScyllaNote(result.first());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return insert;
|
return insert;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// duplicate key error
|
// duplicate key error
|
||||||
|
|
Loading…
Reference in a new issue