Add a RepositorySearchScore table and calculation to the RAC worker

This will be used in a followup PR to order search results instead of the RAC join. Currently, the join with the RAC table in search results in a lookup of ~600K rows, which causes searching to take ~6s. This PR denormalizes the data we need, as well as allowing us to score based on a wider band (6 months vs the current 1 week).
This commit is contained in:
Joseph Schorr 2017-03-17 13:51:45 -04:00
parent 1bfca871ec
commit df3f47c79a
10 changed files with 243 additions and 50 deletions

View file

@ -0,0 +1,35 @@
"""Add RepositorySearchScore table
Revision ID: f30984525c86
Revises: be8d1c402ce0
Create Date: 2017-04-04 14:30:13.270728
"""
# revision identifiers, used by Alembic.
revision = 'f30984525c86'
down_revision = 'be8d1c402ce0'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.create_table('repositorysearchscore',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('repository_id', sa.Integer(), nullable=False),
sa.Column('score', sa.BigInteger(), nullable=False),
sa.Column('last_updated', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], name=op.f('fk_repositorysearchscore_repository_id_repository')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_repositorysearchscore'))
)
op.create_index('repositorysearchscore_repository_id', 'repositorysearchscore', ['repository_id'], unique=True)
op.create_index('repositorysearchscore_score', 'repositorysearchscore', ['score'], unique=False)
### end Alembic commands ###
def downgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.drop_table('repositorysearchscore')
### end Alembic commands ###