Skip to content

Commit 3cec357

Browse files
authored
Merge pull request #1321 from RoboFinSystems/bugfix/extension-display-name
fix(graphs): return the extension display name instead of dropping it
2 parents 7a60968 + 5dcfdf6 commit 3cec357

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

‎robosystems/models/api/entity_graph.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ class EntityWithGraphResponse(BaseModel):
121121

122122
class AvailableExtension(BaseModel):
123123
name: str
124+
# The name to show a user. `name` is the schema slug the create path takes
125+
# ("roboledger"), which is not what a tier or extension picker should be
126+
# rendering — clients fall back to the slug only when this is absent.
127+
display_name: str | None = None
124128
description: str
125129
enabled: bool = False
126130

‎robosystems/routers/graphs/main.py‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@
5454
router = APIRouter(prefix="/v1/graphs", tags=["Graphs"])
5555

5656
# Surfaced to prospects at graph-creation time, so these describe only what is
57-
# built. Both are read twice below — the schema-loading path and its fallback —
58-
# and single-sourcing them here is what keeps the two copies from diverging.
57+
# built. All three are read twice below — the schema-loading path and its
58+
# fallback — and single-sourcing them here is what keeps the copies from
59+
# diverging.
60+
_DISPLAY_NAMES = {
61+
"roboledger": "RoboLedger - Accounting & Financial Reporting",
62+
"roboinvestor": "RoboInvestor - Investment Management",
63+
}
64+
5965
_ROBOLEDGER_DESCRIPTION = (
6066
"Complete accounting system with XBRL reporting and GL transactions. "
6167
"Context-aware: SEC repositories get reporting-only tables, "
@@ -538,12 +544,6 @@ async def get_available_extensions(
538544
f"Extension {ext_info['name']}: available={ext_info.get('available', False)}"
539545
)
540546
if ext_info["available"]:
541-
# Get display names for extensions
542-
display_names = {
543-
"roboledger": "RoboLedger - Accounting & Financial Reporting",
544-
"roboinvestor": "RoboInvestor - Investment Management",
545-
}
546-
547547
# Try to get actual node/relationship counts
548548
try:
549549
from robosystems.schemas.loader import (
@@ -577,7 +577,7 @@ async def get_available_extensions(
577577
available_extensions.append(
578578
{
579579
"name": ext_info["name"],
580-
"display_name": display_names.get(
580+
"display_name": _DISPLAY_NAMES.get(
581581
ext_info["name"], ext_info["name"].title()
582582
),
583583
"description": description, # Use the correctly set description
@@ -589,7 +589,10 @@ async def get_available_extensions(
589589
# Convert dictionaries to AvailableExtension objects
590590
extension_objects = [
591591
AvailableExtension(
592-
name=str(ext["name"]), description=str(ext["description"]), enabled=False
592+
name=str(ext["name"]),
593+
display_name=str(ext["display_name"]),
594+
description=str(ext["description"]),
595+
enabled=False,
593596
)
594597
for ext in available_extensions
595598
]
@@ -605,11 +608,13 @@ async def get_available_extensions(
605608
extensions=[
606609
AvailableExtension(
607610
name="roboledger",
611+
display_name=_DISPLAY_NAMES["roboledger"],
608612
description=_ROBOLEDGER_DESCRIPTION,
609613
enabled=False,
610614
),
611615
AvailableExtension(
612616
name="roboinvestor",
617+
display_name=_DISPLAY_NAMES["roboinvestor"],
613618
description=_ROBOINVESTOR_DESCRIPTION,
614619
enabled=False,
615620
),

‎tests/routers/graphs/test_schema_integration.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,19 @@ async def test_schema_compatibility_workflow(
360360
extensions = extensions_response.json()
361361
assert len(extensions["extensions"]) == 2
362362

363+
# `name` is the slug the create path takes; `display_name` is what a
364+
# picker renders. The display name used to be computed and then dropped
365+
# when the response model was built, leaving clients with "roboledger".
366+
by_name = {ext["name"]: ext for ext in extensions["extensions"]}
367+
assert (
368+
by_name["roboledger"]["display_name"]
369+
== "RoboLedger - Accounting & Financial Reporting"
370+
)
371+
assert (
372+
by_name["roboinvestor"]["display_name"]
373+
== "RoboInvestor - Investment Management"
374+
)
375+
363376
# Now create a schema that should be compatible with roboledger
364377
financial_schema = {
365378
"name": "custom_financial",

0 commit comments

Comments
 (0)