Enhance: Google Photos integration, refinement of Schedule/Todo lists and API fixes

This commit is contained in:
kihong.kim
2026-02-01 01:05:33 +09:00
parent c614c883d4
commit 5fa24d61c9
7 changed files with 56 additions and 40 deletions

View File

@@ -23,7 +23,18 @@ router.get("/", async (req, res) => {
router.get("/today", async (req, res) => {
try {
const { start, end } = getDayRange();
const todos = await Todo.find({ dueDate: { $gte: start, $lte: end } }).sort({
// Include:
// 1. Tasks due today
// 2. Overdue tasks (due before today) that are not completed
// 3. Tasks with no due date that are not completed
const todos = await Todo.find({
$or: [
{ dueDate: { $gte: start, $lte: end } },
{ dueDate: { $lt: start }, completed: false },
{ dueDate: { $exists: false }, completed: false },
{ dueDate: null, completed: false }
]
}).sort({
dueDate: 1,
createdAt: -1,
});

View File

@@ -45,25 +45,22 @@ router.get("/", async (req, res) => {
const currentData = currentResponse.data;
// 3. Process Forecast for Today's Min/Max (Seoul Time: UTC+9)
// OpenWeatherMap returns timestamps in UTC.
// Seoul is UTC+9.
const SeoulOffset = 9 * 60 * 60 * 1000;
const nowKST = new Date(Date.now() + SeoulOffset);
const todayStr = nowKST.toISOString().split("T")[0]; // YYYY-MM-DD in KST
// 3. Process Forecast for Today's Min/Max (Rolling 24-hour window for stability)
// We use the first 8 segments (3h * 8 = 24h) to ensure we always have a full
// day-night cycle of temperatures, providing a stable daily range.
const forecastList = forecastResponse.data.list;
if (forecastList && forecastList.length > 0) {
const next24h = forecastList.slice(0, 8);
const todayItems = forecastResponse.data.list.filter((item) => {
const itemDateKST = new Date(item.dt * 1000 + SeoulOffset);
const itemDateStr = itemDateKST.toISOString().split("T")[0];
return itemDateStr === todayStr;
});
// Calculate min/max from forecast
let minTemp = Math.min(...next24h.map((item) => item.main.temp_min));
let maxTemp = Math.max(...next24h.map((item) => item.main.temp_max));
if (todayItems.length > 0) {
// Find min and max from the 3-hour segments
const minTemp = Math.min(...todayItems.map((item) => item.main.temp_min));
const maxTemp = Math.max(...todayItems.map((item) => item.main.temp_max));
// Also compare with current temperature to ensure the range covers current state
const currentTemp = currentData.main.temp;
minTemp = Math.min(minTemp, currentTemp);
maxTemp = Math.max(maxTemp, currentTemp);
// Update the response structure
currentData.main.temp_min = minTemp;
currentData.main.temp_max = maxTemp;
}