Skip to content

[QA / FEATURE] Consolide CR fields into single "challenge_rating" field#910

Merged
calumbell merged 1 commit into
open5e:stagingfrom
calumbell:902/cr-name-change
Apr 12, 2026
Merged

[QA / FEATURE] Consolide CR fields into single "challenge_rating" field#910
calumbell merged 1 commit into
open5e:stagingfrom
calumbell:902/cr-name-change

Conversation

@calumbell
Copy link
Copy Markdown
Contributor

@calumbell calumbell commented Apr 9, 2026

Description

This PR slightly streamlines the Creature model by replacing the "challenge_rating_decimal" and "challenge_rating_text" fields with a single "challenge_rating" field.

The motivation for this was to improve the developer experience working when working with these fields, although one could argue that there are marginal performance gains to be made here.

N.B. This will break the front-end unless it is also patched to consume the "challenge_rating" field. A PR is on its way that will fix this.

Related Issue

Closes #902

How was this tested?

  • Spot checked on local Django development server
  • pytest on local (all testing passing after updating cases to reflect changes in API response)
  • CI/CD passing

@eepMoody
Copy link
Copy Markdown
Collaborator

So I do think we split these on purpose, so we could use one for sorting and another for display, if I recall.

Are we thinking it makes sense to roll it back at this point? Should we maybe synthesize one from the other or set one of them as "challenge_rating" for ease of use?

@calumbell
Copy link
Copy Markdown
Contributor Author

calumbell commented Apr 11, 2026

@eepMoody Not sure I was privy to the conversations about adding two fields to handle CR, so apologies if I have run rough-shod someone else's careful planning. But to me it makes sense to only use one field to handle CR, especially as the only difference between the data presented in "challenge_rating_decimal" and "challenge_rating_text" is that 0.5, 0.25 and 0.125 are parsed as 1/2, 1/4 and 1/8.

The reasons I think we should roll it back are:

  • Separation of concerns. The only difference between the two CR fields is formatting 0.5, 0.25 and 0.125 as fractions. Formatting ought to be handled on the front-end, with the API presenting the data as it is. Adding API bloat instead of using a three row look-up table on the front-end has the whiff of smelly code.
  • Rubbish field names. "challenge_rating" is good, intuitive name for this field. The "_text" and "_decimal" postfixes torpedo this.
  • Single source of truth. In my experience, debugging front-end code that mixes "challenge_rating_decimal" and "challenge_rating_text" fields is considerably more time-consuming than debugging code that uses the decimal representation and calls the parseChallengeRating() helper function inline to generate the textual representation inside our templates.

That is my thinking. The only hill that I die on is that the numerical CR data should live in a field called "challenge_rating", not "challenge_rating_decimal", and that we should do away with the some of the excessive trailing zeroes.

Let me know your thoughts, happy to make any additional changes required :)

@eepMoody
Copy link
Copy Markdown
Collaborator

Okay yeah, that seems reasonable. I guess we just over-engineered the CR stuff. And yeah, no need for excess trailing zeroes, nobody is tracking CR to three significant digits 🤣

