flask-track-usage icon indicating copy to clipboard operation
flask-track-usage copied to clipboard

[BUG] [Proposal] SQL hook has no attribute 'set_up'

Open Patataman opened this issue 2 years ago • 0 comments

SQL Hooks (and MongoHooks as far as I have seen) are splitted into 2 different methods:

def sumUrl_set_up(*args, **kwargs):
        tables = ["url_hourly", "url_daily", "url_monthly"]
        create_tables(tables, **kwargs)

def sumUrl(**kwargs):
    if not _check_environment(**kwargs):
        return
    if not _check_postgresql(**kwargs):
        raise NotImplementedError("Only PostgreSQL currently supported")
        return
    [...]

However in the Storage class method __init__ it is called as the following: https://github.com/ashcrow/flask-track-usage/blob/629ad1c285dc48e73ef17319b62379643a143221/src/flask_track_usage/storage/init.py#L66

Two solutions came to my mind:

  1. Change Storage.__init__ to call <hook>_set_up function instead.
  2. Change how hooks are created to be classes instead methods

Patataman avatar Apr 29 '22 08:04 Patataman