Partial daily plan implementation

This commit is contained in:
digimint 2025-12-11 02:24:56 -06:00
parent c7f6f3f4f1
commit e0063fffdb
Signed by: digimint
GPG key ID: 8DF1C6FD85ABF748
27 changed files with 1687 additions and 53 deletions

View file

@ -0,0 +1,74 @@
"""Daily tasks setup
Revision ID: 4a2deb2e7bda
Revises: 8576b056149e
Create Date: 2025-12-10 20:55:31.114636
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4a2deb2e7bda'
down_revision = '8576b056149e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('daily_plan',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('start_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='fk_dp_user', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('daily_plan_tasks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('task_id', sa.Integer(), nullable=True),
sa.Column('plan_id', sa.Integer(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.Column('target', sa.DateTime(), nullable=False),
sa.Column('completed', sa.DateTime(), nullable=True),
sa.Column('time_spent', sa.Integer(), nullable=False),
sa.Column('time_goal', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['plan_id'], ['daily_plan.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['task_id'], ['task.id'], ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.add_column(sa.Column('mental_burn', sa.Integer(), nullable=False, default=0))
batch_op.add_column(sa.Column('social_burn', sa.Integer(), nullable=False, default=0))
batch_op.add_column(sa.Column('time_estimate', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('time_spent', sa.Integer(), nullable=False, default=0))
batch_op.add_column(sa.Column('importance', sa.Integer(), nullable=False, default=2))
batch_op.add_column(sa.Column('divisible', sa.Boolean(), nullable=False, default=False))
batch_op.add_column(sa.Column('last_reviewed', sa.DateTime(), nullable=True))
batch_op.alter_column('due',
existing_type=sa.DATETIME(),
nullable=True)
batch_op.drop_column('soft_due')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.add_column(sa.Column('soft_due', sa.DATETIME(), nullable=True))
batch_op.alter_column('due',
existing_type=sa.DATETIME(),
nullable=False)
batch_op.drop_column('last_reviewed')
batch_op.drop_column('divisible')
batch_op.drop_column('importance')
batch_op.drop_column('time_spent')
batch_op.drop_column('time_estimate')
batch_op.drop_column('social_burn')
batch_op.drop_column('mental_burn')
op.drop_table('daily_plan_tasks')
op.drop_table('daily_plan')
# ### end Alembic commands ###

View file

@ -0,0 +1,39 @@
"""Add break info to DailyPlan
Revision ID: 604ec4c8d043
Revises: f1bc3cfb815d
Create Date: 2025-12-11 00:11:06.723265
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '604ec4c8d043'
down_revision = 'f1bc3cfb815d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.add_column(sa.Column('break_time_goal', sa.Integer(), default=0, nullable=True))
batch_op.add_column(sa.Column('break_time_spent', sa.Integer(), default=0, nullable=True))
op.execute('UPDATE daily_plan SET break_time_goal = 0')
op.execute('UPDATE daily_plan SET break_time_spent = 0')
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.alter_column('break_time_goal', nullable=False)
batch_op.alter_column('break_time_spent', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.drop_column('break_time_spent')
batch_op.drop_column('break_time_goal')
# ### end Alembic commands ###

View file

@ -0,0 +1,59 @@
"""Add intent information to DailyPlan
Revision ID: a2f8f8dc3ab0
Revises: ae3136f2aa90
Create Date: 2025-12-11 01:45:56.938210
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a2f8f8dc3ab0'
down_revision = 'ae3136f2aa90'
branch_labels = None
depends_on = None
def upgrade():
### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.add_column(sa.Column('total_time_intent', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('total_time_goal' , sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('total_time_spent' , sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('burn_intent' , sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('burn_goal' , sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('flags_raw' , sa.Integer(), nullable=True))
for col in [
'total_time_intent',
'total_time_goal',
'total_time_spent',
'burn_intent',
'burn_goal',
'flags_raw'
]:
op.execute(f'UPDATE daily_plan SET {col} = 0')
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.alter_column('total_time_intent', nullable=False)
batch_op.alter_column('total_time_goal', nullable=False)
batch_op.alter_column('total_time_spent', nullable=False)
batch_op.alter_column('burn_intent', nullable=False)
batch_op.alter_column('burn_goal', nullable=False)
batch_op.alter_column('flags_raw', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.drop_column('flags_raw')
batch_op.drop_column('burn_goal')
batch_op.drop_column('burn_intent')
batch_op.drop_column('total_time_spent')
batch_op.drop_column('total_time_goal')
batch_op.drop_column('total_time_intent')
# ### end Alembic commands ###

View file

@ -0,0 +1,52 @@
"""Change DailyPlanTask datetimes to use auto-conversion
Revision ID: ae3136f2aa90
Revises: 604ec4c8d043
Create Date: 2025-12-11 00:17:06.827686
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ae3136f2aa90'
down_revision = '604ec4c8d043'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.alter_column('start_at',
new_column_name='start_at_raw'
)
with op.batch_alter_table('daily_plan_tasks', schema=None) as batch_op:
batch_op.alter_column('target',
new_column_name='target_raw'
)
batch_op.alter_column('completed',
new_column_name='completed_raw'
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('daily_plan_tasks', schema=None) as batch_op:
batch_op.alter_column('target_raw',
new_column_name='target'
)
batch_op.alter_column('completed_raw',
new_column_name='completed'
)
with op.batch_alter_table('daily_plan', schema=None) as batch_op:
batch_op.alter_column('start_at_raw',
new_column_name='start_at'
)
# ### end Alembic commands ###

View file

@ -0,0 +1,37 @@
"""Rename Task columns
Revision ID: f1bc3cfb815d
Revises: 4a2deb2e7bda
Create Date: 2025-12-10 22:47:42.436743
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = 'f1bc3cfb815d'
down_revision = '4a2deb2e7bda'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.alter_column('due', new_column_name='due_raw')
batch_op.alter_column('created', new_column_name='created_raw')
batch_op.alter_column('completed', new_column_name='completed_raw')
batch_op.alter_column('last_reviewed', new_column_name='last_reviewed_raw')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.alter_column(column_name='due_raw', new_column_name='due')
batch_op.alter_column(column_name='created_raw', new_column_name='created')
batch_op.alter_column(column_name='completed_raw', new_column_name='completed')
batch_op.alter_column(column_name='last_reviewed_raw', new_column_name='last_reviewed')
# ### end Alembic commands ###