ElixirTeSS / TeSS

Training e-Support Service using Ruby on Rails.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactor "suggestions"/autocomplete

fbacall opened this issue · comments

Suggestions for "keywords" etc. are currently sourced from a text file.

This file is appended to when a new keyword is added to a resource. Suggestions are never removed from the file.

When suggestions are needed, the entire file is loaded into an array - which is slow.

Additionally, the entire array is dumped as JSON on the page, and autocomplete is done using that, which bloats the page size.

Some improvements could be made without too much refactoring:

  • Add a rake task to rebuild the suggestions text files using current data.
  • Store the suggestions in memory, in a format more suited for autocomplete (some kind of trie structure).
  • Look up suggestions dynamically via an AJAX request rather than embedding them on the page.