Commit graph

510 commits

Author SHA1 Message Date
3f325e025a Update character.rb
Add explicit Awakenings enum
2025-02-09 18:35:25 -08:00
52225fe40b Update grid_character.rb
- Adds code transforming incoming ring and awakening values into something the db understands
2025-02-09 18:35:15 -08:00
241393661c Update weapon_awakening.rb
- Removes redefined explicit associations
2025-02-09 18:34:46 -08:00
f1590ab981 Update party.rb
- Removes favorited accessor
- Renames derivative_parties to remixes and adds in-built sort
2025-02-09 18:34:32 -08:00
d7f11e3ca5 Update awakening.rb
- Removes explicitly defined associations and adds ActiveRecord associations instead
2025-02-09 18:34:00 -08:00
9fdce28253 Update users_controller.rb
More efficient way of denoting favorited parties.
2025-02-09 18:33:19 -08:00
f89b21c253 Eager load raids/groups when querying 2025-02-09 18:12:56 -08:00
588d682801 Eager-load jobs when querying job skills 2025-02-09 18:12:38 -08:00
dbe7c67b3d Improve handling mastery bonuses
- Improved handling of nested attributes:
  - Replaced old mastery structure with new `rings` and `awakening` assignments.
  - Added `new_rings` and `new_awakening` virtual attributes for easier updates.
  - Updated `assign_attributes` to exclude `rings` and `awakening` to prevent conflicts.

- Enhanced parameter transformation:
  - Introduced `transform_character_params` to process `rings`, `awakening`, and `earring` more reliably.
  - Ensured proper type conversion (`to_i`) for numeric values in `uncap_level`, `transcendence_step`, and `awakening_level`.
  - Improved error handling for missing values by setting defaults where needed.

- Optimized database queries:
  - Added `.includes(:awakening)` to `set` to prevent N+1 query issues.

- Updated strong parameters:
  - Changed `rings` from individual keys (`ring1`, `ring2`, etc.) to a structured array format.
  - Refactored permitted attributes to align with the new nested structure.
2025-02-09 18:10:12 -08:00
bb82f74e27 Move n+1 detection to around_action hook 2025-02-09 18:04:59 -08:00
76f3b85613 Update raid blueprints
- Show flat representation of raid group in RaidBlueprint's nested view
- Show nested representation of raid in RaidGroupBlueprint's full view
2025-02-09 18:04:43 -08:00
8f77a1f613 Refactor grid blueprints
- **GridCharacterBlueprint:**
  - Removed `:minimal` view restriction on `party` association.
  - Improved nil checks for `ring1`, `ring2`, and `earring` to prevent errors.
  - Converted string values in `awakening_level`, `over_mastery`, and `aetherial_mastery` fields to integers for consistency.
  - Ensured `over_mastery` and `aetherial_mastery` only include valid entries, filtering out blank or zero-modifier values.

- **GridWeaponBlueprint:**
  - Removed `:minimal` view restriction on `party` association.
  - Ensured `weapon` association exists before accessing `ax`, `series`, or `awakening`.
  - Improved conditional checks for `weapon_keys` to prevent errors when `weapon` or `series` is nil.
  - Converted `awakening_level` field to integer for consistency.

- **GridCharacterBlueprint:**
  - Removed `:minimal` view restriction on `party` association.
2025-02-09 18:03:35 -08:00
be91c2c033 Optimize party loading by adding eager loading to set_from_slug
- Refactored `set_from_slug` to use `includes` for eager loading associated models:
  - `user`, `job`, `raid` (with `group`)
  - `characters` (with `character` and `awakening`)
  - `weapons` (with `weapon`, `awakenings`, `weapon_key1`, `weapon_key2`, `weapon_key3`)
  - `summons` (with `summon`)
  - `guidebooks` (`guidebook1`, `guidebook2`, `guidebook3`)
  - `source_party`, `remixes`, `skills`, and `accessory`
