Skip to content

Build the dispatch title list on first use - #1135

Open
rajeswaripedaballi wants to merge 2 commits into
mainfrom
dispatch-titles
Open

rajeswaripedaballi wants to merge 2 commits into
mainfrom
dispatch-titles

Conversation

@rajeswaripedaballi

Copy link
Copy Markdown
Contributor

Sometimes the My interviews page shows the long file path of an interview, like docassemble.Package:data/questions/form.yml, instead of its title. The titles come from a list that sessions.py builds as soon as the file is loaded. Because the interview list endpoint is marked # pre-load, that now happens while the server is still starting up, before every/any package has loaded. So an interview that needs something from another package can fail to load right then, and its file name gets saved as the title and just stays that way.

Now the list is built the first time a title is needed, once the server is fully up. If an interview still fails, it gets tried again after a minute and the reason is logged. And if a title is just the file name, it gets skipped and the page uses its normal fallback name.

I tested it on my local and the titles show up right with nothing failing. The new tests are in test_sessions_dispatch.py.

@nonprofittechy

Copy link
Copy Markdown
Member

Updated this PR in commit 38bac6c to use the public interview_menu() output directly, removing the extra internal get_interview() calls and traceback handling.

  • The menu is still loaded lazily, avoiding startup-time title resolution.
  • Successful logged-in menu results are cached per process for 24 hours. Results containing dainterviewhaserror expire after 60 seconds and are retried on the next lookup.
  • Anonymous requests use their own uncached menu and neither read nor populate the shared cache. The shared cache intentionally assumes logged-in users have the same menu visibility.
  • Broken entries and filename-as-title values retain the readable filename fallback.

Reviewed with Claude via /simplify. Applied the useful review changes: refresh by replacing the cached list rather than mutating it, and isolate the mocked clock to the sessions module in tests.

Validation: all 33 targeted session and dispatch-cache tests passed; git diff --check passed.

This branch has not been deployed

No deployments
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.

2 participants