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

Implement "until" keyword in gantt charts #5224

Conversation

fzag
Copy link
Contributor

@fzag fzag commented Jan 22, 2024

📑 Summary

Implement keyword until for tasks that should run until some specific other task or milestone starts.

Resolves #3173

📏 Design Decisions

The end date of a task could previously be defined either using a duration (e.g. 1d) or an absolute date (e.g. 2024-01-22) but not relatively to other tasks/milestones. This is useful in many cases, e.g.: to avoid repeating the end-date of multiple tasks which should end at the same time, rely on critical milestones with specified date, ...

📋 Tasks

Make sure you

Copy link

netlify bot commented Jan 22, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 5fe9f9e
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/65dfeb1048bc6d0008d392fe
😎 Deploy Preview https://deploy-preview-5224--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the Type: Enhancement New feature or request label Jan 22, 2024
Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Attention: Patch coverage is 89.74359% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 79.23%. Comparing base (31a287b) to head (5fe9f9e).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #5224       +/-   ##
============================================
+ Coverage    43.20%   79.23%   +36.03%     
============================================
  Files           23      175      +152     
  Lines         5115    14535     +9420     
  Branches        23      868      +845     
============================================
+ Hits          2210    11517     +9307     
+ Misses        2904     2815       -89     
- Partials         1      203      +202     
Flag Coverage Δ
e2e 84.80% <75.00%> (?)
unit 43.37% <89.74%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/mermaid/src/diagrams/gantt/ganttDb.js 78.50% <89.74%> (+1.80%) ⬆️

... and 169 files with indirect coverage changes

Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've consolidated all the requested changes here.
I'm not sure if we should use the current date as a fallback, as the diagram would look different based on when it's opened. Either we should throw an error, or we should use a fixed date based on the other dates in the diagram.

  // Test for until
  const untilStatement = /^until\s+(?<ids>[\d\w- ]+)/.exec(str);
  if (untilStatement) {
    // check all until ids and take the earliest
    let earliestStartingTask = null;
    for (const id of untilStatement.groups.ids.split(' ')) {
      let task = findTaskById(id);
      if (!task) {
        continue;
      }
      if (earliestStartingTask === null || task.startTime < earliestStartingTask.startTime) {
        earliestStartingTask = task;
      }
    }

    if (earliestStartingTask) {
      return earliestStartingTask.startTime;
    }

    // TODO: Not sure if we should use a dynamic date here. 
    const dt = new Date();
    dt.setHours(0, 0, 0, 0);
    return dt;
  }

packages/mermaid/src/diagrams/gantt/ganttDb.js Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/gantt/ganttDb.js Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/gantt/ganttDb.js Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/gantt/ganttDb.js Outdated Show resolved Hide resolved
@fzag fzag requested a review from sidharthv96 January 27, 2024 12:55
@sidharthv96
Copy link
Member

image There is one failing test. Can you please look into that?

@fzag
Copy link
Contributor Author

fzag commented Jan 27, 2024

Just fixed it!
The 2 remaining e2e errors are now due to the e2e test having being modified to test the new feature.

@sidharthv96
Copy link
Member

Can you please separate the tests to new ones? And add a few more cases as well? Tests have helped catch numerous issues recently, and this feature is significant enough to warrant individual tests that specifically state the purpose of the test.

Otherwise, in the future, maintainers might not notice subtle failures, or if they do, it'll be difficult to figure out which area is affected.

cypress/integration/rendering/gantt.spec.js Outdated Show resolved Hide resolved
cypress/integration/rendering/gantt.spec.js Outdated Show resolved Hide resolved
Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

packages/mermaid/src/diagrams/gantt/ganttDb.js Outdated Show resolved Hide resolved
@sidharthv96 sidharthv96 added this pull request to the merge queue Feb 27, 2024
@sidharthv96 sidharthv96 removed this pull request from the merge queue due to a manual request Feb 27, 2024
@sidharthv96 sidharthv96 added this pull request to the merge queue Feb 27, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2024
@sidharthv96 sidharthv96 added this pull request to the merge queue Feb 27, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2024
@sidharthv96 sidharthv96 added this pull request to the merge queue Feb 29, 2024
Merged via the queue into mermaid-js:develop with commit 970a98a Feb 29, 2024
20 checks passed
Copy link

mermaid-bot bot commented Feb 29, 2024

@fzag, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Option until / before to Gantt Diagram
2 participants