Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into reprocess-state
Browse files Browse the repository at this point in the history
  • Loading branch information
gferraro committed Jul 5, 2021
2 parents cfd8d33 + d2e1c01 commit 8768699
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions api/V1/monitoringPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const BEFORE_CACOPHONY = new Date(2017, 1, 1);

const LAST_TIMES_TABLE = `with lasttimes as
(select "recordingDateTime", "DeviceId", "GroupId",
LAG("recordingDateTime", 1) OVER
(PARTITION BY "DeviceId" ORDER BY "recordingDateTime")
lasttime from "Recordings"
LAG("recordingDateTime", 1) OVER (PARTITION BY "DeviceId" ORDER BY "recordingDateTime") lasttime,
LAG("duration", 1) OVER (PARTITION BY "DeviceId" ORDER BY "recordingDateTime") lastduration
from "Recordings"
where "recordingDateTime" is not NULL
and type = 'thermalRaw'
and duration > 0
Expand All @@ -40,7 +40,7 @@ const LAST_TIMES_TABLE = `with lasttimes as
)`;

const WHERE_IS_VISIT_START = `where "lasttime" is NULL
or extract(epoch from "recordingDateTime") - extract(epoch from "lasttime") > 600`;
or extract(epoch from "recordingDateTime") - extract(epoch from "lasttime") - "lastduration" > 600`;

const VISITS_COUNT_SQL = `${LAST_TIMES_TABLE} select count(*) from "lasttimes" ${WHERE_IS_VISIT_START}`;

Expand Down
1 change: 0 additions & 1 deletion api/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export const toIdArray = function (fieldName: string): ValidationChain {

const convertToIdArray = function (idsAsString: string): number[] {
if (idsAsString) {
console.log(`value is ${idsAsString}`);
try {
const val = JSON.parse(idsAsString);
if (Array.isArray(val)) {
Expand Down
20 changes: 19 additions & 1 deletion test-cypress/cypress/integration/recordings/monitoring_paging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe("Monitoring : pagings", () => {

it("recordings are broken into approximate pages by start date", () => {
const camera = "basic";
const firstRecording = "10:03";

cy.apiCreateCamera(camera, group);
cy.uploadRecordingsAtTimes(camera, [
Expand Down Expand Up @@ -118,4 +117,23 @@ describe("Monitoring : pagings", () => {
[{ start: "21:03", incomplete: "true" }, { start: "21:40" }]
);
});

it("paging is correct even when time limit is only met by taking duration of video into account.", () => {
const camera = "visits-not-just-start";
cy.apiCreateCamera(camera, group);

cy.uploadRecording(camera, { time: "21:03", duration: 62 });
cy.uploadRecordingsAtTimes(camera, ["21:14", "21:50", "22:20"]);

cy.checkMonitoringWithFilter(
Veronica,
camera,
{ "page-size": 3, page: 1 },
[
{ recordings: 2, start: "21:03" },
{ start: "21:50" },
{ start: "22:20" }
]
);
});
});

0 comments on commit 8768699

Please sign in to comment.