Compare commits
2 Commits
a2b8f1a51c
...
298bae2e78
Author | SHA1 | Date | |
---|---|---|---|
298bae2e78 | |||
f69c73ed66 |
2
server/migrations/18_add_shadowbans.sql
Normal file
2
server/migrations/18_add_shadowbans.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
alter table users
|
||||||
|
add column shadowbanned boolean not null default false;
|
1
server/migrations/19_add_recommended_index.sql
Normal file
1
server/migrations/19_add_recommended_index.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
create index messages_territory_id_idx on messages (territory, id);
|
@ -67,7 +67,7 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
|
|||||||
m.message,
|
m.message,
|
||||||
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
||||||
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
||||||
coalesce(v2.vote, 0) as user_vote,
|
coalesce(sum(case when v.user = ? then v.vote else 0 end), 0) as user_vote,
|
||||||
m.glyph,
|
m.glyph,
|
||||||
m.emote as "emote: Json<Option<EmoteData>>",
|
m.emote as "emote: Json<Option<EmoteData>>",
|
||||||
m.created,
|
m.created,
|
||||||
@ -75,10 +75,10 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
|
|||||||
coalesce(cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int), 0) as last_seen_minutes
|
coalesce(cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int), 0) as last_seen_minutes
|
||||||
from messages m
|
from messages m
|
||||||
left join votes v on m.id = v.message
|
left join votes v on m.id = v.message
|
||||||
left join votes v2 on m.id = v2.message and v2.user = ?
|
|
||||||
inner join users u on m.user = u.id
|
inner join users u on m.user = u.id
|
||||||
where m.territory = ? and m.world is ? and m.ward is ? and m.plot is ?
|
where m.territory = ? and not u.shadowbanned and m.world is ? and m.ward is ? and m.plot is ?
|
||||||
group by m.id"#,
|
group by m.id
|
||||||
|
"#,
|
||||||
id,
|
id,
|
||||||
location,
|
location,
|
||||||
world,
|
world,
|
||||||
@ -103,7 +103,7 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
|
|||||||
m.message,
|
m.message,
|
||||||
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
||||||
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
||||||
coalesce(v2.vote, 0) as user_vote,
|
coalesce(sum(case when v.user = ? then v.vote else 0 end), 0) as user_vote,
|
||||||
m.glyph,
|
m.glyph,
|
||||||
m.emote as "emote: Json<Option<EmoteData>>",
|
m.emote as "emote: Json<Option<EmoteData>>",
|
||||||
m.created,
|
m.created,
|
||||||
@ -111,10 +111,10 @@ async fn logic(state: Arc<State>, id: i64, location: u32, query: GetLocationQuer
|
|||||||
coalesce(cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int), 0) as last_seen_minutes
|
coalesce(cast((julianday(current_timestamp) - julianday(u.last_seen)) * 1440 as int), 0) as last_seen_minutes
|
||||||
from messages m
|
from messages m
|
||||||
left join votes v on m.id = v.message
|
left join votes v on m.id = v.message
|
||||||
left join votes v2 on m.id = v2.message and v2.user = ?
|
|
||||||
inner join users u on m.user = u.id
|
inner join users u on m.user = u.id
|
||||||
where m.territory = ?
|
where m.territory = ? and not u.shadowbanned
|
||||||
group by m.id"#,
|
group by m.id
|
||||||
|
"#,
|
||||||
id,
|
id,
|
||||||
location,
|
location,
|
||||||
)
|
)
|
||||||
@ -182,7 +182,6 @@ fn filter_messages(messages: &mut Vec<RetrievedMessage>, id: i64, vote_threshold
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let time_since_creation = a.created.signed_duration_since(Utc::now().naive_utc());
|
let time_since_creation = a.created.signed_duration_since(Utc::now().naive_utc());
|
||||||
let brand_new = time_since_creation < Duration::minutes(30);
|
let brand_new = time_since_creation < Duration::minutes(30);
|
||||||
let new = time_since_creation < Duration::hours(2);
|
let new = time_since_creation < Duration::hours(2);
|
||||||
|
@ -38,13 +38,12 @@ async fn logic(state: Arc<State>, id: i64, message_id: Uuid) -> Result<impl Repl
|
|||||||
m.message,
|
m.message,
|
||||||
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
||||||
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
||||||
coalesce(v2.vote, 0) as user_vote,
|
coalesce(sum(case when v.user = ? then v.vote else 0 end), 0) as user_vote,
|
||||||
m.glyph,
|
m.glyph,
|
||||||
m.emote as "emote: Json<Option<EmoteData>>",
|
m.emote as "emote: Json<Option<EmoteData>>",
|
||||||
m.created
|
m.created
|
||||||
from messages m
|
from messages m
|
||||||
left join votes v on m.id = v.message
|
left join votes v on m.id = v.message
|
||||||
left join votes v2 on m.id = v2.message and v2.user = ?
|
|
||||||
where m.id = ?
|
where m.id = ?
|
||||||
group by m.id"#,
|
group by m.id"#,
|
||||||
id,
|
id,
|
||||||
|
@ -42,14 +42,13 @@ async fn logic(state: Arc<State>, id: i64, extra: i64, mut query: HashMap<String
|
|||||||
m.message,
|
m.message,
|
||||||
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
coalesce(sum(v.vote between 0 and 1), 0) as positive_votes,
|
||||||
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
coalesce(sum(v.vote between -1 and 0), 0) as negative_votes,
|
||||||
coalesce(v2.vote, 0) as user_vote,
|
coalesce(sum(case when v.user = ? then v.vote else 0 end), 0) as user_vote,
|
||||||
m.glyph,
|
m.glyph,
|
||||||
m.created,
|
m.created,
|
||||||
m.emote as "emote: Json<Option<EmoteData>>",
|
m.emote as "emote: Json<Option<EmoteData>>",
|
||||||
0 as "is_hidden: bool"
|
0 as "is_hidden: bool"
|
||||||
from messages m
|
from messages m
|
||||||
left join votes v on m.id = v.message
|
left join votes v on m.id = v.message
|
||||||
left join votes v2 on m.id = v2.message and v2.user = ?
|
|
||||||
where m.user = ?
|
where m.user = ?
|
||||||
group by m.id"#,
|
group by m.id"#,
|
||||||
id,
|
id,
|
||||||
|
Loading…
Reference in New Issue
Block a user