Skip to content

Commit ec57b65

Browse files
committed
fix: updating the query to ignore deleted entries
1 parent dbcad2c commit ec57b65

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

AutomaticClockOuts/clock_out.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ const doClockOut = async (context) => {
2323
await Promise.all(entries.map(async (timeEntryAsJson) => {
2424
const timeEntry = new TimeEntry(timeEntryAsJson)
2525
if (timeEntry.needsToBeClockedOut()) {
26-
const userToClockOut = findUser(users, timeEntry.timeEntry.owner_id);
27-
if(!userToClockOut.includes(userToClockOut)){
28-
usersWithClockOut.push(userToClockOut)
29-
}
26+
usersWithClockOut.push(findUser(users, timeEntry.timeEntry.owner_id));
3027
timeEntryAsJson.end_date = timeEntry.getTimeToClockOut()
3128
await container.item(timeEntryAsJson.id, timeEntryAsJson.tenant_id).replace(timeEntryAsJson)
3229
totalClockOutsExecuted++

AutomaticClockOuts/time_entry_dao.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
class TimeEntryDao {
22

3-
CONTAINER_ID = 'time_entry';
4-
53
constructor(database) {
6-
this.container = database.container(this.CONTAINER_ID);
4+
const CONTAINER_ID = 'time_entry';
5+
this.container = database.container(CONTAINER_ID);
76
}
87

98
async getEntriesWithNoEndDate () {
109
const QUERY_WITHOUT_END_DATE =
11-
"SELECT * FROM c WHERE (NOT IS_DEFINED(c.end_date) OR IS_NULL(c.end_date) = true) AND IS_DEFINED(c.start_date)";
10+
"SELECT * FROM c WHERE (NOT IS_DEFINED(c.end_date) OR IS_NULL(c.end_date) = true) AND IS_DEFINED(c.start_date) AND (NOT IS_DEFINED(c.deleted) OR IS_NULL(c.deleted) = true)";
1211
return this.container.items
1312
.query({query: QUERY_WITHOUT_END_DATE})
1413
.fetchAll();

0 commit comments

Comments
 (0)