Skip to content

Commit f9cd4e8

Browse files
authored
Start with collection collaboration (#824)
* build(backend): remove tower deps * chore: change the domain name of application * feat(database): migration to change column name for collection * chore(backend): adapt to new database schema * fix(backend): calculate summary correctly * fix(backend): better calculation of summary * chore(frontend): adapt to new gql schema * feat(frontend): add link to people page * chore(database): change name of migration * feat(database): migration to create `user_to_collection` * ci: move commands to single line * feat(database): migration to create new record entries * fix(database): add if guard * feat(database): change the columns around * feat(database): store whether user is a creator * chore(database): change name of column * chore(backend): change the error logged * feat(backend): create new models * feat(*): bring back all user_id column * feat(backend): associate collection with user on creation * feat(backend): use new model to query for user * feat(backend): get collection count in one go * dev: change names of containers * dev: remove version from compose * chore(backend): reduce visibility * feat(backend): return username of creator * chore(docs): remove double quotes from env file * fix(backend): query collections instead of user_to_collection * feat(backend): return names correctly * feat(frontend): how collections are displayed * feat(backend): save creator id when changing association * feat(frontend): do not allow updating custom media * feat(frontend): start new collection schema changes * feat(frontend): get media monitoring button working * chore(backend): change name of gql objects * feat(backend): get user id for collection * feat(frontend): remove from correct collection * feat(frontend): flow collection data correctly * chore(ts-utils): export utility function * feat(frontend): allow adding to collection * chore(frontend): change wording * chore(frontend): change name of param * fix(backend): fetch all collections for entity * fix(backend): associate with collections correctly * fix(backend): merge media should be done in a txn * fix(backend): handle cases when media is already in dest collection * feat(frontend): order of update btns * build(backend): bump version * fix(backend): timezone shenanigans * fix(frontend): better wording * refactor(backend): associate user with entity immediately * docs: add back double quotes * feat(backend): allow storing manga volume * feat(backend): calculate manga volumes * feat(frontend): allow setting volume * fix(frontend): better showing of seen items * chore(backend): add more logging * chore(graphql): get additonal manga details * feat(frontend): display more unit details * feat(frontend): allow reviewing volumes * feat(frontend): better layout for input
1 parent aa3a024 commit f9cd4e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+735
-376
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ryot",
33
"dockerComposeFile": "docker-compose.yml",
4-
"service": "app",
4+
"service": "ryot-app",
55
"forwardPorts": [],
66
"workspaceFolder": "/workspaces/ryot",
77
"postCreateCommand": ". ${containerWorkspaceFolder}/.devcontainer/scripts/post-create.sh",

.devcontainer/docker-compose.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
version: "3.9"
2-
31
services:
4-
app:
2+
ryot-app:
53
build:
64
context: .
75
dockerfile: Dockerfile
@@ -14,7 +12,7 @@ services:
1412
- "5000:5000"
1513
user: archlinux
1614

17-
minio:
15+
ryot-minio:
1816
image: minio/minio
1917
ports:
2018
- "9000:9000"
@@ -23,7 +21,7 @@ services:
2321
- minio_storage:/data
2422
command: server --console-address ":9001" /data
2523

26-
postgres:
24+
ryot-postgres:
2725
image: postgres:16-alpine
2826
restart: unless-stopped
2927
volumes:

.devcontainer/scripts/post-create.sh

-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@
33
# setup the git identities
44
git config --global user.name "${GIT_AUTHOR_NAME}"
55
git config --global user.email "${GIT_AUTHOR_EMAIL}"
6-
7-
# These are available only in a fish environment
8-
fish -c '
9-
# setup dependencies
10-
moon sync projects
11-
'

Cargo.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<p align="center">
2424
<a href="https://docs.ryot.io" target="_blank">Installation</a> •
2525
<a href="https://docs.ryot.io/configuration" target="_blank">Configuration</a> •
26-
<a href="https://demo.ryot.io" target="_blank">Demo</a>
26+
<a href="https://app.ryot.io" target="_blank">Hosted version</a>
2727
</p>
2828

2929
<br/>

apps/backend/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ryot"
3-
version = "5.2.6"
3+
version = "5.2.7"
44
edition = "2021"
55
repository = "https://github.com/IgnisDa/ryot"
66
license = "GPL-3.0"
@@ -80,7 +80,6 @@ surf = { version = "2.3.2", features = [
8080
"h1-client-rustls",
8181
], default-features = false }
8282
tokio = { version = "1.37.0", features = ["full"] }
83-
tower = { version = "0.4.13", features = ["buffer"] }
8483
tower-http = { version = "0.5.2", features = ["catch-panic", "cors", "trace"] }
8584
tracing = { workspace = true }
8685
tracing-subscriber = "0.3.18"

apps/backend/src/entities/collection.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub struct Model {
1414
pub last_updated_on: DateTimeUtc,
1515
pub name: String,
1616
pub description: Option<String>,
17-
#[graphql(skip)]
1817
pub user_id: i32,
1918
}
2019

@@ -32,6 +31,8 @@ pub enum Relation {
3231
on_delete = "Cascade"
3332
)]
3433
User,
34+
#[sea_orm(has_many = "super::user_to_collection::Entity")]
35+
UserToCollection,
3536
}
3637