- This change improves query efficiency by reducing N+1 queries and ensures all relevant associations are preloaded.
- Removed redundant favorite check as it was not necessary in this context.
2025-02-09 18:00:14 -08:00
844d3ee6f8 Maintain API consistency with raid blueprint 2025-02-07 03:38:47 -08:00
ea0bbc542e Alias table name to object to maintain API consistency 2025-02-07 03:34:10 -08:00
b89e83df97 Refactor parties#index and parties#favorites
These are mostly the same methods, so we remove common code into build_parties_query and render_paginated_parties
2025-02-07 03:27:39 -08:00
234d337af7 Update parties_controller.rb
Adds the rest of the changes, too tired to write them all out. Some preview generation, some filtering
2025-02-07 03:22:47 -08:00
38f6c043bf Update parties_controller.rb
Updates apply_includes and apply_excludes, along with modifying id_to_table and build_query
2025-02-07 03:18:30 -08:00
fde9b08edc Update parties#index 2025-02-07 03:17:36 -08:00
fdda833337 Update parties_controller.rbs 2025-02-07 03:17:04 -08:00
59be9d80d2 Remove redundant return 2025-02-07 02:22:47 -08:00
09dc344e35 Refactor parties#create 2025-02-07 02:21:52 -08:00
b526ce2138 Fix old view name in PartyBlueprint 2025-02-07 02:21:38 -08:00
5ecfeb6684 Update filter condition helpers
Just minor refactoring
2025-02-07 02:17:04 -08:00
59564df5ab Adds a helper method for party privacy 2025-02-07 02:15:48 -08:00
5d8ec96172 Updates excluded methods and calculate_count
* Use `includes` instead of `joins`
* Use a less-insane way of counting
2025-02-07 02:11:50 -08:00
8194844d28 Update logic and logs 2025-02-07 02:06:40 -08:00
ab1fd78530 Create parties_controller.rbs 2025-02-07 02:06:14 -08:00
1bc7d5fac9 Add method comments 2025-02-07 02:02:44 -08:00
9f86f3bf29 Remove preview expiry constants
These are defined in the Coordinator instead
2025-02-07 01:59:53 -08:00
adbb048867 Refactored PartyBlueprint to minimize N+1s 2025-02-07 01:58:52 -08:00
cca4427a75 Add cache to is_favorited(user) 2025-02-07 01:58:29 -08:00
dc24f4e600 Add preview generation helpers
The Party model can respond to queries about its preview state with the following models:
- `schedule_preview_generation`
- `preview_content_changed?`
- `preview_expired?`
- `should_generate_preview?`
- `ready_for_preview?`
- `needs_preview_generation?`
- `preview_relevant_attributes`

Removes the following methods:
- `schedule_preview_regeneration`
- `preview_relevant_changes?`
2025-02-07 01:58:17 -08:00
bd53af4339 Add counter caches to party 2025-02-07 01:54:27 -08:00
b86f3a90f6 Remove N+1 from grid object models
Reimplementing `character` `summon` and `weapon` was making N+1s which made queries really slow
2025-02-07 01:53:21 -08:00
4afccabaaf Refactor grid object blueprints 2025-02-07 01:51:34 -08:00
b71ca8e458 Refactor canonical object blueprints 2025-02-07 01:51:24 -08:00
e7db082d8b Update api_controller.rb
Add N+1 detectioin via Prosopite in development/test environments
2025-02-07 01:50:58 -08:00
0ad2db92fa Enable query logging 2025-02-07 01:35:30 -08:00
6dcb15f10d Configure Prosopite and remove CacheFreeLogger 2025-02-07 01:35:14 -08:00
2979ffb1e5 Configure Sidekiq
Create job for cleaning up party previews
2025-02-07 01:34:55 -08:00
8da912a2e4 Update Gemfile
Production:
- `newrelic_rpm`

Development:
- `pg_query`
- `prosopite`
2025-02-07 01:34:11 -08:00
58fd5db844 Update .gitignore 2025-02-07 01:31:11 -08:00
f914c1f16e Add migrations
* Update preview state default to pending
* Adds indexes
* Adds PgHero and PgStatements
2025-02-07 01:30:08 -08:00
8409fcabcf Update gitignore
There is a mystery postgres folder and we are going to ignore it
2025-02-07 01:29:17 -08:00
11d324efe9
Fix image embeds 3 (#176)
* Add default preview images

* Update application.rb

* Adds app assets path in API mode
* Cleans up file

* Create assets.rb

An initializer for font assets (for image generation)

* Updates to Canvas and Coordinator

* Update parties_controller.rb

* Adds retry header if generation is still in progress
* Streams S3 content instead of redirecting to prevent 302

* Update coordinator.rbs

* Create previews.rake

A rake task for generating images offline

* Add commands to build phase
2025-01-20 03:55:22 -08:00
ad2e2cc028
More embed image bandaids (#175)
* Only re-index search when records are updated

* Add logs and fixes

* Add preview_s3_key to Parties

* Add some extra packages to Nixfile

* Add logging around custom font use
2025-01-18 22:32:13 -08:00
1c1ed0dd9d
Work towards fixing embed images (#174)
* Add Redis and Sidekiq

* Rename PreviewGenerationMonitor

* Update production.rb

require master key

* Initialize AWS at application start

* Add fallbacks for credentials

* Add logging

* Create railway.toml
2025-01-18 11:46:41 -08:00
e3a44ca0d5
Implement embed images (#173)
* Add mini_magick and rufus-scheduler

* Expose attributes and add sigs to AwsService

* Get Party ready for preview state

* Added new fields for preview state and generated_at timestamp
* Add preview state enum to model
* Add preview_relevant_changes? after_commit hook

* Add jobs for generating and cleaning up party previews

* Add new endpoints to PartiesController

* `preview` shows the preview and queues it up for generation if it doesn't exist yet
* `regenerate_preview` allows the party owner to force regeneration of previews

* Schedule jobs

* Stalled jobs are checked every 5 minutes
* Failed jobs are retried every hour
* Old preview jobs are cleaned up daily

* Add the preview service

This is where the bulk of the work is. This service renders out the preview images bit by bit. Currently we render the party name, creator, job icon, and weapon grid.

This includes signatures and some fonts.
2025-01-18 09:08:15 -08:00
7ac5501da5
Update README.md (#171) 2025-01-18 03:25:40 -08:00