Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: updating the query to ignore deleted entries
  • Loading branch information
enriquezrene committed Nov 20, 2020
commit ec57b654e9c74fff2cf2558614c2465a372ad433
5 changes: 1 addition & 4 deletions AutomaticClockOuts/clock_out.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ const doClockOut = async (context) => {
await Promise.all(entries.map(async (timeEntryAsJson) => {
const timeEntry = new TimeEntry(timeEntryAsJson)
if (timeEntry.needsToBeClockedOut()) {
const userToClockOut = findUser(users, timeEntry.timeEntry.owner_id);
if(!userToClockOut.includes(userToClockOut)){
usersWithClockOut.push(userToClockOut)
}
usersWithClockOut.push(findUser(users, timeEntry.timeEntry.owner_id));
timeEntryAsJson.end_date = timeEntry.getTimeToClockOut()
await container.item(timeEntryAsJson.id, timeEntryAsJson.tenant_id).replace(timeEntryAsJson)
totalClockOutsExecuted++
Expand Down
7 changes: 3 additions & 4 deletions AutomaticClockOuts/time_entry_dao.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
class TimeEntryDao {

CONTAINER_ID = 'time_entry';

constructor(database) {
this.container = database.container(this.CONTAINER_ID);
const CONTAINER_ID = 'time_entry';
this.container = database.container(CONTAINER_ID);
}

async getEntriesWithNoEndDate () {
const QUERY_WITHOUT_END_DATE =
"SELECT * FROM c WHERE (NOT IS_DEFINED(c.end_date) OR IS_NULL(c.end_date) = true) AND IS_DEFINED(c.start_date)";
"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)";
return this.container.items
.query({query: QUERY_WITHOUT_END_DATE})
.fetchAll();
Expand Down