Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • lava lava
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 64
    • Merge requests 64
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • lava
  • lavalava
  • Merge requests
  • !2009

Merged
Created Feb 28, 2023 by Igor Ponomarev@igo95862Contributor

Introduce annotate_int_field_verbose function

  • Overview 0
  • Commits 1
  • Changes 2

It will be used to convert the int field values to the verbose names.

Example:

Device.health -> 4 -> "Maintenance"

Usuallt the get_FOO_display can be used to get the verbose name but that requires fetching the entire model which is not available when values() or values_list() is used.

Instead the When-Case-Values construct can be used to annotate with verbose name the values on the database. The annotate_int_field_verbose will create those annotations using the Django field metadata.

This technique was already used in 2be1e2b2 but is now in a separate function and can be applied to other tables.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: lava-server-dbutils-annotate-int-field-verbose