FocusFlow α Sprint Blog Series (Part 3) - Focus Mode & Focus Time Count

FOCUS_2025_SE FOCUS_2025_SE 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

目录

  • 1. Overview
  • 2. Function Realization Demonstration
  • 2.1 Focus Mode
  • 2.2 Countdown
  • 2.3 Total Learning Time
  • 3. Code Check-in Records (GitHub Commits)
  • 4. Core Code Analysis
  • 4.1 Task CRUD and Status Update (app.py)
  • 4.2 Marking Tasks as Completed
  • 4.3 Tag-Based Categorization During Task Creation/Editing
  • 5. Sprint Summary

1. Overview

ItemDetails
Course2025 Fall - Software Engineering Class
Assignment RequirementTeam Project - Alpha Sprint Blog
Team NameFocusFlow
AuthorShengpeng Yang (FZU: 832301120, MU: 23126434)
Goal of this AssignmentShowcase the Alpha Sprint progress, including Focus Mode implementation, Timer logic, and Total Study Time tracking.
Other ReferencesIEEE Std 830-1998, GB/T 8567-2006

Sprint Burndown Chart
We tracked our progress meticulously throughout the sprint. The chart below illustrates our team's velocity in completing the task management user stories against our estimated timeline.

img


2. Function Realization Demonstration

We have successfully implemented the core interfaces for managing learning tasks.

2.1 Focus Mode

We offer a Focus Mode for users to choose from, suitable for times when concentration is needed.

img

2.2 Countdown

For different learning tasks or personal preferences, we provide various countdown durations to choose from.

img

2.3 Total Learning Time

In the personal feedback module, users can also view their total learning time.

img


3. Code Check-in Records (GitHub Commits)

Our development process is backed by regular code commits ensuring version control and collaboration.

img


4. Core Code Analysis

The backend logic is powered by Flask and SQLite. Below is an analysis of the key functions in app.py that drive the task management features.

4.1 Task CRUD and Status Update (app.py)

Task Listing with Tags
The /tasks route handles the display of tasks. It fetches tasks specific to the logged-in user and retrieves associated tags for each task to ensure the frontend displays all relevant categorization data.

# app.py
@app.route('/tasks')
@login_required
def tasks():
    # ...
    # Fetch tasks sorted by due date
    tasks = conn.execute('SELECT * FROM tasks WHERE user_id = ? ORDER BY due_date ASC', (user_id,)).fetchall()

    tasks_with_tags = []
    for task in tasks:
        # Fetch tags for each specific task
        tags = conn.execute('SELECT tag FROM task_tags WHERE task_id = ?', (task['id'],)).fetchall()
        task_dict = dict(task)
        task_dict['tags'] = [tag['tag'] for tag in tags]
        # ... (Date formatting logic)
        tasks_with_tags.append(task_dict)
    # ...

Creating and Editing Tasks
We streamlined the creation and editing process into a single route /tasks/add. This function checks if a task_id is present in the form data. If it is, the system performs an UPDATE; otherwise, it performs an INSERT.

# app.py
@app.route('/tasks/add', methods=['POST'])
@login_required
def add_task():
    # ... (Data retrieval from request.form)
    
    if task_id:
        # Edit Mode: Update existing task
        conn.execute('''
            UPDATE tasks 
            SET title = ?, description = ?, course = ?, priority = ?, 
                due_date = ?, repeat = ?, status = ?, updated_at = CURRENT_TIMESTAMP 
            WHERE id = ? 
        ''', (title, description, course, priority, due_date, repeat, status, task_id))
        
        # Clear old tags to re-insert new ones
        conn.execute('DELETE FROM task_tags WHERE task_id = ?', (task_id,))
    else:
        # Create Mode: Insert new task
        cursor = conn.cursor()
        cursor.execute('''
            INSERT INTO tasks (user_id, title, description, course, priority, due_date, repeat, status)
            VALUES (?, ?, ?, ?, ?, ?, ?, ?)
        ''', (user_id, title, description, course, priority, due_date, repeat, status))
        task_id = cursor.lastrowid
    # ...

4.2 Marking Tasks as Completed

To allow for asynchronous status updates (e.g., via AJAX), we implemented a dedicated API endpoint /tasks/update_status/<int:task_id>. This verifies task ownership before updating the status to prevent unauthorized modifications.

# app.py
@app.route('/tasks/update_status/<int:task_id>', methods=['POST'])
@login_required
def update_task_status(task_id):
    # ...
    # Verification: Ensure task belongs to current user
    task = conn.execute('SELECT * FROM tasks WHERE id = ? AND user_id = ?', (task_id, user_id)).fetchone()
    
    # Update status
    conn.execute('UPDATE tasks SET status = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?', (new_status, task_id))
    # ...
    return jsonify({'success': True, 'message': 'Task status updated successfully!'})

4.3 Tag-Based Categorization During Task Creation/Editing

Handling tags requires parsing a comma-separated string from the frontend and creating associations in the task_tags table. This logic is embedded within the add_task route.

# app.py - Inside add_task function
    # ...
    if tags:
        # Split string by comma and strip whitespace
        tag_list = [tag.strip() for tag in tags.split(',') if tag.strip()]

        for tag in tag_list:
            # Insert individual tags into the association table
            conn.execute(
                'INSERT INTO task_tags (task_id, tag) VALUES (?, ?)',
                (task_id, tag)
            )
    # ...

