ispras / lingvodoc-react

Apache License 2.0
7 stars 11 forks source link

General backend refactoring before major Python 3.12 etc. update #1084

Open myrix opened 10 months ago

myrix commented 10 months ago

There are a number of things we should do about the current state of the backend, preferably before we'll commence #969 transition to Python 3.12 and general dependency update.

  1. Fully dropping anything related to solely previous v2 version, including v2 Scala-based web interface artifacts and v2 REST APIs which are superseded by the current GraphQL APIs.

  2. Removing Redis-based cache-through system #462, as agreed after discussing with Oleg. As experience shows, it does not actually improve performance while adding complexity we can do without.

    Perhaps after we transition to Python 3.12 and update dependencies, something better can be done, e.g. maybe based on or with SQLAlchemy's internal caching mechanisms.

    Probably needs a separate issue.

  3. Concurrently with everything else, general code cleanup, refactoring, legibility improvement.

    Probably needs a separate issue with detailed descriptions of preferred changes and practices. Right now we can mention following:

    a) Sort imports according to PEP 8 into standard library, external libraries and project import groups, and sort alphabetically in each group.

    b) Remove unused imports via checking with PyFlakes or other source analyzer.

    c) Use more concise and legible idioms for frequent operations such as getting objects from DB by id or creating GraphQL wrapper objects from DB objects.

    d) Use more Pythonic approach when dealing with DB, whenever possible just do what is required and catch any errors, relying on DB constraints, instead of first checking prerequisite conditions, like e.g. existence of other objects. Should also be more optimal with less DB requests.