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

feat: 'group by priority' names are now more readable #2047

Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions docs/Queries/Grouping.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ Since Tasks X.Y.Z, **[[Custom Grouping|custom grouping]] by description** is now

- `group by priority`
- The priority of the task, namely one of:
- `Priority 0: Highest`
- `Priority 1: High`
- `Priority 2: Medium`
- `Priority 3: None`
- `Priority 4: Low`
- `Priority 5: Lowest`
- `Highest priority`
- `High priority`
- `Medium priority`
- `Normal priority`
- `Low priority`
- `Lowest priority`

> [!released]
>
Expand Down
4 changes: 2 additions & 2 deletions src/Query/Filter/PriorityField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class PriorityField extends Field {

public grouper(): GrouperFunction {
return (task: Task) => {
const priorityName = PriorityTools.priorityNameUsingNone(task.priority);
return [`Priority ${task.priority}: ${priorityName}`];
const priorityName = PriorityTools.priorityNameUsingNormal(task.priority);
return [`%%${task.priority}%%${priorityName} priority`];
};
}
}
24 changes: 12 additions & 12 deletions tests/Query/Filter/PriorityField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ describe('grouping by priority', () => {
});

it.each([
['- [ ] a 🔺', ['Priority 0: Highest']],
['- [ ] a ⏫', ['Priority 1: High']],
['- [ ] a 🔼', ['Priority 2: Medium']],
['- [ ] a', ['Priority 3: None']],
['- [ ] a 🔽', ['Priority 4: Low']],
['- [ ] a ⏬', ['Priority 5: Lowest']],
['- [ ] a 🔺', ['%%0%%Highest priority']],
['- [ ] a ⏫', ['%%1%%High priority']],
['- [ ] a 🔼', ['%%2%%Medium priority']],
['- [ ] a', ['%%3%%Normal priority']],
['- [ ] a 🔽', ['%%4%%Low priority']],
['- [ ] a ⏬', ['%%5%%Lowest priority']],
])('task "%s" should have groups: %s', (taskLine: string, groups: string[]) => {
// Arrange
const grouper = new PriorityField().createNormalGrouper().grouper;
Expand All @@ -219,12 +219,12 @@ describe('grouping by priority', () => {
const tasks = SampleTasks.withAllPriorities();

expect({ grouper, tasks }).groupHeadingsToBe([
'Priority 0: Highest',
'Priority 1: High',
'Priority 2: Medium',
'Priority 3: None',
'Priority 4: Low',
'Priority 5: Lowest',
'%%0%%Highest priority',
'%%1%%High priority',
'%%2%%Medium priority',
'%%3%%Normal priority',
'%%4%%Low priority',
'%%5%%Lowest priority',
]);
});
});