3738
impl Related<super::collection_to_entity::Entity> for Entity {
@@ -52,4 +53,10 @@ impl Related<super::user::Entity> for Entity {
5253
}
5354
}
5455

56+
impl Related<super::user_to_collection::Entity> for Entity {
57+
fn to() -> RelationDef {
58+
Relation::UserToCollection.def()
59+
}
60+
}
61+
5562
impl ActiveModelBehavior for ActiveModel {}

apps/backend/src/entities/collection_to_entity.rs

+1-30
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3
22
3-
use async_trait::async_trait;
43
use sea_orm::entity::prelude::*;
54
use serde::{Deserialize, Serialize};
65

7-
use crate::utils::associate_user_with_entity;
8-
9-
use super::prelude::Collection;
10-
116
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
127
#[sea_orm(table_name = "collection_to_entity")]
138
pub struct Model {
@@ -95,28 +90,4 @@ impl Related<super::exercise::Entity> for Entity {
9590
}
9691
}
9792

98-
#[async_trait]
99-
impl ActiveModelBehavior for ActiveModel {
100-
async fn after_save<C>(model: Model, db: &C, insert: bool) -> Result<Model, DbErr>
101-
where
102-
C: ConnectionTrait,
103-
{
104-
if insert {
105-
let collection = Collection::find_by_id(model.collection_id)
106-
.one(db)
107-
.await?
108-
.unwrap();
109-
associate_user_with_entity(
110-
&collection.user_id,
111-
model.metadata_id,
112-
model.person_id,
113-
model.exercise_id.clone(),
114-
model.metadata_group_id,
115-
db,
116-
)
117-
.await
118-
.ok();
119-
}
120-
Ok(model)
121-
}
122-
}
93+
impl ActiveModelBehavior for ActiveModel {}

apps/backend/src/entities/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6
1+
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
22
33
pub mod prelude;
44

@@ -19,5 +19,6 @@ pub mod review;
1919
pub mod seen;
2020
pub mod user;
2121
pub mod user_measurement;
22+
pub mod user_to_collection;
2223
pub mod user_to_entity;
2324
pub mod workout;

apps/backend/src/entities/prelude.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6
1+
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
22
33
pub use super::calendar_event::Entity as CalendarEvent;
44
pub use super::collection::Entity as Collection;
@@ -17,5 +17,6 @@ pub use super::review::Entity as Review;
1717
pub use super::seen::Entity as Seen;
1818
pub use super::user::Entity as User;
1919
pub use super::user_measurement::Entity as UserMeasurement;
20+
pub use super::user_to_collection::Entity as UserToCollection;
2021
pub use super::user_to_entity::Entity as UserToEntity;
2122
pub use super::workout::Entity as Workout;

apps/backend/src/entities/user.rs

