Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New fitness analytics page #1118

Merged
merged 239 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
239 commits
Select commit Hold shift + click to select a range
61d7c40
feat(migrations): create new columns for daily user activities
IgnisDa Nov 24, 2024
614729e
chore(migrations): remove newlines
IgnisDa Nov 24, 2024
24f3a73
feat(backend): store data in new dua columns
IgnisDa Nov 24, 2024
91f9577
chore(backend): change data type of muscles stored in db
IgnisDa Nov 24, 2024
7e4599e
Merge branch 'main' into issue-1113
IgnisDa Nov 24, 2024
b2d498a
Merge branch 'main' into issue-1113
IgnisDa Nov 24, 2024
7293bec
chore: make start time less than end time
IgnisDa Nov 25, 2024
d9b8837
chore: make start date less than end date
IgnisDa Nov 25, 2024
01587f6
chore(backend): common input struct for date range
IgnisDa Nov 25, 2024
c45defb
chore(backend): add comment to input struct
IgnisDa Nov 25, 2024
9633ee7
chore(frontend): adapt to new gql schema
IgnisDa Nov 25, 2024
b0c1d90
chore(utils): add debug logs for user activity calculation
IgnisDa Nov 25, 2024
dac8fd7
feat(models): add new struct to return response for analytics
IgnisDa Nov 25, 2024
6160b20
build(models/dependent): add new deps
IgnisDa Nov 25, 2024
89b93b1
build(backend): add new required deps
IgnisDa Nov 25, 2024
cac10a4
feat(backend): add new query for getting fitness analytics
IgnisDa Nov 25, 2024
dd715e7
feat(backend): add query fragment for fitness analytics
IgnisDa Nov 25, 2024
d4a7e75
build(services/statistics): add new deps to crate
IgnisDa Nov 25, 2024
4596668
feat(services/statistics): calculate hour counts
IgnisDa Nov 25, 2024
bb4b063
feat(backend): complete implementation of fitness statistics
IgnisDa Nov 25, 2024
e3c05ba
feat(backend): compute additional fields
IgnisDa Nov 25, 2024
7885b14
feat(migrations): add new column to store value
IgnisDa Nov 25, 2024
d41fa64
feat(backend): allow saving value in application cache
IgnisDa Nov 25, 2024
6bd9e69
feat(backend): cache fitness analytics for 2 hours
IgnisDa Nov 25, 2024
84429bf
feat(frontend): add basic fitness analytics page
IgnisDa Nov 25, 2024
76cedd5
fix(frontend): pass correct schema to parser
IgnisDa Nov 25, 2024
e50e905
feat(backend): add new preference for fitness analytics
IgnisDa Nov 25, 2024
3f349d8
feat(frontend): add fitness analytics to sidebar
IgnisDa Nov 25, 2024
935ad4d
feat(frontend): design basic webpage
IgnisDa Nov 25, 2024
6315b21
feat(frontend): do most calculations on the server loader
IgnisDa Nov 25, 2024
17589b5
feat(frontend): get fallback search params
IgnisDa Nov 25, 2024
9189043
feat(frontend): allow specifying custom time ranges
IgnisDa Nov 25, 2024
34b5750
feat(frontend): fetch data for fitness analytics
IgnisDa Nov 25, 2024
ca8e59d
chore(services/cache): log when cache key found
IgnisDa Nov 25, 2024
e6e5068
Revert "chore(services/cache): log when cache key found"
IgnisDa Nov 25, 2024
f02330a
feat(frontend): display basic pie chart
IgnisDa Nov 25, 2024
11fcaad
refactor(frontend): extract component to display chart container
IgnisDa Nov 25, 2024
e7995f4
feat(frontend): allow changing how many muscles to display
IgnisDa Nov 25, 2024
1f7c55e
feat(frontend): save count of muscles shown in local storage
IgnisDa Nov 25, 2024
1200f9e
feat(frontend): also allow setting analytics timespan to "All Time"
IgnisDa Nov 25, 2024
628d082
chore(docs): remove fragment from link
IgnisDa Nov 25, 2024
037202d
feat(frontend): add bar chart for exercises done
IgnisDa Nov 25, 2024
38b4e11
chore(frontend): minor enhancements to chart
IgnisDa Nov 25, 2024
47794fa
feat(frontend): handle cases when no analytics present
IgnisDa Nov 27, 2024
5f68630
Merge branch 'main' into issue-1113
IgnisDa Nov 27, 2024
2faaf1f
feat(backend): save igdb settings in application cache
IgnisDa Nov 27, 2024
1fe5871
feat(backend): save listennotes settings in application cache
IgnisDa Nov 27, 2024
6d010b0
perf(backend): remove extra parameter
IgnisDa Nov 27, 2024
cf75754
refactor(backend): change function name
IgnisDa Nov 27, 2024
f2fec30
perf(backend): do not make a useless clone
IgnisDa Nov 27, 2024
79ff3c8
feat(backend): save tmdb settings in application cache
IgnisDa Nov 27, 2024
db0947e
fix(providers): cache tmdb settings in the database
IgnisDa Nov 27, 2024
6e79e67
chore(migrations): make column non nullable
IgnisDa Nov 27, 2024
dce86b1
chore(backend): adapt to new database schema
IgnisDa Nov 27, 2024
c158727
refactor(backend): change function names
IgnisDa Nov 27, 2024
581c1f3
chore(frontend): minor changes to graphs
IgnisDa Nov 27, 2024
825ed52
chore(gql): fix formatting of query
IgnisDa Nov 27, 2024
fcbebc7
feat(frontend): use better colors for graphs
IgnisDa Nov 27, 2024
33f28da
Merge branch 'main' into issue-1113
IgnisDa Nov 27, 2024
8f943d1
fix(frontend): remove text align from page heading
IgnisDa Nov 27, 2024
9cf4e74
chore(frontend): select entire text when focusing on input
IgnisDa Nov 27, 2024
a6c0837
chore(frontend): change how props are structured
IgnisDa Nov 28, 2024
14af0b1
feat(frontend): function to convert utc hour to local hour
IgnisDa Nov 28, 2024
160a954
feat(frontend): start section to display time of day
IgnisDa Nov 28, 2024
993bc3e
fix(utils/database): calculate hour correctly
IgnisDa Nov 28, 2024
d1401b6
feat(frontend): generate correct data for time of day chart
IgnisDa Nov 28, 2024
29d244a
fix(frontend): generate correct arrays
IgnisDa Nov 28, 2024
8f99589
feat(frontend): display bubble chart for time of day
IgnisDa Nov 28, 2024
abd9670
chore(frontend): better types of stuff
IgnisDa Nov 28, 2024
35019ef
docs: better wording for authentication caveat
IgnisDa Nov 28, 2024
9ce1d04
feat(backend): setting to exclude exercise from analytics
IgnisDa Nov 28, 2024
831425c
feat(utils/database): respect new exercise setting
IgnisDa Nov 28, 2024
aca3fda
fix(services/fitness): handle edge case for updating exercise settings
IgnisDa Nov 28, 2024
b757fb2
feat(frontend): allow excluding exercise from analytics
IgnisDa Nov 28, 2024
e759bbb
feat(frontend): display the active episode for shows and podcasts
IgnisDa Nov 28, 2024
ebb7145
feat(frontend): remove scroll margin when it is no longer first exercise
IgnisDa Nov 28, 2024
4af5829
fix(providers): do not unwrap directly
IgnisDa Nov 30, 2024
c623456
perf(services/fitness): do not cast json to text when filtering on mu…
IgnisDa Dec 2, 2024
95d9a7a
Merge branch 'main' into issue-1113
IgnisDa Dec 4, 2024
664b36a
chore(enums): some other changes
IgnisDa Dec 4, 2024
6fc9141
feat(migrations): new columns for daily_user_activity
IgnisDa Dec 4, 2024
5cf23c9
feat(migrations): drop entire table and recreate it
IgnisDa Dec 4, 2024
c97da8a
feat(backend): adjust daily user activity calculation to new database…
IgnisDa Dec 4, 2024
673e24e
fix(services/statistics): adjust daily user activity calculation to n…
IgnisDa Dec 4, 2024
cfbf161
fix(services/statistics): change fallback to include in same millenium
IgnisDa Dec 4, 2024
7b32251
chore(backend): make the expiry of application cache nullable
IgnisDa Dec 4, 2024
6d63ab9
chore(backend): change names of jobs
IgnisDa Dec 4, 2024
97e8804
feat: more resilient logic for validating pro keys
IgnisDa Dec 4, 2024
a1ded4c
chore(backend): general changes
IgnisDa Dec 4, 2024
509efcd
perf(utils/dependent): only get key if cache is being respect
IgnisDa Dec 4, 2024
f48047e
chore(migrations): add fixme comment
IgnisDa Dec 4, 2024
2da56a5
feat: change "re-evaluate" to "revise"
IgnisDa Dec 4, 2024
de2e6e1
fix(frontend): change btn text
IgnisDa Dec 4, 2024
d111321
feat(backend): allow scheduling user for workout revision
IgnisDa Dec 4, 2024
2581937
chore(utils/database): add log after scheduling
IgnisDa Dec 4, 2024
6562e94
feat(backend): deploy all changes at once
IgnisDa Dec 4, 2024
187010e
feat(backend): implement scheduled workout revision
IgnisDa Dec 4, 2024
3dedb56
chore(services/fitness): add log statement
IgnisDa Dec 4, 2024
7578880
build(ts): update nodejs deps
IgnisDa Dec 4, 2024
44c11a3
perf(utils/database): preselect all exercises
IgnisDa Dec 4, 2024
81de555
fix(frontend): send old event attribute
IgnisDa Dec 4, 2024
0ba6a99
docs: move instructions around
IgnisDa Dec 4, 2024
2f5b5cc
docs: change orders of headings
IgnisDa Dec 4, 2024
2b9b9f4
docs: change word of release section
IgnisDa Dec 4, 2024
bb14bd7
refactor(models/common): order of enum elements
IgnisDa Dec 4, 2024
416be3b
feat(models/common): add key for metadata recently consumed
IgnisDa Dec 4, 2024
accbb4a
feat(utils/dependent): mark metadata as recently consumed when markin…
IgnisDa Dec 4, 2024
06a3d9d
feat(backend): return whether media is recently consumed
IgnisDa Dec 4, 2024
c5ec559
feat(frontend): highlight media which are currently in progress
IgnisDa Dec 4, 2024
8fa47e6
chore(frontend): change some colors
IgnisDa Dec 4, 2024
3cf6da3
chore(frontend): sort prop ordering
IgnisDa Dec 4, 2024
4d3740a
fix(frontend): make box-shadow smaller
IgnisDa Dec 4, 2024
1ec772b
refactor(backend): functions to mark and get entity recently consumed
IgnisDa Dec 4, 2024
fdeba1b
feat(backend): get whether person and metadata group were recently co…
IgnisDa Dec 4, 2024
9063154
feat(backend): mark metadata as recently consumed
IgnisDa Dec 4, 2024
258a156
feat(frontend): display when entity interacted with
IgnisDa Dec 4, 2024
53726cd
chore(migrations): schedule all users for workout revision
IgnisDa Dec 4, 2024
c2806c3
fix(utils/dependent): use Epley formula for one rm calculation below …
IgnisDa Dec 4, 2024
6c126fe
fix(migrations): insert correct cache value into database
IgnisDa Dec 4, 2024
1d8efbb
fix(migrations): run query only when there are more than 0 users
IgnisDa Dec 4, 2024
cc7a999
chore(services/fitness): add log for each user whose workouts are bei…
IgnisDa Dec 4, 2024
1a9295f
fix(utils/dependent): use Epley for reps higher than 10
IgnisDa Dec 4, 2024
0061298
refactor(utils/dependent): use filter instead of mutable variable
IgnisDa Dec 4, 2024
5ddf993
ci: Run CI
IgnisDa Dec 4, 2024
ee30646
fix(services/misc): do not get recommendations for custom metadata
IgnisDa Dec 5, 2024
6eea05b
chore(backend): lift up analytics
IgnisDa Dec 5, 2024
734312d
chore(frontend): adapt to new gql schema
IgnisDa Dec 5, 2024
f20a4de
feat(backend): return entire analytics from single endpoint
IgnisDa Dec 5, 2024
001debc
Revert "feat(backend): return entire analytics from single endpoint"
IgnisDa Dec 5, 2024
ef9dd4d
feat(frontend): respect features enabled when displaying fitness charts
IgnisDa Dec 5, 2024
07c74da
chore(frontend): run formatter
IgnisDa Dec 5, 2024
9bd6b0b
feat(frontend): allow starting media from outside
IgnisDa Dec 5, 2024
4f9b0f6
refactor(frontend): remove duplicated code
IgnisDa Dec 5, 2024
6138332
feat(frontend): load analytics page on client side
IgnisDa Dec 5, 2024
d305745
fix(frontend): do not display counter if not allowed
IgnisDa Dec 5, 2024
cb7b68d
feat(frontend): change the time of day graph
IgnisDa Dec 6, 2024
338c839
feat(frontend): display time ranges for analytics page
IgnisDa Dec 6, 2024
bd53be2
build(frontend): add screenshot deps
IgnisDa Dec 6, 2024
c1ac11c
feat(frontend): button to download the analytics page as png
IgnisDa Dec 6, 2024
1c5f780
fix(frontend): add background color to container to fix screenshots
IgnisDa Dec 6, 2024
31f9713
Merge branch 'main' into issue-1113
IgnisDa Dec 7, 2024
1017d92
feat(frontend): move to using new grid container
IgnisDa Dec 7, 2024
843bbc0
feat(frontend): do not display border if not applicable
IgnisDa Dec 7, 2024
3ab5d9d
feat(backend): remove the activity section
IgnisDa Dec 8, 2024
245df92
feat(frontend): move activity graph to analytics section
IgnisDa Dec 8, 2024
a488274
feat(frontend): adjust activity section to be more in sync with other…
IgnisDa Dec 8, 2024
bdcd952
feat(frontend): use radar chart for time of day
IgnisDa Dec 8, 2024
cc179a6
feat(frontend): display workout counts
IgnisDa Dec 8, 2024
2f3dc47
fix(frontend): time of day
IgnisDa Dec 8, 2024
a8fa276
Revert "Revert "feat(backend): return entire analytics from single en…
IgnisDa Dec 8, 2024
7e157cb
feat(backend): return user analytics correctly
IgnisDa Dec 8, 2024
be8a43a
feat(frontend): display all entity types in scatter chart
IgnisDa Dec 8, 2024
a7158b1
ci: Run CI
IgnisDa Dec 8, 2024
84e99a8
feat(frontend): display polar radius axis
IgnisDa Dec 8, 2024
d80fc94
chore(frontend): always display chart
IgnisDa Dec 8, 2024
fcb8b5d
Revert "chore(frontend): always display chart"
IgnisDa Dec 8, 2024
fef9cd8
feat(frontend): filter out hours which do not have anything associated
IgnisDa Dec 8, 2024
935f1fb
chore(frontend): sort attributes by length
IgnisDa Dec 8, 2024
3ec736c
feat(backend): start making identifier the primary column
IgnisDa Dec 8, 2024
e8b32b5
feat(backend): allow naming exercises similarly
IgnisDa Dec 8, 2024
fa099b7
feat(migrations): change names of indices
IgnisDa Dec 8, 2024
e1e8da0
feat(frontend): start adapting to new graphql schema
IgnisDa Dec 8, 2024
d596604
chore(frontend): adapt to new gql schema
IgnisDa Dec 8, 2024
c93e7e8
ci: Run CI
IgnisDa Dec 8, 2024
5e2c20d
fix(frontend): cleanup remaining stuff
IgnisDa Dec 8, 2024
8d006ec
fix(backend): do not schedule user for workout revision if exercise n…
IgnisDa Dec 8, 2024
c73804f
feat(backend): change `name` key of workouts to `id`
IgnisDa Dec 8, 2024
69d2a65
feat(frontend): adapt to new gql schema
IgnisDa Dec 8, 2024
79a95b2
fix(services/importer): send correct details to the importer
IgnisDa Dec 8, 2024
c9a916e
refactor(backend): extract common fn to generate exercise id
IgnisDa Dec 8, 2024
9f4bbe7
fix(services/importer): select correct attribute of exercise
IgnisDa Dec 8, 2024
ed28bb0
fix(services/importer): select correct attribute of exercise
IgnisDa Dec 8, 2024
ecf7e5c
chore(services/importer): import set lot for strong app
IgnisDa Dec 8, 2024
07c0bcc
feat(backend): send user measurements
IgnisDa Dec 8, 2024
d619692
fix(migrations): collapse two queries into one
IgnisDa Dec 8, 2024
3ab7b64
feat(frontend): do not change case a lot
IgnisDa Dec 8, 2024
1c6189f
fix(frontend): render filter only on the frontend
IgnisDa Dec 8, 2024
32c95b9
ci: Run CI
IgnisDa Dec 8, 2024
069e130
refactor(backend): do not create new services for integrations
IgnisDa Dec 8, 2024
cbabaf8
fix(frontend): remove curly braces
IgnisDa Dec 8, 2024
aa9fb5e
ci: Run CI
IgnisDa Dec 8, 2024
68e1fa5
build(backend): change dependency tree
IgnisDa Dec 8, 2024
d1e477f
build(backend): change dependency tree
IgnisDa Dec 8, 2024
32b5924
refactor(backend): move models around
IgnisDa Dec 8, 2024
7614d2f
refactor(models/common): move structs around
IgnisDa Dec 8, 2024
be860b6
feat(backend): get rid of latest user summary query
IgnisDa Dec 8, 2024
ebc65df
feat(frontend): adapt to new graphql schema
IgnisDa Dec 8, 2024
bf14d4d
refactor(backend): collapse two queries into one
IgnisDa Dec 8, 2024
815f34e
feat(frontend): adapt to new gql schema
IgnisDa Dec 8, 2024
2917983
feat(backend): add query to get user analytics parameters
IgnisDa Dec 8, 2024
09a9fc9
fix(services/statistics): apply null ordering
IgnisDa Dec 8, 2024
9c1b187
build(backend): change dependency tree
IgnisDa Dec 8, 2024
9dd2420
refactor(services/statistics): call function serially
IgnisDa Dec 8, 2024
67cb41d
feat(frontend): use new loader query
IgnisDa Dec 8, 2024
65557de
feat(frontend): capture screen after 1.5 seconds
IgnisDa Dec 8, 2024
e32b782
perf(backend): save user's analytics parameters
IgnisDa Dec 8, 2024
a703de5
ci: Run CI
IgnisDa Dec 8, 2024
15e4f47
perf(models): do not serialize none values
IgnisDa Dec 8, 2024
b10a1d1
fix(frontend): better wording
IgnisDa Dec 8, 2024
4ec06d5
chore(frontend): remove useless zod usage
IgnisDa Dec 8, 2024
be66235
chore(services/importer): add some more logs in plex importer
IgnisDa Dec 9, 2024
f6daa6b
refactor(backend): sync data to owned collection separately
IgnisDa Dec 9, 2024
2b428a5
feat(backend): migrate for existing plex sink integrations
IgnisDa Dec 9, 2024
ec0c05d
fix(services/user): respect sync to owned collection in input
IgnisDa Dec 9, 2024
67d557e
feat(frontend): adapt to new gql schema
IgnisDa Dec 9, 2024
91309b7
fix(frontend): do not make input required
IgnisDa Dec 9, 2024
c3a549a
docs: add info about ryot yank integration
IgnisDa Dec 9, 2024
cf64da0
feat(backend): allow syncing to owned collection from plex
IgnisDa Dec 9, 2024
3cd412f
ci: Run CI
IgnisDa Dec 9, 2024
2412236
docs: improve documentation
IgnisDa Dec 9, 2024
03055aa
feat(backend): return only the id for workouts and workout templates …
IgnisDa Dec 9, 2024
ddab323
fix(services/fitness): specify column of correct model
IgnisDa Dec 9, 2024
3b7932a
feat(frontend): adapt to new gql schema
IgnisDa Dec 9, 2024
185940e
feat(frontend): add skeleton loader for fitness entity
IgnisDa Dec 9, 2024
1a41556
feat(frontend): make loader more presentable
IgnisDa Dec 9, 2024
43d356c
refactor(frontend): some minor changes
IgnisDa Dec 9, 2024
637ea6b
fix(frontend): handle cases when no daily user activities are present
IgnisDa Dec 9, 2024
7041c03
feat(backend): do not use application cache for user workout revision
IgnisDa Dec 10, 2024
0c43a84
feat(backend): return some other data
IgnisDa Dec 10, 2024
58b2409
feat(frontend): display fitness statistics
IgnisDa Dec 10, 2024
ecfb135
feat(frontend): display distance travelled
IgnisDa Dec 10, 2024
a92158e
feat(backend): return total rest time
IgnisDa Dec 10, 2024
e63a4d4
fix(utils/database): store rest time in correct unit
IgnisDa Dec 10, 2024
1a357e7
feat(frontend): display rest time
IgnisDa Dec 10, 2024
2f1058e
ci: Run CI
IgnisDa Dec 10, 2024
a82296b
refactor(frontend): create correct props
IgnisDa Dec 10, 2024
f04cdb3
feat(frontend): make the text dim
IgnisDa Dec 10, 2024
3691a08
feat(ts-utils): add function to format numbers
IgnisDa Dec 10, 2024
2eb14b7
feat(frontend): format workout reps number with compact notation
IgnisDa Dec 10, 2024
3716cb7
fix(frontend): better position for workout btn
IgnisDa Dec 10, 2024
890195e
feat(frontend): display watermark in captured screenshot
IgnisDa Dec 10, 2024
c28971d
feat(frontend): hide counter in captured screenshot
IgnisDa Dec 10, 2024
17606c3
fix(frontend): additional padding for statistics card
IgnisDa Dec 10, 2024
f0a1f01
fix(frontend): additional padding for statistics card
IgnisDa Dec 10, 2024
f828f6c
feat(frontend): add pro validation for saving image
IgnisDa Dec 10, 2024
b7dc389
refactor(frontend): change it to an enum
IgnisDa Dec 10, 2024
b1688fc
refactor(frontend): change watch times to enum
IgnisDa Dec 10, 2024
fa75b94
feat(frontend): hide analytics graph for non pro users
IgnisDa Dec 10, 2024
c097c4a
ci: Run CI
IgnisDa Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions apps/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ axum = { workspace = true }
aws-sdk-s3 = { workspace = true }
background = { path = "../../crates/background" }
cache-service = { path = "../../crates/services/cache" }
chrono = { workspace = true }
chrono-tz = { workspace = true }
collection-resolver = { path = "../../crates/resolvers/collection" }
collection-service = { path = "../../crates/services/collection" }
common-utils = { path = "../../crates/utils/common" }
config = { path = "../../crates/config" }
database-models = { path = "../../crates/models/database" }
dependent-models = { path = "../../crates/models/dependent" }
dotenvy = { workspace = true }
env-utils = { path = "../../crates/utils/env" }
Expand All @@ -31,6 +29,7 @@ file-storage-resolver = { path = "../../crates/resolvers/file-storage" }
file-storage-service = { path = "../../crates/services/file-storage" }
fitness-resolver = { path = "../../crates/resolvers/fitness" }
fitness-service = { path = "../../crates/services/fitness" }
futures = { workspace = true }
http = { workspace = true }
importer-resolver = { path = "../../crates/resolvers/importer" }
importer-service = { path = "../../crates/services/importer" }
Expand All @@ -46,9 +45,7 @@ reqwest = { workspace = true }
router-resolver = { path = "../../crates/resolvers/router" }
sea-orm = { workspace = true }
sea-orm-migration = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
schematic = { workspace = true }
statistics-resolver = { path = "../../crates/resolvers/statistics" }
statistics-service = { path = "../../crates/services/statistics" }
Expand All @@ -58,6 +55,6 @@ tower = { workspace = true }
tower-http = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
unkey = { workspace = true }
traits = { path = "../../crates/traits" }
user-resolver = { path = "../../crates/resolvers/user" }
user-service = { path = "../../crates/services/user" }
18 changes: 8 additions & 10 deletions apps/backend/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use exporter_resolver::{ExporterMutation, ExporterQuery};
use exporter_service::ExporterService;
use file_storage_resolver::{FileStorageMutation, FileStorageQuery};
use file_storage_service::FileStorageService;
use fitness_resolver::{ExerciseMutation, ExerciseQuery};
use fitness_service::ExerciseService;
use fitness_resolver::{FitnessMutation, FitnessQuery};
use fitness_service::FitnessService;
use importer_resolver::{ImporterMutation, ImporterQuery};
use importer_service::ImporterService;
use integration_service::IntegrationService;
Expand Down Expand Up @@ -49,15 +49,14 @@ pub struct AppServices {
pub app_router: Router,
pub importer_service: Arc<ImporterService>,
pub exporter_service: Arc<ExporterService>,
pub exercise_service: Arc<ExerciseService>,
pub fitness_service: Arc<FitnessService>,
pub statistics_service: Arc<StatisticsService>,
pub integration_service: Arc<IntegrationService>,
pub miscellaneous_service: Arc<MiscellaneousService>,
}

