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

Test #1162

Closed
wants to merge 153 commits into from
Closed

Test #1162

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
3df0cd5
Add carto apikey name to api conf and default dotenv
alexeh Feb 21, 2024
ff89243
Add eudr module scaffold
alexeh Feb 23, 2024
0427129
Queue for eudr import
alexeh Feb 26, 2024
fae866c
Bypass queue and parse file
alexeh Feb 26, 2024
5783f2a
Add wellknown to parse WKT to Geom
alexeh Feb 27, 2024
111bddb
Add companyId to supplier entity
alexeh Feb 27, 2024
376a3de
Add totalArea to georegion entity
alexeh Feb 27, 2024
c9e7e8e
Adds EUDR location type
alexeh Feb 27, 2024
e5d3fac
First approach saving eudr ingested data
alexeh Feb 27, 2024
1b90097
transactional save
alexeh Feb 27, 2024
1bbe26d
Add address for company
alexeh Feb 27, 2024
5d6adb0
Fallback to intersection when no adminregion found by district name
alexeh Feb 27, 2024
ff1d3a0
generate fake output csv
alexeh Feb 27, 2024
d51a5e9
Add carto tmp carto connector
alexeh Feb 27, 2024
57d9892
retrieve eudr materials
alexeh Feb 27, 2024
19abf1c
retrieve eudr suppliers
alexeh Feb 27, 2024
edc03a3
retrieve eudr admin-regions
alexeh Feb 27, 2024
66ab6c4
Type EUDR dtos
alexeh Feb 28, 2024
b8c56d1
Add initial get eudr georegions
alexeh Feb 28, 2024
e5a0050
Fix pg json equality operator error, add tests
alexeh Feb 28, 2024
6867a97
eudr admin region filter tests
alexeh Feb 29, 2024
596d9a6
Improve testing framework, add tests for eudr admin-regions
alexeh Feb 29, 2024
294f60e
Refactor eudr related endpoints to eudr controller
alexeh Feb 29, 2024
22168c0
add EUDR output shape class
alexeh Feb 29, 2024
7c2975b
Add bigquery client
alexeh Mar 2, 2024
39982af
Stream alerts response back
alexeh Mar 3, 2024
a972cdc
Refactor setupUser test utility
alexeh Mar 3, 2024
3effc68
Mock eudr repository
alexeh Mar 3, 2024
b2c4e89
Fix regressions, leave legit failing tests until further decisions ab…
alexeh Mar 4, 2024
84185ee
Endpoint to retrieve filtered EUDR Alerts
alexeh Mar 4, 2024
1d0fe38
Dates endpoint
alexeh Mar 5, 2024
b4858f2
Add swagger spec file generation
alexeh Mar 5, 2024
8d4f44c
add eudr credentials k8s secret and eudr dataset api env var
alexeh Mar 5, 2024
ebee872
Adds reverse index to sourcing location georegionid column
alexeh Mar 6, 2024
51f77b1
Adds geo-features.service.ts
alexeh Mar 6, 2024
af397c1
Get Features and FeatureCollection, update swagger spec
alexeh Mar 6, 2024
d3850a0
geo-features tests
alexeh Mar 6, 2024
bc53ccb
clean-up testing flow
alexeh Mar 6, 2024
145b15d
Add entity filters for geo-features
alexeh Mar 6, 2024
2b41f81
Add metadata to geo features
alexeh Mar 7, 2024
c8d07bc
internal param supplier type optional
alexeh Mar 7, 2024
316a403
wrap eudr alert dates in data prop
alexeh Mar 7, 2024
817ac38
update kubectl install gh workflow
alexeh Mar 8, 2024
c378dd3
eudr dashboard first version
alexeh Mar 8, 2024
8821d95
add filters for dashboard
alexeh Mar 8, 2024
acbec43
First working dashboard breakdown version
alexeh Mar 9, 2024
6170749
stronger type safety
alexeh Mar 10, 2024
c396ca4
eudr dashboard detail
alexeh Mar 11, 2024
37647f8
eudr dashboard cleanup
alexeh Mar 12, 2024
5227314
remove data root prop from dashboard responses
alexeh Mar 12, 2024
7fd4ec6
Save georegions with no name and no geom
alexeh Mar 12, 2024
fac3597
filter out geoRegions with no geom
alexeh Mar 12, 2024
31b648d
get material and origin descendants for dashboard filters
alexeh Mar 12, 2024
d38a2cc
Add alert filter by georegion
alexeh Mar 12, 2024
06e6ac4
add isoA3 to table origins and breakdown origins
alexeh Mar 12, 2024
4b45368
Do not save missing geometries as georegions
alexeh Mar 13, 2024
708a2db
Update approach to calculate percentage of missing georegions per sup…
alexeh Mar 13, 2024
1dd9063
Add plotName and id to byVolume dashboard detail
alexeh Mar 13, 2024
d8010b5
handle unknown georegions, aggregate volumes to unknown
alexeh Mar 14, 2024
f9617d5
group plots by alert date in eudr dashboard detail alerts
alexeh Mar 14, 2024
adcfe67
bigquery builder unit tests
alexeh Mar 14, 2024
2cb79de
calculate volume percentage by year, fix total plot area sum
alexeh Mar 15, 2024
ab4f5de
Refactor approach to calculate alert values
alexeh Mar 17, 2024
7d55245
Add company address to import
alexeh Mar 18, 2024
2ce91ee
update field names in bigquerybuilder
alexeh Mar 18, 2024
b8724f5
Add total carbon removals to dashboard and detail
alexeh Mar 18, 2024
98fec7e
migration from Mapbox GL to MapLibre GL
davidsingal Feb 22, 2024
d209b09
eudr page and layout
davidsingal Feb 28, 2024
1adfe62
added supplier chart
davidsingal Mar 1, 2024
a4fd6a4
adding filters to eudr page
davidsingal Mar 1, 2024
3c2b565
updated test for map
davidsingal Feb 22, 2024
d56793d
fixed image resolution and zoom compatibility
davidsingal Mar 5, 2024
d7f5ebe
eudr - suppliers breakdown foundation
andresgnlez Mar 4, 2024
41e07e7
eudr store setup
andresgnlez Mar 5, 2024
459c1cb
eudr - categories breakdown
andresgnlez Mar 5, 2024
503da47
edur - data table
andresgnlez Mar 6, 2024
8889798
added geosjon layer
davidsingal Mar 6, 2024
486abad
added toogle legend
davidsingal Mar 6, 2024
111c9ec
added legend styles
davidsingal Mar 7, 2024
a49dc55
added plot geometries from api
davidsingal Mar 7, 2024
3b4702b
starts connecting filters and fetching of filters
andresgnlez Mar 7, 2024
09dd506
minor styling
andresgnlez Mar 8, 2024
f786dec
EUDR: API connection
andresgnlez Mar 12, 2024
29a7e3c
adds georegions param
andresgnlez Mar 12, 2024
0b2f24f
moves Date object away from store
andresgnlez Mar 12, 2024
5dc6480
updates labels of tooltip
andresgnlez Mar 12, 2024
0d72d4d
updates ISO field
andresgnlez Mar 12, 2024
5cde3a9
EUDR detail page
andresgnlez Mar 12, 2024
1a7f01e
wip
davidsingal Mar 7, 2024
b9b3612
tooltip for plot layer
davidsingal Mar 11, 2024
cae9b2c
planet and dual view
davidsingal Mar 11, 2024
7d9fbad
added legend, basemap selector
davidsingal Mar 13, 2024
13c2a77
basemap selector
davidsingal Mar 13, 2024
7ea0122
planet comparison and contextual layers
davidsingal Mar 14, 2024
17f6aec
fixed types for layer
davidsingal Mar 14, 2024
6146fee
redirects to eudr page after signin
andresgnlez Mar 14, 2024
a7b4d8e
removes old tailwind.config.js
andresgnlez Mar 14, 2024
edab98f
updates redirect of signin test
andresgnlez Mar 14, 2024
b6cffc9
navigation menu: updates EUDR icon, disables other links
andresgnlez Mar 14, 2024
911dfda
fixes svg properties
andresgnlez Mar 15, 2024
8f7a898
adds info buttons to charts
andresgnlez Mar 15, 2024
88a07f6
fixed bug navigating to detail; removed fitbounsd; added radd layer
davidsingal Mar 15, 2024
cb15afa
slider range for legend
davidsingal Mar 15, 2024
4b99dd0
ensures x-axis domain is calculated properly in alerts chart
andresgnlez Mar 18, 2024
3b157f4
adds CRM column to suppliers table
andresgnlez Mar 18, 2024
12f570c
supplier detail: adds carbon removal info to sourcing information
andresgnlez Mar 18, 2024
2342765
passes filters to plot geometries hook
andresgnlez Mar 18, 2024
f35070c
adds placeholders for feching and no data in charts
andresgnlez Mar 18, 2024
913d35e
fixes client Docker image
andresgnlez Mar 18, 2024
2a8fe8a
fixed opacity for layers
davidsingal Mar 18, 2024
0fbc13f
added planet dates
davidsingal Mar 18, 2024
0ee456d
fixed total number of suppliers
davidsingal Mar 19, 2024
10837c6
fixed typo
davidsingal Mar 19, 2024
3831dfe
retrieves carbon removal data correctly
andresgnlez Mar 19, 2024
de0f9a4
passes geoRegionIds parameter correctly
andresgnlez Mar 19, 2024
93188d6
makes filters reactive
andresgnlez Mar 19, 2024
aaf3cbd
triggers map comparison from alerts chart
andresgnlez Mar 19, 2024
c54ec52
adds table filters
andresgnlez Mar 19, 2024
2a48c9a
add dfs and sda georegionids by supplier
alexeh Mar 19, 2024
59bb2f0
add dfs * sda georegion ids for dashboard detail
alexeh Mar 19, 2024
a5f4237
fix swagger doc for dfs sda georegion ids
alexeh Mar 19, 2024
bfe2b45
skipping tests conditionally
andresgnlez Mar 19, 2024
9eab30b
fixes EUDR redirect
andresgnlez Mar 20, 2024
427041c
connect real output, remove carbon_removals from query and set value …
alexeh Mar 20, 2024
edabac5
fit plots to bounds when data is fetched or changed
davidsingal Mar 20, 2024
fc61203
display plots based on dfs/sda values
andresgnlez Mar 19, 2024
3cac2ad
filter geometries by category - WIP
andresgnlez Mar 19, 2024
8253f26
fixes duplicating content of category collapsible
andresgnlez Mar 20, 2024
74bd359
keeps collapsibles open based on redux values
andresgnlez Mar 20, 2024
d2a7278
max bounds and max zoom for eudr page
davidsingal Mar 20, 2024
97ba366
group by month and fill in missing months
alexeh Mar 20, 2024
06e3150
add all plots to all alert dates
alexeh Mar 20, 2024
eca9647
return full detail result
alexeh Mar 20, 2024
3577dc8
tracks zero alerts in alerts deforestation chart
andresgnlez Mar 20, 2024
3399d5e
fallback for geometries
andresgnlez Mar 20, 2024
08cba95
hides tooltip for deforestation alerts chart
andresgnlez Mar 20, 2024
3709f8c
changes category names
andresgnlez Mar 20, 2024
ac1d30d
of suppliers
andresgnlez Mar 20, 2024
eebaf76
updates column names
andresgnlez Mar 20, 2024
2526e72
updates legend with plots
andresgnlez Mar 20, 2024
c40cdfe
updates title of sourcing information chart
andresgnlez Mar 20, 2024
04b13a8
updates label
andresgnlez Mar 20, 2024
95203b4
removes tooltips
andresgnlez Mar 20, 2024
25e0da9
compare map with maplibre
davidsingal Mar 20, 2024
70ea150
fixed compare for the map
davidsingal Mar 20, 2024
134a77e
fixed 500 after fitbounds
davidsingal Mar 20, 2024
307fbb5
fixed compare
davidsingal Mar 20, 2024
112aa63
last minute fixes
davidsingal Mar 20, 2024
889ef43
descendant search for material and origin plot geojsons
alexeh Mar 21, 2024
0f61f9a
env variables; basemap as react map gl layers; better styles for drag…
davidsingal Mar 21, 2024
ab5febd
added temporally env variables cc Alex
davidsingal Mar 21, 2024
bf9022b
legend updates
andresgnlez Mar 21, 2024
b8731ea
disabling tree data node in all filters
davidsingal Mar 21, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/deploy-to-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ jobs:

