You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ponymail.apache.org by "rbowen (via GitHub)" <gi...@apache.org> on 2026/07/07 16:42:55 UTC

Re: [I] Document magic numbers [incubator-ponymail-foal]

rbowen commented on issue #36:
URL: https://github.com/apache/incubator-ponymail-foal/issues/36#issuecomment-4906161119

   Here's an inventory of magic numbers in the codebase that should be extracted as named constants and/or made configurable:
   
   ## Server-side (Python)
   
   | File | Value | Code | Purpose |
   |------|-------|------|---------|
   | `server/plugins/messages.py:175` | `250` | `counter > 250` | Max thread depth when constructing email threads |
   | `server/plugins/messages.py:288` | `250` | `size=250` | Max emails to fetch in a single thread query |
   | `server/endpoints/stats.py` | `10` | `all_authors[:10]` | Top N authors shown in stats response |
   | `tools/import-mbox.py:436` | `40` | `len(ja) >= 40` | Unclear — max length check during import |
   | `tools/migrate.py:149` | `200` | `len(bulk_array) >= 200` | Bulk indexing batch size |
   | `tools/migrate.py:95` | `1000` | `processed - ... >= 1000` | Progress report interval |
   | `tools/plugins/elastic.py:170` | `100` | `size=100` | Default ES scroll batch size |
   | `tools/plugins/elastic.py:170` | `"3m"` | `scroll="3m"` | ES scroll keepalive duration |
   
   ## Frontend (JavaScript)
   
   | File | Value | Code | Purpose |
   |------|-------|------|---------|
   | `webui/js/source/sidebar-stats.js` | `5` | `if (i >= 5)` | Max participants shown in sidebar |
   | `webui/js/source/sidebar-stats.js` | `24` | `par.name.length > 24` | Max author name display length before truncation |
   | `webui/js/source/body-fixups.js:90` | `250` | `urls > 250` | Max URLs to linkify per email |
   | `webui/js/source/body-fixups.js:199` | `25` | `diffs > 25` | Max diff blocks to syntax-highlight |
   | `webui/js/source/body-fixups.js:252` | `50` | `quotes > 50` | Max quoted blocks to style |
   | `webui/js/source/construct-thread.js:58` | `700` | `mw < 700` | Mobile breakpoint width (px) |
   | `webui/js/source/key-commands.js:196` | `20` | `len < 20` | Min message count for keyboard nav |
   | `webui/js/source/listview-threaded.js:211` | `86400000` | `now - date < 86400000` | 24h in ms — "today" threshold |
   | `webui/js/source/listview-flat.js:145` | `86400000` | `now - date < 86400000` | 24h in ms — "today" threshold |
   | `webui/js/source/sidebar-calendar.js:108` | `1000` | `count >= 1000` | Threshold for displaying "1000+" |
   | `webui/js/source/primer.js:242` | `15` | `mid.length == 15` | Legacy shortened message ID length |
   
   ## Config defaults (in `tools/setup.py`)
   
   These are documented in the generated YAML but hardcoded in setup.py:
   
   | Value | Config key | Purpose |
   |-------|-----------|---------|
   | `8080` | `port` | Default server port |
   | `15000` | `max_hits` | Max emails to process in a search |
   | `15` | `pool_size` | ES connection pool size |
   | `8192` | `max_lists` | Max number of mailing lists |
   | `150` | `refresh_rate` | Background indexer interval (seconds) |
   
   ## Already documented as constants ✓
   
   These are already extracted — no action needed:
   - `server/plugins/messages.py`: `OLD_SHORTENED_ID_LENGTH = 18`, `SHORT_BODY_MAX_LEN = 200`
   - `server/endpoints/gravatar.py`: `CACHE_LIMIT = 25000`
   - `server/plugins/session.py`: `FOAL_SAVE_SESSION_INTERVAL = 3600`
   - `tools/archiver.py`: `SHORT_BODY_MAX_LEN = 200`
   
   ---
   
   **Suggested approach:** The frontend values (particularly the arbitrary limits like 5, 24, 250, 25, 50) could be extracted into `webui/js/source/aavariables.js` where other globals live. The server-side values could become module-level constants with docstrings.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ponymail.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org