Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pivot table #71

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 31 additions & 2 deletions data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CuratorsDocument,
} from '../model/day0-case';
import caseFields from '../model/fields.json';
import { CaseStatus } from '../types/enums';
import { Error, Query } from 'mongoose';
import { ObjectId } from 'mongodb';
import { GeocodeOptions, Geocoder, Resolution } from '../geocoding/geocoder';
Expand Down Expand Up @@ -500,14 +501,25 @@ export class CasesController {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const countriesData: any = {};
// Get total case cardinality
const grandTotalCount = await Day0Case.countDocuments({});
const grandTotalCount = await Day0Case.countDocuments({
caseStatus: {
$nin: [CaseStatus.OmitError, CaseStatus.Discarded]
}
});
if (grandTotalCount === 0) {
res.status(200).json({});
return;
}

// Get cardinality of case statuses by country
const countriesStatusCounts = await Day0Case.aggregate([
{
$match: {
caseStatus: {
$nin: [CaseStatus.OmitError, CaseStatus.Discarded]
}
}
},
{
$group: {
_id: {
Expand Down Expand Up @@ -558,7 +570,10 @@ export class CasesController {
$exists: true,
$ne: null,
},
},
caseStatus: {
$nin: [CaseStatus.OmitError, CaseStatus.Discarded]
}
}
},
{
$group: {
Expand Down Expand Up @@ -625,6 +640,13 @@ export class CasesController {
// Get cardinality of case statuses total
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const totalStatusCount: any = await Day0Case.aggregate([
{
$match: {
caseStatus: {
$nin: [CaseStatus.OmitError, CaseStatus.Discarded]
}
}
},
{
$group: {
_id: '$caseStatus',
Expand Down Expand Up @@ -652,6 +674,13 @@ export class CasesController {

// Get cardinality of outcomes total
const totalOutcomeCount = await Day0Case.aggregate([
{
$match: {
caseStatus: {
$nin: [CaseStatus.OmitError, CaseStatus.Discarded]
}
}
},
{
$match: {
'events.outcome': {
Expand Down
2 changes: 0 additions & 2 deletions dev/Dockerfile-test
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ WORKDIR /app

COPY ./run_e2e_tests.sh ./
COPY ./setup_localstack.py ./
COPY ./setup_ingestion.py ./
COPY ./parsing.py ./
COPY ./test_e2e.py ./

CMD [ "./run_e2e_tests.sh" ]
2 changes: 1 addition & 1 deletion dev/docker-compose.dev.full.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
environment:
DEBUG: "True"
ENABLE_FAKE_GEOCODER: "True"
DB: "${DISEASE_NAME}"
curator:
command: "npm run dev"
volumes:
Expand Down Expand Up @@ -74,7 +75,6 @@ services:
dockerfile: Dockerfile-test
depends_on:
- mongo
- mock-source-data
- localstack
ports:
- "4444:4444"
Expand Down
6 changes: 0 additions & 6 deletions dev/run_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ set -eou pipefail

echo "Setting up localstack"
python3 setup_localstack.py
echo "Setting up ingestion environment"
python3 setup_ingestion.py
echo "Waiting for batch jobs"
sleep 10
echo "Running all parser batch jobs"
python3 parsing.py run

echo "Running end-to-end tests"
python3 -m pytest -rs -v .
Expand Down
Loading
Loading