Skip to content

Commit

Permalink
feat(scenes): Add does not contain for Calendar action
Browse files Browse the repository at this point in the history
  • Loading branch information
cicoub13 committed Dec 17, 2024
1 parent 3188ddf commit 531a32c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions front/src/config/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,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 @@ -2155,6 +2155,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 @@ -2155,6 +2155,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

0 comments on commit 531a32c

Please sign in to comment.