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

feat: add an aggregated velocity statistics table #24

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Add materialized view siri_agg_velocity_stats

Revision ID: 589113bd8e5e
Revises: eb501cf9f471
Create Date: 2024-12-16 18:05:19.088109+00:00

"""
from alembic import op
import sqlalchemy as sa


import open_bus_stride_db


# revision identifiers, used by Alembic.
revision = '589113bd8e5e'
down_revision = 'eb501cf9f471'
branch_labels = None
depends_on = None


def upgrade():
op.create_table('siri_agg_velocity_stats',
sa.Column('lon_round', sa.Float(), nullable=False),
sa.Column('lat_round', sa.Float(), nullable=False),
sa.Column('date', sa.Date(), nullable=False),
sa.Column('stddev_hourly_avg', sa.Float(), nullable=True),
sa.Column('avg_hourly_avg', sa.Float(), nullable=True),
sa.Column('sample_number', sa.Integer(), nullable=True),
sa.Column('median_hourly_avg', sa.Float(), nullable=True),
sa.Column('last_used', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('lon_round', 'lat_round', 'date')
)
op.create_index(op.f('ix_siri_agg_velocity_stats_date'), 'siri_agg_velocity_stats', ['date'], unique=False)
op.create_index(op.f('ix_siri_agg_velocity_stats_lon_round_lat_round'), 'siri_agg_velocity_stats', ['lon_round', 'lat_round'], unique=False)
op.create_index(op.f('ix_siri_agg_velocity_stats_last_used'), 'siri_agg_velocity_stats', ['last_used'], unique=False)

def downgrade():
op.drop_table('siri_agg_velocity_stats')
pass
Binary file modified dbschema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.