@calumbell calumbell merged commit 68ae9cb into open5e:staging Apr 12, 2026
3 checks passed
Copilot AI mentioned this pull request Apr 14, 2026
3 tasks
eepMoody added a commit that referenced this pull request Apr 15, 2026
* fixed parsing reaction conditions without parentheses (#842)

* Fix spell data regressions and omissions (#844)

* Fix spell data regressions from PR #842 and update newrelic API

* add missing higher-leve options

* add tests for duplicate or missing higher_level values

* Add missing casting options for deepm and spells-that-dont-suck

* fix freezing sphere being merged with freedom of movement

* Convert distance fields to integer (#845)

* Fix spell data regressions from PR #842 and update newrelic API

* add missing higher-leve options

* add tests for duplicate or missing higher_level values

* Add missing casting options for deepm and spells-that-dont-suck

* fix freezing sphere being merged with freedom of movement

* convert ambiguously precise fields to integers

* update test cases to reflect integers

* update decimal speed fallbacks

* fixed bugs in srd-2024 CreatureAction data (closes #847) (#849)

* fixed markdown errors in Creature spellcasting traits/actions (#855)

* updated srd-2014 dragon breath weapon recharge data (closes #848) (#853)

* removed prepended asterisks from toh/tdcs FeatBenefit 'desc' fields (closes #851) (#852)

* fixed bugs in srd-2024 spell markdown (closes #857)

* updated monster conversion script to scrap input md for bonus actions and reactions

* added missing srd-2024 creature reactions

* removed Mithral and Adamantine Hide Armor from srd-2014 dataset (closes #829)

* bugfix: added missing dash to bfrd mechanist starting equipment markdown

* added 2024 champion subclass data to ClassFeatureItem.json

* added srd-2024 College of Lore data to ClassFeatureItem.json

* replaced casting_times of 'bonus_action' w/ 'bonus-action' as per model spec

* wrote exclude_fields_mixin (and mvd mixins to own dir)

* added ExcludeFieldsMixin to model viewsets

* added missing srd-2024 dragon attack data to CreatureAttackAction

* removed /manifest from url, updated test cases to reflect rmvl

* rmv'd ManifestViewSet

* removed ManifestSerializer

* removed Manifest model

* rmv'd manifest from v1 API schema

* removed /version endpoint

* added character creation rules from srd-2024 (#878)

* Added filter on monsters for environments (#884)

* fixed typo in srd-2024 Adult Green Dragon spellcasting action (#891)

* [BUGFIX] Fixed data errors on `/v2/rulesets/srd_combat-sequence` (#893)

* removed references to <srd:opportunity-attacks> in all open5e data

* fixed ruleset/srd_combat-sequence blockquote markdown

* added missing ClassFeatureItem for Fighter two extra attacks action (#895)

* removed server/vector_index.pkl from repo (#883)

* removed leading slashes on Image file_urls (#886)

* [CI/CD] Upgrade Github Action versions to Node 24 compatable versions (#901)

* updated checkout github action to v6

* updated setup-python gh action to v6

* updated upload-artifact gh action to v6

* updated build-push-action gh action to v7

* Feature: split V2 Item model into Item and MagicItem models (#889)

* split v2 Item endpoint into Item and MagicItem endpoints

* removed vector_index from commit

* rmv'd accidently commited DDT config

* updated buggy test case, see issue #888

* [BUGFIX] `GameContentSerializer` now inherits from `ModelSerializer` (#899)

* GameContentSerializer now inherits from ModelSerializer

* removed 'url' from GameContent Meta->fields prop

* updated v2 tests to reflect removal of URL from many responses

* fixed failing test

* rmvd url field from MagicItemSerializer

* Bugfix: seperated mixed up V1/V2 endpoints (#890)

* updated api/urls.py to stop v1 and v2 endpoints getting mixed up

* updated v1 tests to check against endpoints behind /v1/ subroute

* [BUGFIX] Fixed EagerLoadingMixin early return error (#898)

* fixed bug in EagerLoadingMixin conditional logic, closes #897

* fixed EagerLoadingMixin missing base case, added docstring

* Bump django from 5.2.1 to 5.2.12 (#904)

Bumps [django](https://github.com/django/django) from 5.2.1 to 5.2.12.
- [Commits](django/django@5.2.1...5.2.12)

---
updated-dependencies:
- dependency-name: django
  dependency-version: 5.2.12
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump requests from 2.32.3 to 2.33.0 (#905)

Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.33.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.32.3...v2.33.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.33.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump urllib3 from 2.4.0 to 2.6.3 (#906)

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.4.0 to 2.6.3.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.4.0...2.6.3)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.6.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump django from 5.2.12 to 5.2.13 (#908)

Bumps [django](https://github.com/django/django) from 5.2.12 to 5.2.13.
- [Commits](django/django@5.2.12...5.2.13)

---
updated-dependencies:
- dependency-name: django
  dependency-version: 5.2.13
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fixed bug in srd-2014 skeleton resistances/immunities (#907)

* fixed markdown bugs in srd-2014 brass dragons (#912)

* updated srd-2024 goliath giant ancestry markdown: added missing list bullets (#909)

* consolidated CRs into single 'challenge_rating' field (#910)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Blake Watson <blake@blakewatson.com>
Co-authored-by: calum <47755775+calumbell@users.noreply.github.com>
Co-authored-by: calumbell <calumabell@googlemail.com>
Co-authored-by: August Johnson <augustjohnson@users.noreply.github.com>
Co-authored-by: Steven Noto <stevennoto@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT REQ] Consolidate challenge_rating_text and challenge_rating_decimal into single field

2 participants