5. Sprint Summary

  • Completed Deliverables

    • Distraction-Free Focus Interface: A specialized UI that isolates the user by displaying only pending tasks and the active timer, filtering out completed items to reduce cognitive load.
    • Pomodoro State Machine: A robust JavaScript timer (FocusTimer) that automatically manages transitions between "Focus" and "Break" states and handles audio notifications.
    • Session Data Persistence: Backend logic to securely validate and record completed focus durations into the SQLite database via asynchronous API calls.
    • Global Study Statistics: Implementation of a site-wide tracker that calculates and displays the user's total study hours on the navigation bar of every page.
  • Technical Challenges and Resolutions:

    • Conditional Data Saving: One major challenge was ensuring that the application only recorded "Focus" time and ignored "Break" time in the database. We resolved this by implementing a state flag (isFocusMode) within the FocusTimer class. The saveFocusSession function is strictly gated behind this flag in the handleTimerComplete method, ensuring only valid learning data is committed.
    • Global Data Accessibility: Displaying the "Total Study Time" on the dashboard and sidebar required access to database statistics across every route. Instead of repeating the query code in every view function, we utilized Flask's @app.before_request decorator. This allows us to calculate the aggregate time once and inject it into the global g object, making it accessible to the base template and all child pages automatically.
...全文

相关推荐

1978-2024年 31省GDP数据 第一第二第三产业及占比打包.zip

1978年至2024年,中国经济发展经历了历史性变革,31个省份的GDP数据详细记录了这一时期的变化。从第一产业到第三产业的增加值及占比看,中国产业结构持续优化升级。第一产业(农业)增加值虽逐年上升,但其在经济总量中的比重呈下降趋势,说明农业在国家经济发展中的相对地位有所降低,而绝对生产水平则有所提高。 第二产业涵盖工业和建筑业,长期是中国GDP增长的主要推动力。经济改革初期,第二产业快速增长,为中国现代化奠定了坚实基础。随着时间推移,第二产业占GDP比重虽有起伏,但整体增速明显快于第一产业。部分省份第二产业快速发展,带动了当地经济跃升。 第三产业涵盖服务业、金融业、信息技术等多个领域,是近年来中国GDP增长的又一重要动力。21世纪初以来,随着市场经济的发展和人民生活水平的提高,第三产业比重持续上升,成为拉动GDP增长的重要力量。在一些沿海发达地区,第三产业快速发展对经济的贡献尤为突出。 人均GDP是衡量经济发展水平和居民生活水平的重要指标,其变化也反映出中国各省份在经济发展上的差异和进步。沿海及经济发达省份的人均GDP水平明显高于内陆及边远省份,这与各地区的产业布局、资源分配和政策导向密切相关。 从这些数据可以看出,中国经济发展并不平衡:东部沿海省份往往拥有更高的GDP总量和人均GDP水平,西部和一些内陆省份则相对落后。不过,随着西部大开发、东北振兴等一系列区域发展战略的实施,中西部地区经济增速加快,GDP比重和人均GDP水平显著提升,区域发展差距逐步缩小。 此外,随着经济结构调整和产业政策优化,各省份的经济增长模式也在改变。创新驱动发展战略的实施推动了高新技术产业发展,促进了经济增长质量提升。同时,环境保护和可持续发展理念日益受到重视,绿色GDP概念开始被纳入考量,标志着中国经济发展方式正在转变。 数据分析显示,各省份之间发展并不均衡,这既有历史原因,也受地

温柔-的-女汉子

春秋BC765年世界历史地图矢量文件SHP格式.zip

本资源为《春秋BC765年世界历史地图矢量文件SHP格式》压缩包,文件大小约 26.64 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

白水先森

战国BC286年世界历史地图矢量文件SHP格式.zip

本资源为《战国BC286年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.28 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

白水先森

YOLO26算法游戏场景玩家目标检测+训练好的模型+603张数据集+pyqt可视化界面.zip

附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[玩家(players-sx6K)] · 总计:603 张 · 测试集:2 张 · 验证集:22 张 · 训练集:579 张 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 36 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.5105** mAP50-95 | 0.2501 Precision | 0.8603 Recall | 0.4773 train/box_loss | 1.4654 train/cls_loss | 1.0044 val/box_loss | 2.1439 val/cls_loss | 2.2525 【训练过程分析】 训练刚开始时,模型表现出了良好的收敛速度。前几轮的 train/box_loss 从初始值的 1.4654 降至 1.3865,下降了 0.0789。这意味着模型在学习阶段迅速适应了数据集的特性,尽管没有表现出剧烈波动,但这种稳步下降为后续训练打下了较为坚实的基础。而 val/box_loss 则从 2.1439 下降至 2.0576,下降了 0.0863,尽管下降幅度小于 train/box_loss,但也表明模型在验证集上也有良好的适应性。这反映了模型在初期训练过程中具有较好的学习曲线。 然而,进入中后期,训练与验证的 loss 均呈现平缓的下降趋势。train/box_loss 从 1.3865 下降... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。

guo_xiao_xiao_

春秋BC539年世界历史地图矢量文件SHP格式.zip

本资源为《春秋BC539年世界历史地图矢量文件SHP格式》压缩包,文件大小约 1.86 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

白水先森
评论
收藏 已收藏
分享
返回顶部