Commit graph

487 commits

Author SHA1 Message Date
b1800f411f
Cleans up data on some Characters (#192)
This should update the `wiki_en` field for Kaguya, Fenie, and Uriel. It also adds `character_id` for 6 characters that were missing a value.
2025-03-01 07:31:49 -08:00
a6ede6ecf7
Merge pull request #191 from jedmund/jedmund/parallelize-downloaders
Parallelize downloaders and update sizes
2025-03-01 05:46:08 -08:00
e75578bea3 Refactor download_all_images task
This refactor focuses on implementing parallelization. This allows us to pass in a number of threads and download concurrently. This makes downloading lots of images a lot faster.
2025-03-01 05:43:57 -08:00
ffbc8d0c1e Add support for passing in a Logger 2025-03-01 05:43:05 -08:00
0d997d6ad5 Add new image sizes
* Weapons can now download the “raw”image size, which is the weapon art without a background
* Characters now download the “detail” image size, which is a horizontal crop of the character’s art
* Summons now download the “detail” image size, which is a horizontal crop of the summon’s art
* Summons also download “ls” and “m” instead of “party_main” and “party_sub”, as they match the aspect ratio of weapon sizes better, which should make our lives a lot easier.
2025-03-01 05:42:40 -08:00
5955ef2650 Add support for single sizes
You can now pass one of the sizes in to only download that size for the object.
2025-03-01 05:40:34 -08:00
ae62d594a8 Add parallel gem 2025-03-01 05:29:21 -08:00
82b3d0ed88
Merge pull request #190 from jedmund/jedmund/add-recruits
Adds recruits value to new weapons
2025-03-01 05:25:15 -08:00
e1d983a6d4 Adds recruits IDs to new weapons 2025-02-28 18:24:15 -08:00
4d3c1a800b
Update config files (#189)
* Update weapon series migration

This update fixes MigrateWeaponSeries from 20250218 such that it can be run on an empty database without throwing errors.

* Update .gitignore

Hide backups and logs directories, since we’ll be storing these in the project folder. Also hide mise’s .local directory.

* Change NewRelic log directory

Moved from log/ to logs/

* Add rake task for backing up/restoring prod db

* Rubocop fixes

* Fix error where :preview_state didn’t have an attribute

* Add supervisord ini

This uses my local paths, so we should try to abstract that away later.

* Ignore mise.toml
2025-02-27 23:13:57 -08:00
b2d2952b35
Fix limit column in weapon migration (#188)
* Update weapon series migration

This update fixes MigrateWeaponSeries from 20250218 such that it can be run on an empty database without throwing errors.

* Add items from late 2025-02

* Yuel (Grand)
* Tsukuyomi
* Sennen Goji
* Nightgaze Gale
* Bane of Avidya
* Klesha-Cleaning Dharmachakra

* Add default value for limit column
2025-02-27 20:41:51 -08:00
6bcbc97566
Jedmund/202502 update (#187)
* Update weapon series migration

This update fixes MigrateWeaponSeries from 20250218 such that it can be run on an empty database without throwing errors.

* Add items from late 2025-02

* Yuel (Grand)
* Tsukuyomi
* Sennen Goji
* Nightgaze Gale
* Bane of Avidya
* Klesha-Cleaning Dharmachakra
2025-02-27 20:27:43 -08:00
9827658771
Render the correct view when updating jobs (#186)
We were referencing an old view in `PartiesController#update_job`. This has been corrected.
2025-02-25 09:11:13 -05:00
505176ae5f
Update api URL (#185)
This change updates the production API URL to https://api.granblue.team/v1 instead of https://api.granblue.team/api/v1.
2025-02-25 08:23:47 -05:00
6db5faeb98
Add items from January/February 2025 (#184)
* Add new items

Items from:
- Unite and Fight (January 2025)
- Story Event (January 2025)
- Negima Collab (February 2025)
- January Flash Gala
- January Legend Festival
- February Flash Gala
- February character uncap

Data fixes for
- Chat Noir FLB (rarity was set to a bad value)
- End of year weapons (FLB date not set)

* Fix CSVs

* Fix data update rake task

* Add CSV require in BaseImporter
2025-02-24 16:09:30 -05:00
11db6674fc
fix migrator (#183)
- rename migration so it happens first
- postdeployment database migrator now migrates database and data migrations in chronological order
2025-02-18 01:47:23 -08:00
bb96593798
Update database_migrator.rb (#182)
Make database migrator run migrations in order
2025-02-18 01:12:15 -08:00
3cdd925162
Fix filters and add processors (#181)
* Update test csvs

* Fix count filters and refactor apply_filters

* Update party_querying_concern.rb

* +tests/-debug logs

* Make party association optional in Job

* Updates for weapon series

- Change to new series numbers
- Add static method for querying whether the weapon's element is changeable
- Add a new method to return a text slug for the weapon's series

* Add and update test data

- Updates canonical.rb for loading multiple types of data with multiple types of associations
- Adds test data for Guidebooks, Job Accessories, Job Skills, and Jobs
- Updates test data for Weapons and Summons

* Migrations

- Adds series of migrations for changing the weapon's series to the values used by Cygames
- Shuffled around some foreign keys

* Implement BaseProcessor

Processors are in charge of processing deck data straight from Granblue.

* Implement CharacterProcessor

Process character data from deck

* Implement WeaponProcessor

Process weapon data from deck

* Implement JobProcessor

Process job, job skill, and job accessory data from deck

* Implement SummonProcessor

Process summon data from deck

* Update SummonProcessor to work like the others

* ImportController should use processors

* Process element for changeable weapons
2025-02-17 23:51:50 -08:00
60f153a169
Users#info endpoint uses username instead of ID (#180) 2025-02-13 02:43:16 -08:00
a042847aab
Migrate to Query Builder (#179)
* Moved queries into PartyQueryBuilder service

PartyQueryBuilder supersedes PartyQueryingConcern as it is also used for UsersController (and is our fix for profiles being broken)

* Implement PartyQueryBuilder in controllers

* Update summon_transformer.rb

This should fix the transformer so that we properly capture summons and subaura summons

* Update parties_controller_spec.rb

* Add NewRelic license key

* Add Sentry

Why not?
2025-02-12 23:43:02 -08:00
d6300f7aeb
Add first round of tests (#178)
* Install Rspec

* Create .aidigestignore

* Update rails_helper

- Added sections and comments
- Add support for loading via canonical.rb
- Add FactoryBot syntax methods
- Disable SQL logging in test environment

* Move gems around

* Add canonical.rb and test env CSVs

We load these CSVs via canonical.rb when we run tests as a data source for canonical objects.

* Remove RBS for now

This is too much and we need to find the right solution

* Refactor GridSummonsController and add tests

* Create GridSummon factory

* Refactor GridSummon and add documentation and tests

* Create have_error_on.rb

* Update .aidigestignore

* Fix warnings

* Add GridWeapons and Parties factories

* Refactor GridWeapon and add documentation and tests

* Create .rubocop.yml

* Create no_weapon_provided_error.rb

* Refactor GridWeaponsController

- Refactors controller
- Adds YARD documentation
- Adds Rspec tests

* Refactor GridSummonsController

- Refactors controller
- Adds YARD documentation
- Adds Rspec tests

* Enable shoulda/matchers

* Update User factory

* Update party.rb

We moved updating the party's element and extra flag to inside the party. We use an after_commit hook to minimize the amount of queries we're running to do this.

* Update party.rb

We change setting the edit key to use the conditional assignment operator so that it doesn't get overridden when we're running tests. This shouldn't have an effect in production.

* Update api_controller.rb

Change render_unprocessable_entity_response to render the errors hash instead of the exception so that we get more helpful errors.

* Add new errors

Added NoCharacterProvidedError and NoSummonProvidedError

* Add tests and docs to GridCharacter

We added a factory, spec and documentation to the GridCharacter model

* Ensure numericality

* Move enums into GranblueEnums

We don't use these yet, but it gives us a structured place to pull them from.

* Refactor GridCharactersController

- Refactors controller
- Adds YARD documentation
- Adds Rspec tests

* Add debug hook and other small changes

* Update grid_characters_controller.rb

Removes logs

* Update .gitignore

* Update .aidigestignore

* Refactored PartiesController

- Split PartiesController into three concerns
- Implemented testing for PartiesController and two concerns
- Implemented fixes across other files to ensure PartiesController tests pass
- Added Favorites factory

* Implement SimpleCov

* Refactor Party model

- Refactors Party model
- Adds tests
- Adds documentation

* Update granblue_enums.rb

Remove included block
2025-02-12 02:42:30 -08:00
6cf11e6517
Jedmund/fix image embeds 4 (#177)
* Update gitignore

There is a mystery postgres folder and we are going to ignore it

* Add migrations

* Update preview state default to pending
* Adds indexes
* Adds PgHero and PgStatements

* Update .gitignore

* Update Gemfile

Production:
- `newrelic_rpm`

Development:
- `pg_query`
- `prosopite`

* Configure Sidekiq

Create job for cleaning up party previews

* Configure Prosopite and remove CacheFreeLogger

* Enable query logging

* Update api_controller.rb

Add N+1 detectioin via Prosopite in development/test environments

* Refactor canonical object blueprints

* Refactor grid object blueprints

* Remove N+1 from grid object models

Reimplementing `character` `summon` and `weapon` was making N+1s which made queries really slow

* Add counter caches to party

* 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?`

* Add cache to is_favorited(user)

* Refactored PartyBlueprint to minimize N+1s

* Remove preview expiry constants

These are defined in the Coordinator instead

* Add method comments

* Create parties_controller.rbs

* Update logic and logs

* Updates excluded methods and calculate_count

* Use `includes` instead of `joins`
* Use a less-insane way of counting

* Adds a helper method for party privacy

* Update filter condition helpers

Just minor refactoring

* Fix old view name in PartyBlueprint

* Refactor parties#create

* Remove redundant return

* Update parties_controller.rbs

* Update parties#index

* Update parties_controller.rb

Updates apply_includes and apply_excludes, along with modifying id_to_table and build_query

* Update parties_controller.rb

Adds the rest of the changes, too tired to write them all out. Some preview generation, some filtering

* 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

* Alias table name to object to maintain API consistency

* Maintain API consistency with raid blueprint

* 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.

* 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.

* Update raid blueprints

- Show flat representation of raid group in RaidBlueprint's nested view
- Show nested representation of raid in RaidGroupBlueprint's full view

* Move n+1 detection to around_action hook

* 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.

* Eager-load jobs when querying job skills

* Eager load raids/groups when querying

* Update users_controller.rb

More efficient way of denoting favorited parties.

* Update awakening.rb

- Removes explicitly defined associations and adds ActiveRecord associations instead

* Update party.rb

- Removes favorited accessor
- Renames derivative_parties to remixes and adds in-built sort

* Update weapon_awakening.rb

- Removes redefined explicit associations

* Update grid_character.rb

- Adds code transforming incoming ring and awakening values into something the db understands

* Update character.rb

Add explicit Awakenings enum

* Update coordinator.rb

Adds 'queued' as a state for generation
2025-02-09 22:50:18 -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
a5ad22b9c1
Create LICENSE (#172) 2025-01-18 03:25:32 -08:00
8708343b65
Create ENDPOINTS.md (#169) 2025-01-18 03:22:55 -08:00
d8cea9fd94
Update README.md (#170) 2025-01-18 03:22:34 -08:00
7d164b540c
Adds documentation to some lib functions (#168)
* Add sigs and docs to transformers

* Add sigs and docs to downloaders

* Adds sigs and docs to importers
2025-01-18 03:09:29 -08:00
0d5d4d5f59
Jedmund/import (#167)
* Move app/helpers/granblue_wiki to lib/parsers/wiki

This clears up the namespace beginning with "Granblue"

* Removed some top-level Granblue libs

DataImporter and DownloadManager exist inside of the PostDeployment namespace now so these files are redundant

* Fix Downloaders namespace

Our namespace was singular Downloader, now it is plural Downloaders to match the folder name

* Fix import paths

* DownloadManager was moved to downloaders/
* import_data task now uses the PostDeployment version of DataImporter

* Update application.rb

Eager-Load/Autoload the lib/ folder

* Update cors.rb

Add Granblue website and Extension ID to CORS

* Add transformers

Transformers take raw data from Granblue Fantasy and transforms them into hensei-compatible JSON. Transformers heavily borrow from vazkii/hensei-transfer.

* Add ImportController and route

This adds the controller that handles creating a full party from transformed Granblue Fantasy data
2025-01-17 12:02:12 -08:00
97d811cc29
Update PULL_REQUEST_TEMPLATE.md (#166)
Remove double quotes
2025-01-16 00:34:58 -08:00
6a60b605b6
Fix issue with migrations in Rails 8 (#165) 2025-01-16 00:34:13 -08:00
bde8dffaa2
Update PR templates again (#164) 2025-01-15 21:52:20 -08:00
7b74105e63
Updates to Ruby 3.3.7 (#163)
* Update .ruby-version and Gemfile

* Update .ruby-gemset

* Update Gemfile.lock
2025-01-15 21:31:49 -08:00
d75e4a8448
Downloader fixes (#162)
* Fix summon data

* Update logic for downloaders

These are responsible for downloading variants (01, 02, etc)

* Update puts statement

* Simplify ImageDownloader

* Simplify DownloadManager
2025-01-15 19:15:58 -08:00
fa386511e1
Some final post-deploy fixes (#161)
* Fix track_record error

* Add newlines

* Update PR templates
2025-01-15 18:06:20 -08:00
52f213d4cb
Update importer (#160)
* Importer now displays validation errors

This will help people debug errors before submitting their PR.

* Fix errors in the outstanding updates
2025-01-15 17:46:14 -08:00
0fd3f0f801
Importer should no longer look for recruits_id (#159) 2025-01-15 16:21:10 -08:00
aac629debc
Update recruits_id to recruits (#158) 2025-01-15 16:13:05 -08:00
b454ce2785
Update 20250113-summons-002.csv (#157) 2025-01-15 16:04:32 -08:00
a8ca474e4c
Add second batch of new items to database (#153)
* Adds more new items to the database

* Updates to older migrations

These were manually updated in the database

* Adds more new items to the database

* Fixes misclassification of Grand Weapons

* Add the final new items

* Delete 20250115-summons-003.csv

* Updates weapons with granblue_id reference to Characters

* Remove extra empty lines

* Adds Orologia summon

* Modify deployment manager

Use - to make it easier to copy paste into Github PR
2025-01-15 15:57:47 -08:00
1ffd96633b
Try to fix data migration error in post-deploy script (#156) 2025-01-15 15:35:13 -08:00
d71b78e5f8
Update post-deploy script and Rails credentials (#155)
* Fresh credentials.yml.enc

* Update .ruby-gemset

* Made PostDeploymentManager modular

We broke PostDeploymentManager out into several files to make it easier to maintain.

We also added a "force" mode that forces the script to consider all CSV files. This is useful for testing the post-deploy script itself. This should only be used in test mode or you will dirty your database.

We also fine tuned some of the logging to make sure that both verbose and non-verbose modes are helpful.
2025-01-15 14:56:38 -08:00
0d46cb3833
Link Character and Weapon tables with granblue_id (#154)
* Add recruits column to weapons

* Populate recruits column with granblue_ids

* Remove recruits_id and index recruits
2025-01-15 02:11:06 -08:00
386515cd18
Rename data_update_request_template.md to pull_request_template.md (#152) 2025-01-15 01:28:56 -08:00
df7454af4e
Add migration to post-deploy script (#151) 2025-01-13 06:36:01 -08:00
1d6dff18de
Add the first batch of new items (#149) 2025-01-13 06:12:56 -08:00
a03b1bfe20
Create data_update_request_template.md (#150) 2025-01-13 05:54:09 -08:00