FocusFlow α Sprint Blog Series (Part 4) - Homepage check-in & Overview
目录
- 1. Overview
- 2. Function Realization Demonstration
- 2.1 Daily check-in system
- 2.2 Data Overview Panel
- 3. Code Check-in Records (GitHub Commits)
- 4. Core Code Analysis
- 5.Sprint Summary
- 5.1 Completed Deliverables
- 5.2Technical Challenges and Resolutions:
1. Overview
| Course | https://bbs.csdn.net/forums/2501_MU_SE_FZU |
|---|---|
| Assignment Requirement | https://bbs.csdn.net/topics/620061759 |
| Team name | FocusFlow |
| Author | Hongzhi He(FZU:832302220 MU:23125390 |
| Goal of this Assignment | Showcase the Alpha Sprint progress, including homepage check-in, homepage overview, etc. |
| Other References | IEEE 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.

2. Function Realization Demonstration
We have implemented functions such as homepage check-in and homepage overview
2.1 Daily check-in system
In FocusFlow, the check-in function is not only a record of user login, but also an important incentive mechanism for cultivating study habits. Users gain a sense of achievement through continuous check-in, forming a positive feedback loop.



2.2 Data Overview Panel
The data overview panel can visually display learning progress, making users' goals clearer and their actions faster

3. Code Check-in Records (GitHub Commits)
Our development process is backed by regular code commits ensuring version control and collaboration.

4. Core Code Analysis
This task involves some core code, and the key parts will be presented below for analysis.
Firstly, the core code of the check-in function belongs to the data layer design
models.py
class Checkin:
def __init__(self, id=None, user_id=None, date=None, created_at=None):
self.id = id
self.user_id = user_id
self.date = date
self.created_at = created_at
The Checkin class follows the "single responsibility principle" and is only responsible for storing the core information of check-in records By associating the user_id field with the User table, a one to many relationship between users and check-in records can be achieved. The date field is specifically used to store check-in dates (excluding specific times), making it easy to perform statistics and queries based on dates. The created date record is used to record the specific time point of check-in for subsequent auditing and analysis
The next step is the implementation of the check-in logic in the control layer, mainly consisting of the app.py file:
app.py
@app.route('/checkin', methods=['POST'])
@login_required
def checkin():
user_id = session['user_id']
today = datetime.now().strftime('%Y-%m-%d') # 关键:标准化日期格式
conn = get_db_connection()
try:
# 防重签机制:检查今天是否已经签到
existing_checkin = conn.execute(
'SELECT * FROM checkins WHERE user_id = ? AND date = ?',
(user_id, today)
).fetchone()
if existing_checkin:
flash('You have already signed in today!', 'info')
else:
# 执行签到:插入新记录
conn.execute(
'INSERT INTO checkins (user_id, date) VALUES (?, ?)',
(user_id, today)
)
conn.commit()
flash('Sign in successful! Keep up the good work!', 'success')
finally:
conn.close()
return redirect(url_for('dashboard'))
Ensure that the same user can only check in once on the same day through UNIQUE (user_id, date) database constraints and pre checks Perform operations in database transactions to ensure data consistency Provide instant feedback through flash messages to enhance user experience Store dates in% Y -% m -% d format to avoid time zone issues.
In addition, we have also implemented the function of continuous check-in, and the key part of it is also in the app.py file:
app.py
# 获取连续签到天数
streak_days = 0
checkin_dates = conn.execute('''
SELECT date FROM checkins WHERE user_id = ? ORDER BY date DESC
''', (user_id,)).fetchall()
if checkin_dates:
current_date = datetime.now().date()
for checkin_date in checkin_dates:
checkin_date_obj = datetime.strptime(checkin_date['date'], '%Y-%m-%d').date()
if (current_date - checkin_date_obj).days == streak_days:
streak_days += 1
else:
break
Calculate the consecutive days by checking the most recent check-in records in a loop Use (Current_date checkin_date_obj). days to calculate the date interval Sort by date DESC in descending order, starting from the most recent Terminate the loop immediately when discontinuous dates are detected.
In order to achieve real-time display of today's check-in status and task completion percentage, provide weekly learning trends, highlight consecutive check-in days, and other homepage functions, we still implement homepage aggregation in app.py. Some of the code is as follows:
app.py
# 获取签到信息
today = datetime.now().strftime('%Y-%m-%d')
has_checked_in = conn.execute('SELECT * FROM checkins WHERE user_id = ? AND date = ?',
(user_id, today)).fetchone() is not None
# 获取本周专注时长
week_start = (datetime.now() - timedelta(days=datetime.now().weekday())).strftime('%Y-%m-%d')
focus_time_query = conn.execute('''
SELECT SUM(duration) as total_minutes
FROM focus_sessions
WHERE user_id = ? AND date(start_time) >= ?
''', (user_id, week_start)).fetchone()
# 获取任务统计
completed_tasks_query = conn.execute('''
SELECT COUNT(*) as count FROM tasks WHERE user_id = ? AND status = 'completed'
''', (user_id,)).fetchone()
Aggregate data from the checkins, foci sessions, and tasks tables Calculate using relative time (this week, today) Reduce application layer computation by utilizing built-in functions such as SUM and COUNT in databases Only query relevant data when needed to avoid unnecessary database access.
Finally, we present the key code of our database design pattern:
-- 签到表的核心设计
CREATE TABLE checkins (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL,
date DATE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE(user_id, date) -- 防止重复签到
);
The checkins table serves as the fact table, and the users table serves as the dimension table Store summary data such as stream_days in the users table to improve query performance Store check-in records by date partition for easy management of historical data.
5.Sprint Summary
5.1 Completed Deliverables
- Core Homepage Redesign – Implemented dynamic dashboard with real-time data widgets
- Daily Check-in System – Functional check-in button with streak tracking and calendar view
- User Data Overview Panel – Displays pending tasks, study duration, completion rate, and weekly stats
- Personalized Greetings – Time-based greetings (morning/afternoon/evening) with user name
- Weekly Learning Trends – 7-day visual trend chart integrating check-ins and focus sessions
- Database Schema Enhancement – Added checkins table and user statistics fields (current_streak, total_checkins, etc.)
5.2Technical Challenges and Resolutions:
- Consecutive Day Calculation Logic:
Solution:Implemented date-difference iteration algorithm with early termination on break detection - Preventing Duplicate Check-ins:
Solution:Combined database UNIQUE constraint (user_id, date) with pre-check in application logic - Real-time Data Synchronization:
Solution:Used AJAX polling for stats updates and optimistic UI updates for check-in actions - Timezone Handling:
Solution:Stored all dates in UTC and converted to local time only for display purposes - Database Performance with Aggregates:
Solution:Added indexes on user_id, date fields and used SQL aggregation functions (SUM, COUNT) - Responsive Dashboard Layout:
Solution:Applied Bootstrap 5 grid system with conditional card stacking on mobile devices
The sprint successfully delivered a fully functional homepage with integrated check-in system and real-time learning analytics. All core acceptance criteria were met, with particular attention given to data accuracy, user experience, and system performance.
相关推荐
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 下降... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。
春秋BC539年世界历史地图矢量文件SHP格式.zip
本资源为《春秋BC539年世界历史地图矢量文件SHP格式》压缩包,文件大小约 1.86 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。


