New version API collaboration and tested for Project
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import projectModel from "../../V1Models/Project/project-model.ts";
|
||||
import userModel from "../../model/user-Model.ts";
|
||||
import UsersDataModel from "../../V1Models/Auth/user.ts";
|
||||
import { existingUser } from "../helpers/ProjecthelperFn.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
|
||||
interface IRecentData {
|
||||
organization: string;
|
||||
@@ -29,7 +28,6 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
||||
try {
|
||||
const { userId, organization, role } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
console.log('userExisting: ', userExisting);
|
||||
if (!userExisting) return { status: "User not found" };
|
||||
const userRecentData = await UsersDataModel(organization)
|
||||
.findOne({ userId: userId, isArchive: false })
|
||||
@@ -43,16 +41,19 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const populatedProjects = userRecentData.recentlyViewed as IProject[];
|
||||
console.log("populatedProjects: ", populatedProjects);
|
||||
const RecentDatas = await Promise.all(
|
||||
populatedProjects.map(async (project) => {
|
||||
const projectExisting = await projectModel(organization)
|
||||
.findOne(filter)
|
||||
.findOne({ _id: project._id, isArchive: false })
|
||||
.select("_id projectName createdBy thumbnail createdAt isViewed");
|
||||
return projectExisting;
|
||||
})
|
||||
);
|
||||
console.log("RecentDatas: ", RecentDatas);
|
||||
|
||||
const filteredProjects = RecentDatas.filter(Boolean);
|
||||
console.log("filteredProjects: ", filteredProjects);
|
||||
return { status: "Success", data: filteredProjects };
|
||||
} catch (error) {
|
||||
return { status: error };
|
||||
|
||||
Reference in New Issue
Block a user