#[allow(clippy::too_many_arguments)]
pub async fn create_app_services(
is_pro: bool,
db: DatabaseConnection,
timezone: chrono_tz::Tz,
s3_client: aws_sdk_s3::Client,
Expand All @@ -73,7 +72,6 @@ pub async fn create_app_services(
let cache_service = CacheService::new(&db);
let supporting_service = Arc::new(
SupportingService::new(
is_pro,
&db,
timezone,
cache_service,
Expand All @@ -87,7 +85,7 @@ pub async fn create_app_services(
);
let user_service = Arc::new(UserService(supporting_service.clone()));
let importer_service = Arc::new(ImporterService(supporting_service.clone()));
let exercise_service = Arc::new(ExerciseService(supporting_service.clone()));
let fitness_service = Arc::new(FitnessService(supporting_service.clone()));
let exporter_service = Arc::new(ExporterService(supporting_service.clone()));
let collection_service = Arc::new(CollectionService(supporting_service.clone()));
let statistics_service = Arc::new(StatisticsService(supporting_service.clone()));
Expand All @@ -104,7 +102,7 @@ pub async fn create_app_services(
.data(user_service.clone())
.data(importer_service.clone())
.data(exporter_service.clone())
.data(exercise_service.clone())
.data(fitness_service.clone())
.data(statistics_service.clone())
.data(collection_service.clone())
.data(file_storage_service.clone())
Expand Down Expand Up @@ -149,7 +147,7 @@ pub async fn create_app_services(
app_router,
importer_service,
exporter_service,
exercise_service,
fitness_service,
statistics_service,
integration_service,
miscellaneous_service,
Expand Down Expand Up @@ -192,7 +190,7 @@ pub struct QueryRoot(
MiscellaneousQuery,
ImporterQuery,
ExporterQuery,
ExerciseQuery,
FitnessQuery,
FileStorageQuery,
StatisticsQuery,
CollectionQuery,
Expand All @@ -204,7 +202,7 @@ pub struct MutationRoot(
MiscellaneousMutation,
ImporterMutation,
ExporterMutation,
ExerciseMutation,
FitnessMutation,
FileStorageMutation,
CollectionMutation,
UserMutation,
Expand Down
49 changes: 36 additions & 13 deletions apps/backend/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,41 @@ use apalis::prelude::*;
use background::{ApplicationJob, CoreApplicationJob, ScheduledJob};
use common_utils::ryot_log;
use exporter_service::ExporterService;
use fitness_service::ExerciseService;
use fitness_service::FitnessService;
use importer_service::ImporterService;
use integration_service::IntegrationService;
use media_models::CommitMediaInput;
use miscellaneous_service::MiscellaneousService;
use statistics_service::StatisticsService;
use traits::TraceOk;

pub async fn background_jobs(
pub async fn run_background_jobs(
information: ScheduledJob,
misc_service: Data<Arc<MiscellaneousService>>,
) -> Result<(), Error> {
ryot_log!(debug, "Running job at {:#?}", information.0);
misc_service.perform_background_jobs().await.unwrap();
misc_service.perform_background_jobs().await.trace_ok();
Ok(())
}

pub async fn sync_integrations_data(
pub async fn run_frequent_jobs(
_information: ScheduledJob,
fitness_service: Data<Arc<FitnessService>>,
misc_service: Data<Arc<MiscellaneousService>>,
integration_service: Data<Arc<IntegrationService>>,
) -> Result<(), Error> {
integration_service.yank_integrations_data().await.unwrap();
misc_service
.perform_server_key_validation()
.await
.trace_ok();
integration_service
.yank_integrations_data()
.await
.trace_ok();
fitness_service
.process_users_scheduled_for_workout_revision()
.await
.trace_ok();
Ok(())
}

Expand Down Expand Up @@ -67,7 +81,7 @@ pub async fn perform_application_job(
integration_service: Data<Arc<IntegrationService>>,
importer_service: Data<Arc<ImporterService>>,
exporter_service: Data<Arc<ExporterService>>,
exercise_service: Data<Arc<ExerciseService>>,
fitness_service: Data<Arc<FitnessService>>,
statistics_service: Data<Arc<StatisticsService>>,
) -> Result<(), Error> {
let name = information.to_string();
Expand All @@ -84,10 +98,9 @@ pub async fn perform_application_job(
.await
.is_ok()
}
ApplicationJob::ReEvaluateUserWorkouts(user_id) => exercise_service
.re_evaluate_user_workouts(user_id)
.await
.is_ok(),
ApplicationJob::ReviseUserWorkouts(user_id) => {
fitness_service.revise_user_workouts(user_id).await.is_ok()
}
ApplicationJob::UpdateMetadata(metadata_id, force_update) => misc_service
.update_metadata_and_notify_users(&metadata_id, force_update)
.await
Expand All @@ -104,7 +117,7 @@ pub async fn perform_application_job(
.update_metadata_group(&metadata_group_id)
.await
.is_ok(),
ApplicationJob::UpdateGithubExerciseJob(exercise) => exercise_service
ApplicationJob::UpdateGithubExerciseJob(exercise) => fitness_service
.update_github_exercise(exercise)
.await
.is_ok(),
Expand All @@ -126,12 +139,22 @@ pub async fn perform_application_job(
ApplicationJob::PerformExport(user_id) => {
exporter_service.perform_export(user_id).await.is_ok()
}
ApplicationJob::UpdateExerciseLibrary => exercise_service
ApplicationJob::UpdateExerciseLibrary => fitness_service
.deploy_update_exercise_library_job()
.await
.is_ok(),
ApplicationJob::SyncIntegrationsData => {
integration_service.yank_integrations_data().await.is_ok()
integration_service
.yank_integrations_data()
.await
.trace_ok();
integration_service
.sync_integrations_data_to_owned_collection()
.await
.is_ok()
}
ApplicationJob::PerformServerKeyValidation => {
misc_service.perform_server_key_validation().await.is_ok()
}
ApplicationJob::HandleEntityAddedToCollectionEvent(collection_to_entity_id) => {
integration_service
Expand Down
Loading
Loading