+16
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub struct Model {
7676
pub enum Relation {
7777
#[sea_orm(has_many = "super::collection::Entity")]
7878
Collection,
79+
#[sea_orm(has_many = "super::exercise::Entity")]
80+
Exercise,
7981
#[sea_orm(has_many = "super::import_report::Entity")]
8082
ImportReport,
8183
#[sea_orm(has_many = "super::review::Entity")]
@@ -84,6 +86,8 @@ pub enum Relation {
8486
Seen,
8587
#[sea_orm(has_many = "super::user_measurement::Entity")]
8688
UserMeasurement,
89+
#[sea_orm(has_many = "super::user_to_collection::Entity")]
90+
UserToCollection,
8791
#[sea_orm(has_many = "super::user_to_entity::Entity")]
8892
UserToEntity,
8993
#[sea_orm(has_many = "super::workout::Entity")]
@@ -96,6 +100,12 @@ impl Related<super::collection::Entity> for Entity {
96100
}
97101
}
98102

103+
impl Related<super::exercise::Entity> for Entity {
104+
fn to() -> RelationDef {
105+
Relation::Exercise.def()
106+
}
107+
}
108+
99109
impl Related<super::import_report::Entity> for Entity {
100110
fn to() -> RelationDef {
101111
Relation::ImportReport.def()
@@ -120,6 +130,12 @@ impl Related<super::user_measurement::Entity> for Entity {
120130
}
121131
}
122132

133+
impl Related<super::user_to_collection::Entity> for Entity {
134+
fn to() -> RelationDef {
135+
Relation::UserToCollection.def()
136+
}
137+
}
138+
123139
impl Related<super::user_to_entity::Entity> for Entity {
124140
fn to() -> RelationDef {
125141
Relation::UserToEntity.def()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
2+
3+
use sea_orm::entity::prelude::*;
4+
5+
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6+
#[sea_orm(table_name = "user_to_collection")]
7+
pub struct Model {
8+
#[sea_orm(primary_key, auto_increment = false)]
9+
pub collection_id: i32,
10+
#[sea_orm(primary_key, auto_increment = false)]
11+
pub user_id: i32,
12+
}
13+
14+
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15+
pub enum Relation {
16+
#[sea_orm(
17+
belongs_to = "super::collection::Entity",
18+
from = "Column::CollectionId",
19+
to = "super::collection::Column::Id",
20+
on_update = "Cascade",
21+
on_delete = "Cascade"
22+
)]
23+
Collection,
24+
#[sea_orm(
25+
belongs_to = "super::user::Entity",
26+
from = "Column::UserId",
27+
to = "super::user::Column::Id",
28+
on_update = "Cascade",
29+
on_delete = "Cascade"
30+
)]
31+
User,
32+
}
33+
34+
impl Related<super::collection::Entity> for Entity {
35+
fn to() -> RelationDef {
36+
Relation::Collection.def()
37+
}
38+
}
39+
40+
impl Related<super::user::Entity> for Entity {
41+
fn to() -> RelationDef {
42+
Relation::User.def()
43+
}
44+
}
45+
46+
impl ActiveModelBehavior for ActiveModel {}

apps/backend/src/fitness/resolver.rs

+1
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ impl ExerciseService {
796796
&self.db,
797797
user_id,
798798
ChangeCollectionToEntityInput {
799+
creator_user_id: user_id,
799800
collection_name: DefaultCollection::Custom.to_string(),
800801
exercise_id: Some(exercise.id.clone()),
801802
..Default::default()

apps/backend/src/importer/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ impl ImporterService {
396396
podcast_episode_number: seen.podcast_episode_number,
397397
anime_episode_number: seen.anime_episode_number,
398398
manga_chapter_number: seen.manga_chapter_number,
399+
manga_volume_number:seen.manga_volume_number,
399400
provider_watched_on: seen.provider_watched_on.clone(),
400401
change_state: None,
401402
},
@@ -440,6 +441,7 @@ impl ImporterService {
440441
.add_entity_to_collection(
441442
user_id,
442443
ChangeCollectionToEntityInput {
444+
creator_user_id: user_id,
443445
collection_name: col.to_string(),
444446
metadata_id: Some(metadata.id),
445447
..Default::default()
@@ -509,6 +511,7 @@ impl ImporterService {
509511
.add_entity_to_collection(
510512
user_id,
511513
ChangeCollectionToEntityInput {
514+
creator_user_id: user_id,
512515
collection_name: col.to_string(),
513516
metadata_id: Some(metadata_id),
514517
..Default::default()
@@ -564,6 +567,7 @@ impl ImporterService {
564567
.add_entity_to_collection(
565568
user_id,
566569
ChangeCollectionToEntityInput {
570+
creator_user_id: user_id,
567571
collection_name: col.to_string(),
568572
person_id: Some(person.id),
569573
..Default::default()

apps/backend/src/integrations.rs

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct IntegrationMedia {
2626
pub podcast_episode_number: Option<i32>,
2727
pub anime_episode_number: Option<i32>,
2828
pub manga_chapter_number: Option<i32>,
29+
pub manga_volume_number: Option<i32>,
2930
pub provider_watched_on: Option<String>,
3031
}
3132

@@ -115,6 +116,7 @@ impl IntegrationService {
115116
podcast_episode_number: None,
116117
manga_chapter_number: None,
117118
anime_episode_number: None,
119+
manga_volume_number: None,
118120
})
119121
}
120122

@@ -244,6 +246,7 @@ impl IntegrationService {
244246
podcast_episode_number: None,
245247
anime_episode_number: None,
246248
manga_chapter_number: None,
249+
manga_volume_number: None,
247250
})
248251
}
249252

@@ -324,6 +327,7 @@ impl IntegrationService {
324327
podcast_episode_number: None,
325328
anime_episode_number: None,
326329
manga_chapter_number: None,
330+
manga_volume_number: None,
327331
});
328332
}
329333
}

0 commit comments

Comments
 (0)