- name: Install kubectl
run: |
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/kubernetes-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o --no-tty /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
sudo apt install -y kubectl

- name: Config kubectl
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/testing-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ jobs:
working-directory: api
run: yarn test:integration

testing-api-unit:
name: Unit Tests
runs-on: ubuntu-22.04
timeout-minutes: 30

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 18.16
uses: actions/setup-node@v3
with:
node-version: '18.16'

- name: Install API dependencies
working-directory: api
run: yarn install

- name: Run API tests + coverage
working-directory: api
run: yarn test:unit

# - name: Generate API coverage artifact
# uses: actions/upload-artifact@v2
# with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/testing-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
name: Running client tests
runs-on: ubuntu-22.04
timeout-minutes: 30
if: ${{ github.ref_name != 'test' }}
strategy:
fail-fast: false
defaults:
Expand Down
6 changes: 6 additions & 0 deletions api/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@
"email": {
"sendGridApiKey": "SENDGRID_API_KEY"
}
},
"eudr": {
"apiKey": "CARTO_API_KEY",
"baseUrl": "CARTO_BASE_URL",
"credentials": "EUDR_CREDENTIALS",
"dataset": "EUDR_DATASET"
}
}
6 changes: 6 additions & 0 deletions api/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@
"email": {
"sendGridApiKey": null
}
},
"eudr": {
"apiKey": null,
"baseUrl": "null",
"credentials": null,
"dataset": null
}
}
6 changes: 6 additions & 0 deletions api/config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@
"email": {
"sendGridApiKey": "SG.forSomeReasonSendGridApiKeysNeedToStartWithSG."
}
},
"eudr": {
"apiKey": null,
"baseUrl": "null",
"credentials": null,
"dataset": "test_dataset"
}
}
4 changes: 4 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
"test:cov": "node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --coverage --forceExit",
"test:debug": "node --inspect-brk --expose-gc -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --config test/jest-config.json --detectOpenHandles --forceExit",
"test:integration": "node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --forceExit -i test/integration/",
"test:unit": "node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --forceExit -i test/unit/",
"test:e2e": "NODE_OPTIONS=\"--max-old-space-size=6144\" node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --logHeapUsage --forceExit -i test/e2e/"
},
"engines": {
"node": "^18.16"
},
"dependencies": {
"@google-cloud/bigquery": "^7.5.0",
"@googlemaps/google-maps-services-js": "~3.3.2",
"@json2csv/node": "^7.0.1",
"@nestjs/axios": "^3.0.0",
Expand Down Expand Up @@ -69,6 +71,7 @@
"swagger-ui-express": "~4.6.0",
"typeorm": "0.3.11",
"uuid": "~9.0.0",
"wellknown": "^0.5.0",
"xlsx": "~0.18.5",
"yargs": "^17.3.1"
},
Expand All @@ -85,6 +88,7 @@
"@types/config": "^3.3.0",
"@types/express": "^4.17.13",
"@types/faker": "^6.6.9",
"@types/geojson": "^7946.0.14",
"@types/jest": "^29.5.3",
"@types/jsonapi-serializer": "^3.6.5",
"@types/lodash": "^4.14.177",
Expand Down
2 changes: 2 additions & 0 deletions api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { AuthorizationService } from 'modules/authorization/authorization.servic
import { TasksService } from 'modules/tasks/tasks.service';
import { NotificationsModule } from 'modules/notifications/notifications.module';
import { ReportsModule } from 'modules/reports/reports.module';
import { EudrModule } from 'modules/eudr-alerts/eudr.module';

