poll_vote cleanup
This commit is contained in:
parent
efda68bc64
commit
06141e1ecc
4 changed files with 34 additions and 23 deletions
|
@ -44,7 +44,6 @@ async fn setup_schema(db: &DbConn) {
|
||||||
ad,
|
ad,
|
||||||
announcement_read,
|
announcement_read,
|
||||||
announcement,
|
announcement,
|
||||||
antenna_note,
|
|
||||||
antenna,
|
antenna,
|
||||||
app,
|
app,
|
||||||
attestation_challenge,
|
attestation_challenge,
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
mod int_test {
|
mod int_test {
|
||||||
use native_utils::{database, model, util};
|
use native_utils::{database, model};
|
||||||
|
|
||||||
use model::{
|
use model::{
|
||||||
entity::{antenna, antenna_note, note, user},
|
entity::{antenna, user},
|
||||||
repository::Repository,
|
repository::Repository,
|
||||||
schema,
|
schema,
|
||||||
};
|
};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter};
|
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
|
||||||
|
|
||||||
use crate::{cleanup, prepare};
|
use crate::{cleanup, prepare};
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ mod int_test {
|
||||||
prepare().await;
|
prepare().await;
|
||||||
let db = database::get_database().unwrap();
|
let db = database::get_database().unwrap();
|
||||||
|
|
||||||
let (alice, alice_antenna) = user::Entity::find()
|
let (_, alice_antenna) = user::Entity::find()
|
||||||
.filter(user::Column::Username.eq("alice"))
|
.filter(user::Column::Username.eq("alice"))
|
||||||
.find_also_related(antenna::Entity)
|
.find_also_related(antenna::Entity)
|
||||||
.one(db)
|
.one(db)
|
||||||
|
@ -86,24 +86,6 @@ mod int_test {
|
||||||
.expect("Unable to pack");
|
.expect("Unable to pack");
|
||||||
assert_eq!(packed.has_unread_note, false);
|
assert_eq!(packed.has_unread_note, false);
|
||||||
|
|
||||||
let note_model = note::Entity::find()
|
|
||||||
.filter(note::Column::UserId.eq(alice.id))
|
|
||||||
.one(db)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.expect("note not found");
|
|
||||||
let antenna_note = antenna_note::Model {
|
|
||||||
id: util::id::create_id(0).unwrap(),
|
|
||||||
antenna_id: alice_antenna.id.to_owned(),
|
|
||||||
note_id: note_model.id.to_owned(),
|
|
||||||
read: false,
|
|
||||||
};
|
|
||||||
antenna_note
|
|
||||||
.into_active_model()
|
|
||||||
.reset_all()
|
|
||||||
.insert(db)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let packed = alice_antenna
|
let packed = alice_antenna
|
||||||
.to_owned()
|
.to_owned()
|
||||||
.pack()
|
.pack()
|
||||||
|
|
|
@ -53,6 +53,9 @@ export const scyllaQueries = {
|
||||||
byReplyId: `SELECT * FROM note WHERE "replyId" = ?`,
|
byReplyId: `SELECT * FROM note WHERE "replyId" = ?`,
|
||||||
byChannelId: `SELECT * FROM note_by_channel_id WHERE "channelId" = ?`,
|
byChannelId: `SELECT * FROM note_by_channel_id WHERE "channelId" = ?`,
|
||||||
},
|
},
|
||||||
|
count: {
|
||||||
|
byUserId: `SELECT COUNT(*) FROM note_by_user_id WHERE "userId" = ?`,
|
||||||
|
},
|
||||||
delete: `DELETE FROM note WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? AND "userHost" = ? AND "visibility" = ?`,
|
delete: `DELETE FROM note WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? AND "userHost" = ? AND "visibility" = ?`,
|
||||||
update: {
|
update: {
|
||||||
renoteCount: `UPDATE note SET
|
renoteCount: `UPDATE note SET
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import { awaitAll } from "@/prelude/await-all.js";
|
import { awaitAll } from "@/prelude/await-all.js";
|
||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
import { ApiError } from "../../error.js";
|
import { ApiError } from "../../error.js";
|
||||||
|
import { scyllaClient } from "@/db/scylla.js";
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ["users"],
|
tags: ["users"],
|
||||||
|
@ -147,6 +148,32 @@ export const paramDef = {
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export default define(meta, paramDef, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
|
// FIXME: do we really need this chart?
|
||||||
|
if (scyllaClient) {
|
||||||
|
return {
|
||||||
|
notesCount: 0,
|
||||||
|
repliesCount: 0,
|
||||||
|
renotesCount: 0,
|
||||||
|
repliedCount: 0,
|
||||||
|
renotedCount: 0,
|
||||||
|
pollVotesCount: 0,
|
||||||
|
pollVotedCount: 0,
|
||||||
|
localFollowingCount: 0,
|
||||||
|
remoteFollowingCount: 0,
|
||||||
|
localFollowersCount: 0,
|
||||||
|
remoteFollowersCount: 0,
|
||||||
|
sentReactionsCount: 0,
|
||||||
|
receivedReactionsCount: 0,
|
||||||
|
noteFavoritesCount: 0,
|
||||||
|
pageLikesCount: 0,
|
||||||
|
pageLikedCount: 0,
|
||||||
|
driveFilesCount: 0,
|
||||||
|
driveUsage: 0,
|
||||||
|
followingCount: 0,
|
||||||
|
followersCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const user = await Users.findOneBy({ id: ps.userId });
|
const user = await Users.findOneBy({ id: ps.userId });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ApiError(meta.errors.noSuchUser);
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
|
|
Loading…
Reference in a new issue