Skip to content

Conversation

@yamantaka-singh
Copy link

I just found some irregularities and scope for better indentation and readability, so my OCD triggered and Hence I tried to fix it!

chore: clean up and refactor listen.py for readability and robustness

  • Updated flatten_dict:

    • Changed default separator to "." for clearer nested key structure.
    • Fixed logic to avoid double separators.
    • Removed redundant list() call on .items().
  • Renamed convert_comma_seperated_string_to_listconvert_comma_separated_string_to_list:

    • Strips whitespace.
    • Skips empty values when splitting.
  • Refactored Listen class:

    • Simplified timestamp handling with isinstance() tuple check.
    • Safely flattened additional_info only if valid.
    • Replaced direct dict access with .get() to prevent KeyErrors.
    • Removed deletion of recording_msid (likely unintended bug).
  • Improved from_json and from_timescale:

    • Used loop to safely parse timestamps from available fields.
    • Safer key handling using .setdefault() and conditional checks.
  • General improvements:

    • Used f-strings throughout for clarity.
    • Added docstrings for all major methods.
    • Removed redundant and unused code.

Thank you, ~MJ

refactor: simplify and modernize Flask app factory
```

**Description:**

* Unified DB connection helpers into a single `_get_conn` with `LocalProxy`.
* Centralized teardown to close all DB connections per request.
* Streamlined config loading with Docker/consul retries and git version logging.
* Modernized app setup: cleaner debug, logging, and assignment expressions.
* Simplified Sentry, cache, and metrics initialization.
* Clean Jinja filter registration with dictionary update.
* Removed redundant code for better readability and maintainability.

---

This version is **short, clear, and easy to skim**, while still describing all the major changes.
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.

1 participant