Skip to content

Commit

Permalink
Merge pull request #266 from 18F/bugfix/domain_download_report_filtering
Browse files Browse the repository at this point in the history
[Bugfix] Filter domain download report correctly
  • Loading branch information
levinmr authored Aug 7, 2024
2 parents 63cf3e2 + 3249e3f commit 6cd6463
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const query = ({
const dbTable = version === "1.1" ? "analytics_data" : "analytics_data_ga4";
const limitParam = parseLimitParam(limit);
const pageParam = parsePageParam(page);
if (domain && reportName !== "download") {
if (domain) {
return queryDomain(
domain,
reportName,
Expand Down
134 changes: 62 additions & 72 deletions test/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,13 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
2,
1,
null,
null,
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 2,
page: 1,
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(2);
Expand Down Expand Up @@ -298,15 +296,13 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
1000,
1,
null,
null,
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 1000,
page: 1,
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(2);
Expand Down Expand Up @@ -340,15 +336,13 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
1000,
1,
null,
null,
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 1000,
page: 1,
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(2);
Expand Down Expand Up @@ -393,15 +387,13 @@ describe("db", () => {
.client(table)
.insert(testData)
.then(() => {
return db.queryDomain(
"test.gov",
"download",
1000,
1,
null,
null,
table,
);
return db.query({
domain: "test.gov",
reportName: "download",
limit: 1000,
page: 1,
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(4);
Expand Down Expand Up @@ -446,15 +438,14 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
1000,
1,
"2017-10-20",
null,
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 1000,
page: 1,
before: "2017-10-20",
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(2);
Expand Down Expand Up @@ -494,15 +485,14 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
1000,
1,
null,
"2017-10-20",
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 1000,
page: 1,
after: "2017-10-20",
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(1);
Expand Down Expand Up @@ -552,15 +542,15 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
1000,
1,
"2018-01-02",
"2017-10-20",
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 1000,
page: 1,
before: "2018-01-02",
after: "2017-10-20",
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(2);
Expand Down Expand Up @@ -610,15 +600,15 @@ describe("db", () => {
},
])
.then(() => {
return db.queryDomain(
"test.gov",
"site",
1000,
1,
"2018-01-04",
"2017-10-20",
table,
);
return db.query({
domain: "test.gov",
reportName: "site",
limit: 1000,
page: 1,
before: "2018-01-04",
after: "2017-10-20",
version: queryVersion,
});
})
.then((results) => {
expect(results).to.have.length(2);
Expand Down

0 comments on commit 6cd6463

Please sign in to comment.