Merge branch 'release/v2.0.3' of https://github.com/Worklenz/worklenz into feature/project-list-grouping
This commit is contained in:
@@ -145,7 +145,7 @@ BEGIN
|
||||
SET progress_value = NULL,
|
||||
progress_mode = NULL
|
||||
WHERE project_id = _project_id
|
||||
AND progress_mode = _old_mode;
|
||||
AND progress_mode::text::progress_mode_type = _old_mode;
|
||||
END IF;
|
||||
|
||||
RETURN NEW;
|
||||
|
||||
@@ -50,11 +50,16 @@ export default class TasksControllerBase extends WorklenzControllerBase {
|
||||
task.progress = parseInt(task.progress_value);
|
||||
task.complete_ratio = parseInt(task.progress_value);
|
||||
}
|
||||
// For tasks with no subtasks and no manual progress, calculate based on time
|
||||
// For tasks with no subtasks and no manual progress
|
||||
else {
|
||||
task.progress = task.total_minutes_spent && task.total_minutes
|
||||
? ~~(task.total_minutes_spent / task.total_minutes * 100)
|
||||
: 0;
|
||||
// Only calculate progress based on time if time-based progress is enabled for the project
|
||||
if (task.project_use_time_progress && task.total_minutes_spent && task.total_minutes) {
|
||||
// Cap the progress at 100% to prevent showing more than 100% progress
|
||||
task.progress = Math.min(~~(task.total_minutes_spent / task.total_minutes * 100), 100);
|
||||
} else {
|
||||
// Default to 0% progress when time-based calculation is not enabled
|
||||
task.progress = 0;
|
||||
}
|
||||
|
||||
// Set complete_ratio to match progress
|
||||
task.complete_ratio = task.progress;
|
||||
|
||||
@@ -610,6 +610,21 @@ export default class TasksControllerV2 extends TasksControllerBase {
|
||||
return this.createTagList(result.rows);
|
||||
}
|
||||
|
||||
public static async getProjectSubscribers(projectId: string) {
|
||||
const q = `
|
||||
SELECT u.name, u.avatar_url, ps.user_id, ps.team_member_id, ps.project_id
|
||||
FROM project_subscribers ps
|
||||
LEFT JOIN users u ON ps.user_id = u.id
|
||||
WHERE ps.project_id = $1;
|
||||
`;
|
||||
const result = await db.query(q, [projectId]);
|
||||
|
||||
for (const member of result.rows)
|
||||
member.color_code = getColor(member.name);
|
||||
|
||||
return this.createTagList(result.rows);
|
||||
}
|
||||
|
||||
public static async checkUserAssignedToTask(taskId: string, userId: string, teamId: string) {
|
||||
const q = `
|
||||
SELECT EXISTS(
|
||||
|
||||
@@ -6,11 +6,11 @@ import { isProduction } from "../shared/utils";
|
||||
const pgSession = require("connect-pg-simple")(session);
|
||||
|
||||
export default session({
|
||||
name: process.env.SESSION_NAME || "worklenz.sid",
|
||||
name: process.env.SESSION_NAME,
|
||||
secret: process.env.SESSION_SECRET || "development-secret-key",
|
||||
proxy: true,
|
||||
proxy: false,
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
saveUninitialized: true,
|
||||
rolling: true,
|
||||
store: new pgSession({
|
||||
pool: db.pool,
|
||||
@@ -18,9 +18,10 @@ export default session({
|
||||
}),
|
||||
cookie: {
|
||||
path: "/",
|
||||
secure: isProduction(), // Use secure cookies in production
|
||||
httpOnly: true,
|
||||
sameSite: "lax", // Standard setting for same-origin requests
|
||||
// secure: isProduction(),
|
||||
// httpOnly: isProduction(),
|
||||
// sameSite: "none",
|
||||
// domain: isProduction() ? ".worklenz.com" : undefined,
|
||||
maxAge: 30 * 24 * 60 * 60 * 1000 // 30 days
|
||||
}
|
||||
});
|
||||
@@ -19,7 +19,8 @@ export async function on_project_subscriber_change(_io: Server, socket: Socket,
|
||||
const isSubscribe = data.mode == 0;
|
||||
const q = isSubscribe
|
||||
? `INSERT INTO project_subscribers (user_id, project_id, team_member_id)
|
||||
VALUES ($1, $2, $3);`
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (user_id, project_id, team_member_id) DO NOTHING;`
|
||||
: `DELETE
|
||||
FROM project_subscribers
|
||||
WHERE user_id = $1
|
||||
@@ -27,7 +28,7 @@ export async function on_project_subscriber_change(_io: Server, socket: Socket,
|
||||
AND team_member_id = $3;`;
|
||||
await db.query(q, [data.user_id, data.project_id, data.team_member_id]);
|
||||
|
||||
const subscribers = await TasksControllerV2.getTaskSubscribers(data.project_id);
|
||||
const subscribers = await TasksControllerV2.getProjectSubscribers(data.project_id);
|
||||
socket.emit(SocketEvents.PROJECT_SUBSCRIBERS_CHANGE.toString(), subscribers);
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user