Commit graph

31 commits

Author SHA1 Message Date
07f23e2b74 add /users/me settings endpoint 2025-12-14 01:23:37 -08:00
860177c0a4 add show_gamertag to user 2025-12-13 20:09:52 -08:00
32bc9f5872 fix /users/me endpoint to use current_user 2025-12-02 06:54:12 -08:00
07e5488e0b Add custom page size support via X-Per-Page header
- Add page_size helper method to read from X-Per-Page header
- Set min (1) and max (100) bounds for page sizes
- Update all paginated endpoints to use dynamic page size
- Maintain backward compatibility with default sizes
2025-09-17 05:44:14 -07: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
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
8381c668bc
Implement roles and visibility (#128)
* Add migrations to add user roles and party visibility.

* Update schema.rb

* Add admin check in User model

* Implement rudimentary visibility of teams

* Adds checks to Party model
* Hides parties from collection views depending on visibility
* Disallows viewing private parties if you're not the owner

* Add a party's visibility to blueprint

* Add admin mode

The API Controller checks if the user is logged in and whether they are an admin, and checks for the X-Admin-Mode header

* Implement admin mode overrides

* Add admin_mode to authorize

* Note to self: Implement user editing by admins

* Fix syntax error with equality in SQL

* Fix syntax error with method name

* Fix bug in who can see restricted parties

* Add privacy control to user profiles
2023-08-25 15:53:56 -07:00
13a9644bb0
(Hotfix) Fixes a variety of small bugs (#115)
* Remove ap call

* Fix remix render method

* Downcase username on db end

There was a bug where users with capital letters in their name could not access their profiles after we tried to make things case insensitive.

* Remove ap call and unused code
2023-07-04 03:21:02 -07:00
78b5b063fc
Deploy July Quality Update (#114)
* Remove print statements from data migration

* (Hotfix) Fix data migration failing due to nil

* Fix stale migration errors

* Ensure new characters have Awakenings

Every character starts with Balanced Lv1 awakening

* Ensure weapons without awakenings do not expose key

* Updates database seeds (#109)

* Destroy favorites when a party is deleted

* Allow users to delete parties with remixes (#111)

There was a bug that prevented users from deleting parties with remixes, because the source party reference was not being nulled.

We fixed that with `dependent: :nullify` but also added a boolean key to the parties database to track if a party is a remix or not. This way, if a party is flagged as a remix but the source party is null, we know that the original party was deleted and can message this on the frontend.

* Fix deleting grid summons (#112)

A bad decision to try to reduce code in `set` made this fail with a 422 because `summon_params` was being tested against but... didn't exist? was nil?

I fixed it by not using `set` before calling `destroy`, and just finding the summon in the `destroy` method itself

* Usernames in URLs should not be case-sensitive (#113)

Amateur hour mistake

* Change default filters in users controller
2023-07-04 00:40:06 -07:00
6e81ffc7dd
Implements advanced filters (#90) (#91)
* Add advanced filters

Adds new filters to search:

* Full auto
* Charge attack
* Auto guard
* Number of weapons (user-selectable now)
* Number of summons
* Number of characters
* Maximum number of turns
* Maximum number of buttons
* Maximum clear time
* User quality (No anonymous users)
* Name quality (No untitled teams)
* Remixes (Only show original teams)

* Update advanced filter params

* Add default to party counter cache
2023-04-09 19:40:41 -07:00
06f8d28874
February 2023 Update (#48) 2023-02-04 23:46:12 -08:00
1752081f3f Output theme 2022-12-25 20:17:20 -08:00
574d8e0b3e Normalize constants in ApiController 2022-12-23 19:08:36 -08:00
b7a537f540 Fix token generation on signup 2022-12-22 21:27:38 -08:00
e91e1664a6 Update blueprint for availability endpoints 2022-12-22 18:12:34 -08:00
c5391a6683 Fix bug where now wasn't replaced 2022-12-22 00:44:39 -08:00
5c97488a20 Update UsersController to use blueprinter 2022-12-21 23:13:19 -08:00
c1716c1e4f Run RuboCop on everything
yolo
2022-12-21 00:22:47 -08:00
ba632af5e7 Add gender to user database 2022-04-10 13:25:57 -07:00
5d45b8898e Add favorites to parties 2022-03-21 03:53:59 -07:00
1f3ba2307f Add pagination for collections 2022-03-14 19:42:29 -07:00
49e4a02150 Add update and info method on User 2022-03-04 05:14:36 -08:00
c7d53d4ffd Remove print log 2022-03-01 12:51:11 -08:00
d5ed98f0cf Implement filters on profiles 2022-03-01 02:19:44 -08:00
86640d5986 Remove log 2022-02-27 22:28:42 -08:00
e97afb72bc Update users_controller.rb 2020-09-25 17:57:32 -07:00
71a0a090ba Add route for viewing a profile 2020-09-25 14:59:50 -07:00
12a98d4abd Update UsersController
Adds registration, check_email, and check_username methods
2020-09-25 10:53:56 -07:00
071f6b4664 Controllers should inherit from ApiController 2020-09-19 12:46:24 -07:00
f616fe23db Restart on Rails 2020-09-14 18:30:54 -07:00