Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching in dbops #7

Open
aelzenaar opened this issue Dec 6, 2018 · 0 comments
Open

Caching in dbops #7

aelzenaar opened this issue Dec 6, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@aelzenaar
Copy link
Owner

Code like this:

  if year == None:
    years = []
    for item in db:
      if not(item['ts_year'] in years):
        years.append(item['ts_year'])
    return sorted(years)

Belongs on tdwtf (does anyone still read that? :o). Iterating through every item in the database just to enumerate the possible values of 'ts_year' tags? Really? We need to cache this, and every place where this kind of pattern occurs, before my database gets too big.

Possible implementation: add an additional table in the database to store [years/months/whatever], add a command-line to update it manually (based on iterating the full db), and update it whenever we add/update an article (i.e. check whether the year attached to the article is in the table, if not add it).

@aelzenaar aelzenaar added the enhancement New feature or request label Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant