refactor: update dependencies

This commit is contained in:
Anna 2023-09-17 03:53:57 -04:00
parent 5ef3a8c6b4
commit 739b8819c7
Signed by: anna
GPG Key ID: D0943384CD9F87D1
7 changed files with 788 additions and 491 deletions

1253
server/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,8 @@ rayon = "1"
serde = { version = "1", features = ["derive"] }
serde_yaml = "0.9"
sha3 = "0.10"
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "sqlite", "chrono"] }
toml = "0.7"
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "sqlite", "chrono"] }
toml = "0.8"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
tokio-stream = { version = "0.1", default-features = false, features = ["net"] }
uuid = { version = "1", features = ["serde", "v4"] }

View File

@ -0,0 +1,3 @@
[toolchain]
channel = 'nightly'
targets = ['x86_64-unknown-linux-musl']

View File

@ -1,4 +1,4 @@
#![feature(drain_filter)]
#![feature(extract_if)]
use std::collections::HashMap;
use std::net::SocketAddr;

View File

@ -66,11 +66,11 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
m.message,
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
v2.vote as user_vote,
coalesce(v2.vote, 0) as user_vote,
m.glyph,
m.created,
m.user,
cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int) as last_seen_minutes
coalesce(cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int), 0) as last_seen_minutes
from messages m
left join votes v on m.id = v.message
left join votes v2 on m.id = v2.message and v2.user = ?
@ -101,11 +101,11 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
m.message,
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
v2.vote as user_vote,
coalesce(v2.vote, 0) as user_vote,
m.glyph,
m.created,
m.user,
cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int) as last_seen_minutes
coalesce(cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int), 0) as last_seen_minutes
from messages m
left join votes v on m.id = v.message
left join votes v2 on m.id = v2.message and v2.user = ?
@ -129,7 +129,7 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
fn filter_messages(messages: &mut Vec<RetrievedMessage>, id: i64) {
// remove messages where the user has been offline for over 35 minutes
// also remove messages with low score (that aren't the from the user)
messages.drain_filter(|msg| msg.last_seen_minutes >= 35 || (msg.user != id && (msg.positive_votes - msg.negative_votes) < crate::consts::VOTE_THRESHOLD_HIDE));
messages.retain(|msg| msg.last_seen_minutes < 35 && (msg.user == id || (msg.positive_votes - msg.negative_votes) >= crate::consts::VOTE_THRESHOLD_HIDE));
// shuffle messages since we'll be excluding later based on messages
// that have already been included, so this will be more fair
@ -211,5 +211,5 @@ fn filter_messages(messages: &mut Vec<RetrievedMessage>, id: i64) {
});
let ids = ids.into_inner();
messages.drain_filter(|msg| !ids.contains(&msg.id));
messages.retain(|msg| ids.contains(&msg.id));
}

View File

@ -5,7 +5,6 @@ use uuid::Uuid;
use warp::{Filter, Rejection, Reply};
use warp::filters::BoxedFilter;
use crate::message::RetrievedMessageTerritory;
use crate::State;
use crate::web::{AnyhowRejection, WebError};
@ -37,7 +36,7 @@ async fn logic(state: Arc<State>, id: i64, message_id: Uuid) -> Result<impl Repl
m.message,
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
v2.vote as user_vote,
coalesce(v2.vote, 0) as user_vote,
m.glyph,
m.created
from messages m

View File

@ -41,7 +41,7 @@ async fn logic(state: Arc<State>, id: i64, extra: i64, mut query: HashMap<String
m.message,
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
v2.vote as user_vote,
coalesce(v2.vote, 0) as user_vote,
m.glyph,
m.created,
0 as "is_hidden: bool"