const queueConfig: any = config.get('queue');

Expand Down Expand Up @@ -84,6 +85,7 @@ const queueConfig: any = config.get('queue');
AuthorizationModule,
NotificationsModule,
ReportsModule,
EudrModule,
],
providers: [
{
Expand Down
35 changes: 35 additions & 0 deletions api/src/create-swagger-specification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as fs from 'fs';
import * as crypto from 'crypto';
import * as process from 'process';

function hashContent(content: string): string {
return crypto.createHash('sha256').update(content).digest('hex');
}

const active: boolean = false;

export async function createOrUpdateSwaggerSpec(document: any): Promise<void> {
if (active && process.env.NODE_ENV == 'development') {
const documentString: string = JSON.stringify(document);
const currentHash: string = hashContent(documentString);

const specPath: string = './swagger-spec.json';
if (fs.existsSync(specPath)) {
const existingSpec: string = fs.readFileSync(specPath, 'utf8');
const existingHash: string = hashContent(existingSpec);

if (currentHash !== existingHash) {
console.log('Swagger spec has changed. Updating...');
fs.writeFileSync(specPath, documentString);
} else {
console.log('No changes in Swagger spec.');
}
} else {
console.log('Swagger spec does not exist. Creating...');
fs.writeFileSync(specPath, documentString);
}
} else {
console.log('Swagger spec update is not active.');
return;
}
}
9 changes: 9 additions & 0 deletions api/src/guards/sensitive-info.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ export class SensitiveInfoGuard implements NestInterceptor {
context: ExecutionContext,
next: CallHandler<any>,
): Observable<any> {
const request = context.switchToHttp().getRequest();
if (this.dataComesFromAStreamEndpoint(request.url)) {
return next.handle();
}

return next.handle().pipe(map((data: any) => instanceToPlain(data)));
}

dataComesFromAStreamEndpoint(url: string): boolean {
return url.includes('eudr');
}
}
3 changes: 3 additions & 0 deletions api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as compression from 'compression';
import { JwtAuthGuard } from 'guards/jwt-auth.guard';
import { useContainer } from 'class-validator';
import { SensitiveInfoGuard } from 'guards/sensitive-info.guard';
import { createOrUpdateSwaggerSpec } from 'create-swagger-specification';

async function bootstrap(): Promise<void> {
const logger: Logger = new Logger('bootstrap');
Expand Down Expand Up @@ -35,6 +36,8 @@ async function bootstrap(): Promise<void> {
);
SwaggerModule.setup('/swagger', app, swaggerDocument);

await createOrUpdateSwaggerSpec(swaggerDocument);

app.useGlobalPipes(
new ValidationPipe({
forbidUnknownValues: true,
Expand Down
5 changes: 4 additions & 1 deletion api/src/modules/admin-regions/admin-regions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import { CreateAdminRegionDto } from 'modules/admin-regions/dto/create.admin-reg
import { UpdateAdminRegionDto } from 'modules/admin-regions/dto/update.admin-region.dto';
import { PaginationMeta } from 'utils/app-base.service';
import { ApiOkTreeResponse } from 'decorators/api-tree-response.decorator';
import { GetAdminRegionTreeWithOptionsDto } from 'modules/admin-regions/dto/get-admin-region-tree-with-options.dto';
import {
GetAdminRegionTreeWithOptionsDto,
GetEUDRAdminRegions,
} from 'modules/admin-regions/dto/get-admin-region-tree-with-options.dto';
import { SetScenarioIdsInterceptor } from 'modules/impact/set-scenario-ids.interceptor';

@Controller(`/api/v1/admin-regions`)
Expand Down
4 changes: 0 additions & 4 deletions api/src/modules/admin-regions/admin-regions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ export class AdminRegionsService extends AppBaseService<
return this.findTreesWithOptions({ depth: adminRegionTreeOptions.depth });
}

async getAdminRegionByIds(ids: string[]): Promise<AdminRegion[]> {
return this.adminRegionRepository.findByIds(ids);
}

/**
* @description: Returns an array of all children of given Admin Region's Ids with optional parameters
* @param {string[]} adminRegionIds - The IDs of the admin regions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { IsBoolean, IsNumber, IsOptional, IsUUID } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { CommonFiltersDto } from 'utils/base.query-builder';
import { ApiPropertyOptional, OmitType } from '@nestjs/swagger';
import {
CommonEUDRFiltersDTO,
CommonFiltersDto,
} from 'utils/base.query-builder';
import { Type } from 'class-transformer';

export class GetAdminRegionTreeWithOptionsDto extends CommonFiltersDto {
Expand All @@ -24,3 +27,7 @@ export class GetAdminRegionTreeWithOptionsDto extends CommonFiltersDto {
@IsUUID('4')
scenarioId?: string;
}

export class GetEUDRAdminRegions extends CommonEUDRFiltersDTO {
withSourcingLocations!: boolean;
}
Loading
Loading