Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the progress on ck-monitor to work with generation tasks #639

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions frontend/src/app/components/ck-monitor/ck-monitor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
TaskActionType,
TaskWorkflow,
GroupTaskStatus,
TaskWorkflowType,
} from 'src/app/models/workflow';
import { BoardService } from 'src/app/services/board.service';
import { ProjectService } from 'src/app/services/project.service';
Expand Down Expand Up @@ -616,22 +617,34 @@ export class CkMonitorComponent implements OnInit, OnDestroy {

// sum all amountRequired for each action per post
// i.e. Post A (1 tag req, 1 comment req) + Post B (1 tag req, 0 comments required)
const remaining = values.reduce(
let remaining = values.reduce(
(partialSum, a) =>
partialSum + a.reduce((partial, b) => partial + b.amountRequired, 0),
0
);

// nothing left to do
if (remaining == 0) return 100;
if (remaining == 0 && task.workflow.type !== TaskWorkflowType.GENERATION)
return 100;

// sum both required tags (1) and required comments (1) = 2
// multiple by number of posts since those requirements are per-post
const total =
task.workflow.requiredActions.reduce(
(partialSum, a) => partialSum + a.amountRequired,
0
) * values.length;
let total = task.workflow.requiredActions
.filter((a) => a.type !== TaskActionType.CREATE_POST)
.reduce((partialSum, a) => partialSum + a.amountRequired, 0);
if (task.workflow.type === TaskWorkflowType.GENERATION) {
const createPosts = task.workflow.requiredActions.filter(
(a) => a.type === TaskActionType.CREATE_POST
)[0].amountRequired;
const postsCreated = Object.keys(task.groupTask.progress).length;

const actionPerPost = total;
if (total) total = total * createPosts + createPosts;
else total = createPosts;
remaining += createPosts - postsCreated;
remaining += (createPosts - postsCreated) * actionPerPost;
} else {
total *= values.length;
}

return ((total - remaining) / total) * 100;
}
Expand Down
Loading