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(scenes): Add does not contain for Calendar action #2187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions front/src/config/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,7 @@
"nameLabel": "Wenn der Name",
"isExactly": "genau ist",
"contains": "enthält",
"doesNotContain": "enthält nicht",
"startsWith": "beginnt mit",
"endsWith": "endet mit",
"hasAnyName": "einen beliebigen Namen hat",
Expand Down
1 change: 1 addition & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,7 @@
"nameLabel": "If the name",
"isExactly": "is exactly",
"contains": "contains",
"doesNotContain": "does not contain",
"startsWith": "starts with",
"endsWith": "ends with",
"hasAnyName": "has any name",
Expand Down
1 change: 1 addition & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,7 @@
"nameLabel": "Si le nom",
"isExactly": "est exactement",
"contains": "contient",
"doesNotContain": "ne contient pas",
"startsWith": "commence par",
"endsWith": "finit par",
"hasAnyName": "a n'importe quel nom",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class CheckTime extends Component {
<option value="contains">
<Text id="editScene.triggersCard.calendarEventIsComing.contains" />
</option>
<option value="does-not-contain">
<Text id="editScene.triggersCard.calendarEventIsComing.doesNotContain" />
</option>
<option value="starts-with">
<Text id="editScene.triggersCard.calendarEventIsComing.startsWith" />
</option>
Expand Down
6 changes: 6 additions & 0 deletions server/lib/calendar/calendar.findCurrentlyRunningEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ async function findCurrentlyRunningEvent(calendars, calendarEventNameComparator,
[Op.like]: `%${calendarEventName}%`,
};
break;
case 'does-not-contain':
// @ts-ignore
queryParams.where.name = {
[Op.notLike]: `%${calendarEventName}%`,
};
break;
case 'starts-with':
// @ts-ignore
queryParams.where.name = {
Expand Down
1 change: 1 addition & 0 deletions server/models/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const actionSchema = Joi.array().items(
calendar_event_name_comparator: Joi.string().valid(
'is-exactly',
'contains',
'does-not-contain',
'starts-with',
'ends-with',
'has-any-name',
Expand Down
15 changes: 15 additions & 0 deletions server/test/lib/calendar/calendar.event.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@ describe('calendar.findCurrentlyRunningEvent', () => {
const eventsId = events.map((e) => e.id);
expect(eventsId).deep.equal(['a2b57b0a-7148-4961-8540-e493104bfd7c']);
});
it('should find event in calendar - does not contain', async () => {
await calendar.createEvent('test-calendar', {
id: 'a2b57b0a-7148-4961-8540-e493104bfd7c',
name: 'my test event',
start: startDate,
end: endDate,
});
const events = await calendar.findCurrentlyRunningEvent(
['test-calendar', 'test-calendar-random'],
'does-not-contain',
'random',
);
const eventsId = events.map((e) => e.id);
expect(eventsId).deep.equal(['a2b57b0a-7148-4961-8540-e493104bfd7c']);
});
it('should find event in calendar - starts-with', async () => {
await calendar.createEvent('test-calendar', {
id: 'a2b57b0a-7148-4961-8540-e493104bfd7c',
Expand Down
Loading