-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,42 @@ | ||
import { Request, Response } from "express"; | ||
|
||
import { Task } from "../models/Task.js"; | ||
import { IEntry } from "../models/Entry.js"; | ||
import mongoose from "mongoose"; | ||
|
||
// Get all tasks by UserId | ||
export async function getMonthTasks(req: Request, res: Response) { | ||
const { userId, year, month } = req.params; | ||
export async function getTasksByUserId(req: Request, res: Response) { | ||
const { userId } = req.params; | ||
|
||
if (!userId) { | ||
throw new Error("User ID is required."); | ||
} | ||
|
||
const tasks = await Task.find({ userId }).exec(); | ||
|
||
// const tasksWithFilteredEntries = tasks.map((task) => { | ||
// const filteredEntries = task.entries.filter((entry) => { | ||
// const entryYear = entry.date.getFullYear(); | ||
|
||
// return entryYear === Number(year); | ||
// }); | ||
|
||
// return { | ||
// ...task.toObject(), | ||
// entries: filteredEntries, | ||
// }; | ||
// }); | ||
|
||
return res.json(tasks); | ||
} | ||
|
||
// Get all tasks by UserId | ||
export async function getTasksByUserId(req: Request, res: Response) { | ||
const { userId } = req.params; | ||
// export async function getMonthTasks(req: Request, res: Response) { | ||
// const { userId, year, month } = req.params; | ||
|
||
if (!userId) { | ||
throw new Error("User ID is required."); | ||
} | ||
// if (!userId) { | ||
// throw new Error("User ID is required."); | ||
// } | ||
|
||
const tasks = await Task.find({ userId }).exec(); | ||
// const tasks = await Task.find({ userId }).exec(); | ||
|
||
return res.json(tasks); | ||
} | ||
// const tasksWithFilteredEntries = tasks.map((task) => { | ||
// const filteredEntries = task.entries.filter((entry) => { | ||
// const entryYear = entry.date.getFullYear(); | ||
|
||
// Get all tasks | ||
export async function getAllTasks(req: Request, res: Response) { | ||
const tasks = await Task.find(); | ||
// return entryYear === Number(year); | ||
// }); | ||
|
||
return res.json(tasks); | ||
} | ||
// return { | ||
// ...task.toObject(), | ||
// entries: filteredEntries, | ||
// }; | ||
// }); | ||
|
||
// return res.json(tasks); | ||
// } |