Skip to content

Commit

Permalink
Deduplicate media items for upcoming section (#1089)
Browse files Browse the repository at this point in the history
* feat(backend): allow specifying dedupe for calendar events

* chore(frontend): adapt to new gql schema

* chore(backend): send new param

* Revert "chore(backend): send new param"

This reverts commit e99bdd1.

* Revert "chore(frontend): adapt to new gql schema"

This reverts commit 421c966.

* Revert "feat(backend): allow specifying dedupe for calendar events"

This reverts commit 0be5c51.

* chore(services/misc): send new param for deduplicating events

* feat(services/misc): do not return duplicate elements for upcoming query

* chore(services/misc): change order of attrs

* refactor(backend): move function into service

* Revert "refactor(backend): move function into service"

This reverts commit 546175d.

* refactor(backend): move stuff to more appropriate place

* refactor(backend): move stuff around

* refactor(backend): move more functions over

* refactor(backend): move another struct over

* refactor(backend): move another struct over

* fix(frontend): swapped icons for manga and anime

* style(frontend): remove function bodies

* refactor(backend): do not use trait

* refactor(backend): move all functions to dependent utils

* build(ts): upgrade packages

* build(backend): update dependencies and rust version
  • Loading branch information
IgnisDa authored Oct 30, 2024
1 parent d62dc9f commit eb644f7
Show file tree
Hide file tree
Showing 30 changed files with 1,099 additions and 966 deletions.
999 changes: 514 additions & 485 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ members = [
resolver = "2"

[workspace.dependencies]
anyhow = "=1.0.89"
apalis = { version = "=0.5.3", features = ["cron", "limit"] }
anyhow = "=1.0.91"
apalis = { version = "=0.5.5", features = ["cron", "limit"] }
argon2 = "=0.6.0-pre.1"
async-graphql = { version = "=7.0.11", features = [
"chrono",
Expand All @@ -57,7 +57,7 @@ async-graphql = { version = "=7.0.11", features = [
"tracing",
] }
async-trait = "=0.1.83"
aws-sdk-s3 = { version = "=1.54.0", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "=1.58.0", features = ["behavior-version-latest"] }
axum = { version = "=0.7.7", features = ["macros", "multipart"] }
boilermates = "=0.3.0"
chrono = "=0.4.38"
Expand All @@ -82,7 +82,7 @@ markdown = "=1.0.0-alpha.21"
moka = { version = "=0.12.8", features = ["future"] }
nanoid = "=0.4.0"
openidconnect = "=3.5.0"
regex = "=1.11.0"
regex = "=1.11.1"
rust_decimal = "=1.36.0"
rust_decimal_macros = "=1.36.0"
schematic = { version = "=0.17.5", features = [
Expand All @@ -99,7 +99,7 @@ schematic = { version = "=0.17.5", features = [
"validate",
"yaml",
], default-features = false }
sea-orm = { version = "=1.0.1", features = [
sea-orm = { version = "=1.1.0", features = [
"debug-print",
"postgres-array",
"macros",
Expand All @@ -110,17 +110,17 @@ sea-orm = { version = "=1.0.1", features = [
"with-rust_decimal",
"with-uuid",
], default-features = false }
sea-orm-migration = "=1.0.1"
sea-query = "=0.31.1"
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.128"
sea-orm-migration = "=1.1.0"
sea-query = "=0.32.0"
serde = { version = "=1.0.214", features = ["derive"] }
serde_json = "=1.0.132"
serde_with = { version = "=3.11.0", features = ["chrono_0_4"] }
slug = "=0.1.6"
strum = { version = "=0.26.3", features = ["derive"] }
reqwest = { version = "=0.12.8", features = ["json", "stream"] }
tokio = { version = "=1.40.0", features = ["full"] }
reqwest = { version = "=0.12.9", features = ["json", "stream"] }
tokio = { version = "=1.41.0", features = ["full"] }
tracing = { version = "=0.1.40", features = ["attributes"] }
uuid = { version = "=1.10.0", features = ["v4"], default-features = false }
uuid = { version = "=1.11.0", features = ["v4"], default-features = false }

[profile.release]
lto = true
2 changes: 1 addition & 1 deletion apps/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ tower = { version = "=0.4.13", features = ["buffer"] }
tower-http = { version = "=0.5.2", features = ["catch-panic", "cors", "trace"] }
tracing = { workspace = true }
tracing-subscriber = "=0.3.18"
unkey = "=0.4.0"
unkey = "=0.5.0"
user-resolver = { path = "../../crates/resolvers/user" }
user-service = { path = "../../crates/services/user" }
38 changes: 15 additions & 23 deletions apps/frontend/app/lib/generals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ export const queryClient = new QueryClient({
defaultOptions: { queries: { staleTime: Number.POSITIVE_INFINITY } },
});

export const getDateFromTimeSpan = (timeSpan: TimeSpan) => {
return match(timeSpan)
export const getDateFromTimeSpan = (timeSpan: TimeSpan) =>
match(timeSpan)
.with(TimeSpan.Last7Days, () => dayjs().subtract(7, "days"))
.with(TimeSpan.Last30Days, () => dayjs().subtract(30, "days"))
.with(TimeSpan.Last90Days, () => dayjs().subtract(90, "days"))
.with(TimeSpan.Last365Days, () => dayjs().subtract(365, "days"))
.with(TimeSpan.AllTime, () => null)
.exhaustive();
};

export enum FitnessEntity {
Workouts = "workouts",
Expand Down Expand Up @@ -126,7 +125,7 @@ export const sendNotificationToServiceWorker = (
body: string,
tag?: AppServiceWorkerNotificationTag,
data?: AppServiceWorkerNotificationData,
) => {
) =>
navigator.serviceWorker.ready.then((registration) => {
registration.showNotification(title, {
tag,
Expand All @@ -136,7 +135,6 @@ export const sendNotificationToServiceWorker = (
icon: LOGO_IMAGE_URL,
});
});
};

export type AppServiceWorkerMessageData = {
event: "remove-timer-completed-notification";
Expand All @@ -145,7 +143,7 @@ export type AppServiceWorkerMessageData = {
export const postMessageToServiceWorker = (
message: AppServiceWorkerMessageData,
) => {
if (navigator.serviceWorker.controller)
if (navigator.serviceWorker?.controller)
navigator.serviceWorker.controller.postMessage(message);
};

Expand Down Expand Up @@ -254,8 +252,8 @@ export enum Verb {
Read = 0,
}

export const getVerb = (verb: Verb, lot: MediaLot) => {
return match(verb)
export const getVerb = (verb: Verb, lot: MediaLot) =>
match(verb)
.with(Verb.Read, () => {
return match(lot)
.with(MediaLot.Book, MediaLot.Manga, () => "read")
Expand All @@ -277,7 +275,6 @@ export const getVerb = (verb: Verb, lot: MediaLot) => {
});
})
.otherwise(() => "");
};

/**
* Generate a random color based on a seed.
Expand All @@ -286,9 +283,7 @@ export const getVerb = (verb: Verb, lot: MediaLot) => {
export const generateColor = (seed: number) => {
const color = Math.floor(Math.abs(Math.sin(seed) * 16777215));
let newColor = color.toString(16);
while (newColor.length < 6) {
newColor = `0${color}`;
}
while (newColor.length < 6) newColor = `0${color}`;
return `#${newColor}`;
};

Expand All @@ -297,25 +292,22 @@ export const generateColor = (seed: number) => {
*/
export const getStringAsciiValue = (input: string) => {
let total = 0;
for (let i = 0; i < input.length; i++) {
total += input.charCodeAt(i);
}
for (let i = 0; i < input.length; i++) total += input.charCodeAt(i);
return total;
};

export const getMetadataIcon = (lot: MediaLot) => {
return match(lot)
export const getMetadataIcon = (lot: MediaLot) =>
match(lot)
.with(MediaLot.Book, () => IconBook)
.with(MediaLot.Manga, () => IconBooks)
.with(MediaLot.Movie, () => IconDeviceTv)
.with(MediaLot.Anime, () => IconDeviceTvOld)
.with(MediaLot.VisualNovel, () => IconBook2)
.with(MediaLot.Show, () => IconDeviceDesktop)
.with(MediaLot.VideoGame, () => IconBrandAppleArcade)
.with(MediaLot.AudioBook, () => IconHeadphones)
.with(MediaLot.Podcast, () => IconMicrophone)
.with(MediaLot.Manga, () => IconDeviceTvOld)
.with(MediaLot.Anime, () => IconBooks)
.with(MediaLot.VisualNovel, () => IconBook2)
.with(MediaLot.AudioBook, () => IconHeadphones)
.with(MediaLot.VideoGame, () => IconBrandAppleArcade)
.exhaustive();
};

export const applicationBaseUrl =
typeof window !== "undefined" ? window.location.origin : "";
Expand Down
10 changes: 5 additions & 5 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@ryot/generated": "workspace:*",
"@ryot/graphql": "workspace:*",
"@ryot/ts-utils": "workspace:*",
"@tabler/icons-react": "3.20.0",
"@tabler/icons-react": "3.21.0",
"@tanstack/react-query": "5.59.16",
"@tanstack/react-query-devtools": "5.59.16",
"buffer": "6.0.3",
Expand All @@ -47,28 +47,28 @@
"js-cookie": "3.0.5",
"jwt-decode": "4.0.0",
"mantine-datatable": "7.12.4",
"nanoid": "5.0.7",
"nanoid": "5.0.8",
"react": "18.3.1",
"react-confirm": "0.3.0-7",
"react-dom": "18.3.1",
"react-virtuoso": "4.12.0",
"react-webcam": "7.2.0",
"recharts": "2.13.0",
"recharts": "2.13.1",
"remix-routes": "1.7.7",
"remix-utils": "7.7.0",
"tiny-invariant": "1.3.3",
"ts-pattern": "5.5.0",
"ufo": "1.5.4",
"usehooks-ts": "3.1.0",
"uuid": "10.0.0",
"uuid": "11.0.2",
"zod": "3.23.8",
"zodix": "0.4.4"
},
"devDependencies": {
"@bitprojects/umami-logger-typescript": "1.0.10",
"@remix-pwa/dev": "3.1.0",
"@remix-run/dev": "2.13.1",
"@types/cookie": "0.6.0",
"@types/cookie": "1.0.0",
"@types/crypto-js": "4.2.2",
"@types/howler": "2.2.12",
"@types/js-cookie": "3.0.6",
Expand Down
22 changes: 11 additions & 11 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@conform-to/zod": "1.2.2",
"@isaacs/ttlcache": "1.4.1",
"@paddle/paddle-js": "1.2.3",
"@paddle/paddle-js": "1.3.1",
"@paddle/paddle-node-sdk": "1.9.1",
"@radix-ui/react-label": "2.1.0",
"@radix-ui/react-slot": "1.1.0",
Expand All @@ -22,27 +22,27 @@
"@ryot/graphql": "workspace:*",
"@ryot/transactional": "workspace:*",
"@ryot/ts-utils": "workspace:*",
"@tabler/icons-react": "3.20.0",
"@tabler/icons-react": "3.21.0",
"@unkey/api": "0.26.2",
"class-variance-authority": "0.7.0",
"clsx": "2.1.1",
"crypto-js": "4.2.0",
"dayjs": "1.11.13",
"drizzle-orm": "0.35.3",
"embla-carousel-autoplay": "8.3.0",
"embla-carousel-react": "8.3.0",
"embla-carousel-autoplay": "8.3.1",
"embla-carousel-react": "8.3.1",
"graphql": "16.9.0",
"graphql-request": "7.1.0",
"humanize-duration-ts": "2.1.1",
"input-otp": "1.2.4",
"input-otp": "1.2.5",
"isbot": "5.1.17",
"lodash": "4.17.21",
"lucide-react": "0.453.0",
"nanoid": "5.0.7",
"lucide-react": "0.454.0",
"nanoid": "5.0.8",
"next-themes": "0.3.0",
"nodemailer": "6.9.15",
"openid-client": "5.6.5",
"postgres": "3.4.4",
"nodemailer": "6.9.16",
"openid-client": "5.7.0",
"postgres": "3.4.5",
"react": "18.3.1",
"react-dom": "18.3.1",
"remix-routes": "1.7.7",
Expand All @@ -59,7 +59,7 @@
"@remix-run/dev": "2.13.1",
"@tailwindcss/typography": "0.5.15",
"@types/crypto-js": "^4.2.2",
"@types/lodash": "4.17.12",
"@types/lodash": "4.17.13",
"@types/nodemailer": "6.4.16",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
Expand Down
1 change: 1 addition & 0 deletions crates/migrations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub use m20230502_create_genre::{
pub use m20230504_create_collection::Collection as AliasedCollection;
pub use m20230505_create_review::Review as AliasedReview;
pub use m20230822_create_exercise::Exercise as AliasedExercise;
pub use m20230912_create_calendar_event::CalendarEvent as AliasedCalendarEvent;
pub use m20231016_create_collection_to_entity::CollectionToEntity as AliasedCollectionToEntity;
pub use m20231017_create_user_to_entity::UserToEntity as AliasedUserToEntity;

Expand Down
4 changes: 0 additions & 4 deletions crates/models/fitness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ version = "0.1.0"
edition = "2021"

[dependencies]
application-utils = { path = "../../utils/application" }
async-graphql = { workspace = true }
async-trait = { workspace = true }
common-models = { path = "../../models/common" }
derive_more = { workspace = true }
educe = { workspace = true }
enums = { path = "../../enums" }
file-storage-service = { path = "../../services/file-storage" }
rust_decimal = { workspace = true }
rust_decimal_macros = { workspace = true }
schematic = { workspace = true }
sea-orm = { workspace = true }
serde = { workspace = true }
Expand Down
Loading

0 comments on commit eb644f7

Please sign in to comment.