Compare commits

..

No commits in common. "8ee67addb69c94c91c6e0a8e0dd2f9ef8cf2620f" and "743080395bbbc98d7182f60612eb68ed593ebf48" have entirely different histories.

3 changed files with 15 additions and 17 deletions

6
.tci
View file

@ -1,18 +1,18 @@
#!/bin/bash #!/bin/bash
echo "building release binary" echo "building release binary"
cargo build --release --all-features cargo build --release --all-features -j 1 # limit memory usage
echo "stopping service" echo "stopping service"
systemctl --user stop upub systemctl --user stop upub
echo "installing new binary" echo "installing new binary"
cp ./target/release/upub /opt/bin/upub cp ./target/release/upub /opt/bin/upub
echo "migrating database" echo "migrating database"
/opt/bin/upub -c /srv/tci/upub.toml --domain https://upub.alemi.dev migrate /opt/bin/upub --db "sqlite:///srv/tci/upub.db" --domain https://upub.alemi.dev migrate
echo "restarting service" echo "restarting service"
systemctl --user start upub systemctl --user start upub
echo "rebuilding frontend" echo "rebuilding frontend"
cd web cd web
/opt/bin/trunk build --release --public-url 'https://upub.alemi.dev/web' CARGO_BUILD_JOBS=1 /opt/bin/trunk build --release --public-url 'https://upub.alemi.dev/web'
echo "deploying frontend" echo "deploying frontend"
rm /srv/http/upub/web/* rm /srv/http/upub/web/*
mv ./dist/* /srv/http/upub/web/ mv ./dist/* /srv/http/upub/web/

View file

@ -40,19 +40,19 @@ pub struct DatasourceConfig {
#[serde_inline_default("sqlite://./upub.db".into())] #[serde_inline_default("sqlite://./upub.db".into())]
pub connection_string: String, pub connection_string: String,
#[serde_inline_default(32)] #[serde_inline_default(4)]
pub max_connections: u32, pub max_connections: u32,
#[serde_inline_default(1)] #[serde_inline_default(1)]
pub min_connections: u32, pub min_connections: u32,
#[serde_inline_default(90u64)] #[serde_inline_default(300u64)]
pub connect_timeout_seconds: u64, pub connect_timeout_seconds: u64,
#[serde_inline_default(30u64)] #[serde_inline_default(300u64)]
pub acquire_timeout_seconds: u64, pub acquire_timeout_seconds: u64,
#[serde_inline_default(10u64)] #[serde_inline_default(1u64)]
pub slow_query_warn_seconds: u64, pub slow_query_warn_seconds: u64,
#[serde_inline_default(true)] #[serde_inline_default(true)]

View file

@ -1,5 +1,5 @@
use apb::{ActivityMut, ObjectMut}; use apb::{ActivityMut, ObjectMut};
use sea_orm::{sea_query::{IntoColumnRef, IntoCondition}, ColumnTrait, Condition, ConnectionTrait, DbErr, EntityName, EntityTrait, FromQueryResult, Iden, Iterable, LoaderTrait, ModelTrait, Order, QueryFilter, QueryOrder, QueryResult, QuerySelect, RelationTrait, Select, SelectColumns}; use sea_orm::{sea_query::IntoCondition, ColumnTrait, Condition, ConnectionTrait, DbErr, EntityName, EntityTrait, FromQueryResult, Iden, Iterable, LoaderTrait, ModelTrait, Order, QueryFilter, QueryOrder, QueryResult, QuerySelect, RelationTrait, Select, SelectColumns};
use crate::model; use crate::model;
@ -8,10 +8,7 @@ pub struct Query;
impl Query { impl Query {
pub fn activities(my_id: Option<i64>) -> Select<model::addressing::Entity> { pub fn activities(my_id: Option<i64>) -> Select<model::addressing::Entity> {
let mut select = model::addressing::Entity::find() let mut select = model::addressing::Entity::find()
.distinct_on([ .distinct_on([(model::activity::Entity, model::activity::Column::Internal)])
(model::addressing::Entity, model::addressing::Column::Published).into_column_ref(),
(model::activity::Entity, model::activity::Column::Internal).into_column_ref(),
])
.join(sea_orm::JoinType::InnerJoin, model::addressing::Relation::Activities.def()) .join(sea_orm::JoinType::InnerJoin, model::addressing::Relation::Activities.def())
.join(sea_orm::JoinType::LeftJoin, model::addressing::Relation::Objects.def()) .join(sea_orm::JoinType::LeftJoin, model::addressing::Relation::Objects.def())
.filter( .filter(
@ -20,8 +17,8 @@ impl Query {
.add(model::activity::Column::Id.is_not_null()) .add(model::activity::Column::Id.is_not_null())
.add(model::object::Column::Id.is_not_null()) .add(model::object::Column::Id.is_not_null())
) )
.order_by(model::addressing::Column::Published, Order::Desc)
.order_by(model::activity::Column::Internal, Order::Desc) .order_by(model::activity::Column::Internal, Order::Desc)
.order_by(model::addressing::Column::Published, Order::Desc)
.select_only(); .select_only();
for col in model::activity::Column::iter() { for col in model::activity::Column::iter() {
@ -47,10 +44,11 @@ impl Query {
pub fn objects(my_id: Option<i64>) -> Select<model::addressing::Entity> { pub fn objects(my_id: Option<i64>) -> Select<model::addressing::Entity> {
let mut select = model::addressing::Entity::find() let mut select = model::addressing::Entity::find()
.distinct_on([ // .distinct_on([
(model::addressing::Entity, model::addressing::Column::Published).into_column_ref(), // (model::object::Entity, model::object::Column::Internal).into_column_ref(),
(model::object::Entity, model::object::Column::Internal).into_column_ref(), // (model::addressing::Entity, model::addressing::Column::Published).into_column_ref(),
]) // ])
.distinct()
.join(sea_orm::JoinType::InnerJoin, model::addressing::Relation::Objects.def()) .join(sea_orm::JoinType::InnerJoin, model::addressing::Relation::Objects.def())
.order_by(model::addressing::Column::Published, Order::Desc) .order_by(model::addressing::Column::Published, Order::Desc)
.order_by(model::object::Column::Internal, Order::Desc) .order_by(model::object::Column::Internal, Order::Desc)