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

Create CANHistory endpoint #3277

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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,73 @@
"""Adding new table for CANHistory

Revision ID: 98a16d1ef6be
Revises: 6615ac7d4eea
Create Date: 2025-01-07 22:08:04.671935+00:00

"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '98a16d1ef6be'
down_revision: Union[str, None] = '6615ac7d4eea'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
sa.Enum('CAN_DATA_IMPORT', 'CAN_NICKNAME_EDITED', 'CAN_DESCRIPTION_EDITED', 'CAN_FUNDING_CREATED', 'CAN_RECEIVED_CREATED', 'CAN_FUNDING_EDITED', 'CAN_RECEIVED_EDITED', 'CAN_FUNDING_DELETED', 'CAN_RECEIVED_DELETED', 'CAN_PORTFOLIO_CREATED', 'CAN_PORTFOLIO_DELETED', 'CAN_PORTFOLIO_EDITED', 'CAN_DIVISION_CREATED', 'CAN_DIVISION_DELETED', 'CAN_DIVISION_EDITED', 'CAN_CARRY_FORWARD_CALCULATED', name='canhistorytype').create(op.get_bind())
op.create_table('can_history_version',
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
sa.Column('can_id', sa.Integer(), autoincrement=False, nullable=True),
sa.Column('ops_event_id', sa.Integer(), autoincrement=False, nullable=True),
sa.Column('history_title', sa.String(), autoincrement=False, nullable=True),
sa.Column('history_message', sa.Text(), autoincrement=False, nullable=True),
sa.Column('timestamp', sa.String(), autoincrement=False, nullable=True),
sa.Column('history_type', postgresql.ENUM('CAN_DATA_IMPORT', 'CAN_NICKNAME_EDITED', 'CAN_DESCRIPTION_EDITED', 'CAN_FUNDING_CREATED', 'CAN_RECEIVED_CREATED', 'CAN_FUNDING_EDITED', 'CAN_RECEIVED_EDITED', 'CAN_FUNDING_DELETED', 'CAN_RECEIVED_DELETED', 'CAN_PORTFOLIO_CREATED', 'CAN_PORTFOLIO_DELETED', 'CAN_PORTFOLIO_EDITED', 'CAN_DIVISION_CREATED', 'CAN_DIVISION_DELETED', 'CAN_DIVISION_EDITED', 'CAN_CARRY_FORWARD_CALCULATED', name='canhistorytype', create_type=False), autoincrement=False, nullable=True),
sa.Column('created_by', sa.Integer(), autoincrement=False, nullable=True),
sa.Column('updated_by', sa.Integer(), autoincrement=False, nullable=True),
sa.Column('created_on', sa.DateTime(), autoincrement=False, nullable=True),
sa.Column('updated_on', sa.DateTime(), autoincrement=False, nullable=True),
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
sa.Column('operation_type', sa.SmallInteger(), nullable=False),
sa.PrimaryKeyConstraint('id', 'transaction_id')
)
op.create_index(op.f('ix_can_history_version_end_transaction_id'), 'can_history_version', ['end_transaction_id'], unique=False)
op.create_index(op.f('ix_can_history_version_operation_type'), 'can_history_version', ['operation_type'], unique=False)
op.create_index(op.f('ix_can_history_version_transaction_id'), 'can_history_version', ['transaction_id'], unique=False)
op.create_table('can_history',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('can_id', sa.Integer(), nullable=False),
sa.Column('ops_event_id', sa.Integer(), nullable=False),
sa.Column('history_title', sa.String(), nullable=False),
sa.Column('history_message', sa.Text(), nullable=False),
sa.Column('timestamp', sa.String(), nullable=False),
sa.Column('history_type', postgresql.ENUM('CAN_DATA_IMPORT', 'CAN_NICKNAME_EDITED', 'CAN_DESCRIPTION_EDITED', 'CAN_FUNDING_CREATED', 'CAN_RECEIVED_CREATED', 'CAN_FUNDING_EDITED', 'CAN_RECEIVED_EDITED', 'CAN_FUNDING_DELETED', 'CAN_RECEIVED_DELETED', 'CAN_PORTFOLIO_CREATED', 'CAN_PORTFOLIO_DELETED', 'CAN_PORTFOLIO_EDITED', 'CAN_DIVISION_CREATED', 'CAN_DIVISION_DELETED', 'CAN_DIVISION_EDITED', 'CAN_CARRY_FORWARD_CALCULATED', name='canhistorytype', create_type=False), nullable=True),
sa.Column('created_by', sa.Integer(), nullable=True),
sa.Column('updated_by', sa.Integer(), nullable=True),
sa.Column('created_on', sa.DateTime(), nullable=True),
sa.Column('updated_on', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['can_id'], ['can.id'], ),
sa.ForeignKeyConstraint(['created_by'], ['ops_user.id'], ),
sa.ForeignKeyConstraint(['ops_event_id'], ['ops_event.id'], ),
sa.ForeignKeyConstraint(['updated_by'], ['ops_user.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('can_history')
op.drop_index(op.f('ix_can_history_version_transaction_id'), table_name='can_history_version')
op.drop_index(op.f('ix_can_history_version_operation_type'), table_name='can_history_version')
op.drop_index(op.f('ix_can_history_version_end_transaction_id'), table_name='can_history_version')
op.drop_table('can_history_version')
sa.Enum('CAN_DATA_IMPORT', 'CAN_NICKNAME_EDITED', 'CAN_DESCRIPTION_EDITED', 'CAN_FUNDING_CREATED', 'CAN_RECEIVED_CREATED', 'CAN_FUNDING_EDITED', 'CAN_RECEIVED_EDITED', 'CAN_FUNDING_DELETED', 'CAN_RECEIVED_DELETED', 'CAN_PORTFOLIO_CREATED', 'CAN_PORTFOLIO_DELETED', 'CAN_PORTFOLIO_EDITED', 'CAN_DIVISION_CREATED', 'CAN_DIVISION_DELETED', 'CAN_DIVISION_EDITED', 'CAN_CARRY_FORWARD_CALCULATED', name='canhistorytype').drop(op.get_bind())
# ### end Alembic commands ###
226 changes: 226 additions & 0 deletions backend/data_tools/data/can_data.json5
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,230 @@
funding: 1000000.0,
},
],
can_history: [
{ // 1
can_id: 500,
ops_event_id: 1,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 2
can_id: 501,
ops_event_id: 2,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 3
can_id: 502,
ops_event_id: 3,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 4
can_id: 503,
ops_event_id: 4,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 5
can_id: 504,
ops_event_id: 5,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 6
can_id: 505,
ops_event_id: 6,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 7
can_id: 506,
ops_event_id: 7,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 8
can_id: 507,
ops_event_id: 8,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 9
can_id: 508,
ops_event_id: 9,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 10
can_id: 509,
ops_event_id: 10,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 11
can_id: 510,
ops_event_id: 11,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 12
can_id: 511,
ops_event_id: 12,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 13
can_id: 512,
ops_event_id: 13,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 14
can_id: 513,
ops_event_id: 14,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 15
can_id: 514,
ops_event_id: 15,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 16
can_id: 515,
ops_event_id: 16,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 17
can_id: 516,
ops_event_id: 17,
history_title: "CAN Imported!",
history_message: "CAN Imported by Reed on Wednesdsay January 1st",
timestamp: "2025-01-01T00:07:00.000000Z",
history_type: "CAN_DATA_IMPORT"
},
{ // 18
can_id: 500,
ops_event_id: 18,
history_title: "Nickname Edited",
history_message: "CAN nickname edited by Director Dave to Test CAN",
timestamp: "2025-01-01T00:08:00.000000Z",
history_type: "CAN_NICKNAME_EDITED"
},
{ // 19
can_id: 500,
ops_event_id: 19,
history_title: "Description Edited",
history_message: "CAN description edited by Director Dave to Healthy Marriages Responsible Fatherhood - OPRE",
timestamp: "2025-01-01T00:09:00.000000Z",
history_type: "CAN_DESCRIPTION_EDITED"
},
{ // 20
can_id: 500,
ops_event_id: 20,
history_title: "CAN Funding Created",
history_message: "CAN funding created by Director Dave",
timestamp: "2025-01-01T00:10:00.000000Z",
history_type: "CAN_FUNDING_CREATED"
},
{ // 21
can_id: 500,
ops_event_id: 21,
history_title: "CAN Received Created",
history_message: "CAN received created by Director Dave",
timestamp: "2025-01-01T00:11:00.000000Z",
history_type: "CAN_RECEIVED_CREATED"
},
{ // 22
can_id: 500,
ops_event_id: 22,
history_title: "CAN Funding Edited",
history_message: "CAN funding edit by Director Dave",
timestamp: "2025-01-01T00:11:30.000000Z",
history_type: "CAN_FUNDING_EDITED"
},
{ // 23
can_id: 500,
ops_event_id: 23,
history_title: "CAN Received Edited",
history_message: "CAN funding edit by Director Dave",
timestamp: "2025-01-01T00:12:00.000000Z",
history_type: "CAN_RECEIVED_EDITED"
},
{ // 24
can_id: 500,
ops_event_id: 24,
history_title: "CAN Funding Deleted",
history_message: "CAN funding deleted by Director Dave",
timestamp: "2025-01-01T00:12:00.000000Z",
history_type: "CAN_FUNDING_DELETED"
},
{ // 25
can_id: 500,
ops_event_id: 25,
history_title: "CAN Received Deleted",
history_message: "CAN received deleted by Director Dave",
timestamp: "2025-01-01T00:12:30.000000Z",
history_type: "CAN_RECEIVED_DELETED"
},
{ // 26
can_id: 500,
ops_event_id: 26,
history_title: "CAN Carry Forward Calculated",
history_message: "CAN carry forward amount calculated",
timestamp: "2025-01-01T00:13:00.000000Z",
history_type: "CAN_CARRY_FORWARD_CALCULATED"
},
{ // 27
can_id: 500,
ops_event_id: 27,
history_title: "CAN Funding Created",
history_message: "CAN funding created by Director Dave",
timestamp: "2025-01-01T00:14:00.000000Z",
history_type: "CAN_FUNDING_CREATED"
},
{ // 28
can_id: 500,
ops_event_id: 28,
history_title: "CAN Funding Deleted",
history_message: "CAN funding deleted by Director Dave",
timestamp: "2025-01-01T00:15:00.000000Z",
history_type: "CAN_FUNDING_DELETED"
},
]
}
Loading
Loading