denormalize more columns
This commit is contained in:
parent
a7fdf68bd2
commit
b37717d431
4 changed files with 25 additions and 35 deletions
|
@ -51,9 +51,14 @@ CREATE TABLE IF NOT EXISTS note ( -- Models timeline
|
|||
"channelId" ascii, -- Channel
|
||||
"channelName" text,
|
||||
"userId" ascii, -- User
|
||||
"userHost" text,
|
||||
"replyId" ascii, -- Reply
|
||||
"replyUserId" ascii,
|
||||
"replyUserHost" text,
|
||||
"renoteId" ascii, -- Boost
|
||||
"reactions" map<text, int>,
|
||||
"renoteUserId" ascii,
|
||||
"renoteUserHost" text,
|
||||
"reactions" map<text, int>, -- Reactions
|
||||
"noteEdit" set<frozen<note_edit_history>>, -- Edit History
|
||||
"updatedAt" timestamp,
|
||||
PRIMARY KEY ("createdAtDate", "createdAt", "id")
|
||||
|
|
|
@ -45,14 +45,19 @@ export const prepared = {
|
|||
"channelId",
|
||||
"channelName",
|
||||
"userId",
|
||||
"userHost",
|
||||
"replyId",
|
||||
"replyUserId",
|
||||
"replyUserHost",
|
||||
"renoteId",
|
||||
"renoteUserId",
|
||||
"renoteUserHost",
|
||||
"reactions",
|
||||
"noteEdit",
|
||||
"updatedAt"
|
||||
)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
select: {
|
||||
byDate: `SELECT * FROM note WHERE "createdAtDate" IN ?`,
|
||||
byId: `SELECT * FROM note WHERE "id" IN ?`,
|
||||
|
@ -111,35 +116,9 @@ export interface ScyllaNoteEditHistory {
|
|||
|
||||
export type ScyllaNote = Note & {
|
||||
createdAtDate: Date;
|
||||
createdAt: Note["createdAt"];
|
||||
id: Note["id"];
|
||||
visibility: Note["visibility"];
|
||||
text: Note["text"];
|
||||
name: Note["name"];
|
||||
cw: Note["cw"];
|
||||
localOnly: Note["localOnly"];
|
||||
renoteCount: Note["renoteCount"];
|
||||
repliesCount: Note["repliesCount"];
|
||||
uri: Note["uri"];
|
||||
url: Note["url"];
|
||||
score: Note["score"];
|
||||
files: ScyllaDriveFile[];
|
||||
fileIds: Note["fileIds"];
|
||||
attachedFileTypes: Note["attachedFileTypes"];
|
||||
visibleUserIds: Note["visibleUserIds"];
|
||||
mentions: Note["mentions"];
|
||||
emojis: Note["emojis"];
|
||||
tags: Note["tags"];
|
||||
hasPoll: Note["hasPoll"];
|
||||
threadId: Note["threadId"];
|
||||
channelId: Note["channelId"];
|
||||
channelName: string;
|
||||
userId: Note["userId"];
|
||||
replyId: Note["replyId"];
|
||||
renoteId: Note["renoteId"];
|
||||
reactions: Note["reactions"];
|
||||
noteEdit: ScyllaNoteEditHistory[];
|
||||
updatedAt: Note["updatedAt"];
|
||||
};
|
||||
|
||||
export function parseScyllaNote(row: types.Row): ScyllaNote {
|
||||
|
@ -170,8 +149,13 @@ export function parseScyllaNote(row: types.Row): ScyllaNote {
|
|||
channelId: row.get("channelId"),
|
||||
channelName: row.get("channelName"),
|
||||
userId: row.get("userId"),
|
||||
userHost: row.get("userHost"),
|
||||
replyId: row.get("replyId"),
|
||||
replyUserId: row.get("replyUserId"),
|
||||
replyUserHost: row.get("replyUserHost"),
|
||||
renoteId: row.get("replyId"),
|
||||
renoteUserId: row.get("renoteUserId"),
|
||||
renoteUserHost: row.get("renoteUserHost"),
|
||||
reactions: row.get("reactions"),
|
||||
noteEdit: row.get("noteEdit"),
|
||||
updatedAt: row.get("updatedAt"),
|
||||
|
@ -179,13 +163,8 @@ export function parseScyllaNote(row: types.Row): ScyllaNote {
|
|||
channel: null,
|
||||
renote: null,
|
||||
reply: null,
|
||||
renoteUserHost: null,
|
||||
renoteUserId: null,
|
||||
mentionedRemoteUsers: "",
|
||||
replyUserHost: null,
|
||||
replyUserId: null,
|
||||
user: null,
|
||||
userHost: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ export async function getNote(
|
|||
candidate.visibleUserIds.includes(me.id) || // visible to me
|
||||
candidate.mentions.includes(me.id) || // mentioned me
|
||||
(candidate.visibility === "followers" &&
|
||||
(await cache.isFollowing(candidate.userId)));
|
||||
(await cache.isFollowing(candidate.userId))) || // following
|
||||
candidate.replyUserId === me.id; // replied to myself
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
|
|
|
@ -796,9 +796,14 @@ async function insertNote(
|
|||
insert.threadId,
|
||||
data.channel?.id,
|
||||
data.channel?.name,
|
||||
user.id,
|
||||
insert.userId,
|
||||
insert.userHost,
|
||||
insert.replyId,
|
||||
insert.replyUserId,
|
||||
insert.replyUserHost,
|
||||
insert.renoteId,
|
||||
insert.renoteUserId,
|
||||
insert.renoteUserHost,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
|
Loading…
Reference in a new issue