Skip to content

Commit

Permalink
Merge pull request #403 from tillywoodfield/401-performance
Browse files Browse the repository at this point in the history
Add indexes to `log` table in database
  • Loading branch information
tillywoodfield authored Apr 17, 2024
2 parents b68d5fd + 713cc6e commit ab0a10b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 0 additions & 1 deletion iati_datastore/iatilib/codelists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def codelist_with_translations(clname, major_version):
except IOError as exc:
warnings.warn(str(exc))
enums = {ident(codes[code]['en']): (code, codes[code]['en'], {lang: codes[code][lang] for lang in codes[code]}) for code in codes}
print(enums)
return enums

by_major_version = {}
Expand Down
4 changes: 2 additions & 2 deletions iati_datastore/iatilib/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ class Log(db.Model):
__tablename__ = 'log'
id = sa.Column(sa.Integer, primary_key=True)
dataset = sa.Column(sa.String)
resource = sa.Column(sa.String)
logger = sa.Column(sa.String) # the name of the logger. (e.g. myapp.views)
resource = sa.Column(sa.String, index=True)
logger = sa.Column(sa.String, index=True) # the name of the logger. (e.g. myapp.views)
level = sa.Column(sa.String) # info, debug, or error?
trace = sa.Column(sa.String) # the full traceback printout
msg = sa.Column(sa.String) # any custom log you may have included
Expand Down
30 changes: 30 additions & 0 deletions migrations/versions/cd81311bb68b_add_log_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Add log indexes
Revision ID: cd81311bb68b
Revises: 864375812164
Create Date: 2024-04-12 13:51:24.890197
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cd81311bb68b'
down_revision = '864375812164'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_log_logger'), 'log', ['logger'], unique=False)
op.create_index(op.f('ix_log_resource'), 'log', ['resource'], unique=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_log_resource'), table_name='log')
op.drop_index(op.f('ix_log_logger'), table_name='log')
# ### end Alembic commands ###

0 comments on commit ab0a10b

Please sign in to comment.