Skip to content

[RELEASE] Gleaming Garnet #200

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

Merged
merged 88 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
b3887ab
[TM-2040] change ids for country landscapes
egrojMonroy May 28, 2025
8d5556d
[TM-2040] add bad request exception for not accepted landscapes
egrojMonroy May 29, 2025
db9e2e2
[TM-2040] Merge branch 'release/fanciful-flourite' into feat/TM-2040-…
egrojMonroy May 29, 2025
d1f3215
[TM-2040] Merge branch 'release/fanciful-flourite' into feat/TM-2040-…
egrojMonroy May 30, 2025
dac5dcf
[TM-2083] add tree restoration goal for profit tree count
egrojMonroy May 30, 2025
3803ddc
[TM-2083] add non profit and join queries
egrojMonroy May 30, 2025
ac21837
[TM-2083] add tree grown goal
egrojMonroy May 30, 2025
c086e2e
Merge pull request #186 from wri/main
Scriptmatico May 30, 2025
b2fcae6
[TM-2049] add project short name column filter
pachonjcl Jun 1, 2025
81a9d25
[TM-2040] update for tests
egrojMonroy Jun 2, 2025
b21d145
[TM-2083] [TM-2040] add trees under restoration
egrojMonroy Jun 2, 2025
300fd91
[TM-2083] [TM-2040] cache results for improving timing
egrojMonroy Jun 2, 2025
3590ed7
[TM-2083] improve quering
egrojMonroy Jun 2, 2025
c2320f4
[TM-2088] add loadAssociationData method to entity processors
Scriptmatico Jun 2, 2025
430863f
[TM-2083] add unit tests
egrojMonroy Jun 2, 2025
cf1b65f
[TM-2088] feat: update loadAssociationData method to accept a single …
Scriptmatico Jun 2, 2025
6b58454
[TM-2088] feat: update loadAssociationData method to accept an array …
Scriptmatico Jun 2, 2025
0692004
[TM-2040] Merge branch 'staging' into feat/TM-2040-fix-id-country-lan…
egrojMonroy Jun 2, 2025
2e00626
Merge pull request #185 from wri/feat/TM-2040-fix-id-country-landscapes
egrojMonroy Jun 2, 2025
7b02429
[TM-2040] boundingbox in gateway
egrojMonroy Jun 3, 2025
10f28e1
Merge pull request #189 from wri/feat/TM-2040-add-bounding-box-to-gat…
egrojMonroy Jun 3, 2025
de06ea2
[TM-2088] feat: update loadAssociationData method signatures to retur…
Scriptmatico Jun 3, 2025
3340f70
[TM-2040] add trailing in boundingbox resource
egrojMonroy Jun 3, 2025
01ac599
[TM-2040] add suffix for boundingbox service
egrojMonroy Jun 3, 2025
ba1487d
Merge pull request #190 from wri/fix/TM-2040-add-trailing-line
egrojMonroy Jun 3, 2025
fe3001c
[TM-2083] Merge branch 'staging' into feat/TM-2083-tree-restoration-g…
egrojMonroy Jun 3, 2025
80d6f6a
[TM-2083] fix data for due date arrays
egrojMonroy Jun 4, 2025
e41d04f
[TM-2088] feat: add mock implementation for loadAssociationData in En…
Scriptmatico Jun 4, 2025
8985032
[TM-2049] fix lint
pachonjcl Jun 4, 2025
fb32944
[TM-2088] feat: implement loadAssociationData method in multiple proc…
Scriptmatico Jun 4, 2025
c4b2dde
[TM-2083] add date for caching
egrojMonroy Jun 4, 2025
2da2bea
Merge pull request #187 from wri/feat/TM-2049_project_short_names
pachonjcl Jun 4, 2025
7119434
[TM-2103] add impact story controller
LimberHope Jun 5, 2025
83d3a01
[TM-2103] remove unnecessary types
LimberHope Jun 5, 2025
34d7689
[TM-2103] fix lint
LimberHope Jun 5, 2025
521eab0
[TM-2054] Include "all" in jobs collections.
roguenet Jun 6, 2025
8e423fe
[TM-2049] add filter project short names
pachonjcl Jun 9, 2025
f45a452
[TM-2103] [TM-1554] improve code and update .spec files
LimberHope Jun 9, 2025
6ed2869
[TM-2103] [TM-1554]update .spec files
LimberHope Jun 9, 2025
dda7321
[TM-2083] change some datatype
egrojMonroy Jun 9, 2025
d763aa7
[TM-2083] Merge branch 'staging' into feat/TM-2083-tree-restoration-g…
egrojMonroy Jun 9, 2025
a757b58
[TM-2054] Add associates type.
roguenet Jun 9, 2025
9a1d831
[TM-2103] update query sort and filters
LimberHope Jun 9, 2025
2ae4bb6
[TM-2103] fix lint
LimberHope Jun 9, 2025
08e8e49
[TM-2103] update unit test
LimberHope Jun 9, 2025
c3256ac
[TM-2083] add goals instead of percentage
egrojMonroy Jun 9, 2025
69904a4
[TM-1994] Add new collections for Fundo Flora
roguenet Jun 9, 2025
89b3ae1
[TM-1994] Add FF framework.
roguenet Jun 9, 2025
cae7a22
[TM-2103] improve code and update unit test
LimberHope Jun 9, 2025
47ed0e4
[TM-2103] improve code and update unit test
LimberHope Jun 9, 2025
e00db12
[TM-2103] change content type field
LimberHope Jun 10, 2025
145f045
[TM-2088] feat: refactor loadAssociationData to return association da…
Scriptmatico Jun 10, 2025
681b1a7
[TM-2103] apply review feedback on impact stories service and entity
LimberHope Jun 10, 2025
14ba4e0
[TM-2103] remove unnecessary imports
LimberHope Jun 10, 2025
dc946fa
[TM-2088] feat: enhance loadAssociationData method to support string …
Scriptmatico Jun 10, 2025
ba9c36b
[TM-2088] feat: update loadAssociationData to handle empty site and s…
Scriptmatico Jun 10, 2025
86998c0
[TM-2088] feat: add mock implementation for loadAssociationData in En…
Scriptmatico Jun 10, 2025
2a5c033
[TM-2088] feat: add placeholder for loadAssociationData method in ent…
Scriptmatico Jun 10, 2025
78f0b4f
[TM-2103] remove unnecessary imports
LimberHope Jun 10, 2025
d509333
[TM-2083] fix no cache response
egrojMonroy Jun 10, 2025
977f49d
[TM-2049] improve typing and naming variables
pachonjcl Jun 10, 2025
c914e83
Merge pull request #196 from wri/feat/TM-2054-demographics-schema-edits
roguenet Jun 10, 2025
303059b
Merge pull request #197 from wri/feat/TM-1994-fundo-flora-demographics
roguenet Jun 10, 2025
7697106
[TM-2083] add to cache a callback and return json api if no cache
egrojMonroy Jun 10, 2025
19e45be
[TM-2083] remove unused variable
egrojMonroy Jun 10, 2025
69ba05d
[TM-2083] fix unit tests
egrojMonroy Jun 10, 2025
59b5539
Merge pull request #195 from wri/feat/TM-2049_project_short_names_res…
pachonjcl Jun 10, 2025
f3ca35c
[TM-2083] condense !== undef && !== null => !=null
egrojMonroy Jun 10, 2025
2265c4f
[TM-2103] changes
LimberHope Jun 10, 2025
8294962
[TM-2103] remove bool filter
LimberHope Jun 10, 2025
d408740
Merge pull request #188 from wri/feat/TM-2083-tree-restoration-goals
egrojMonroy Jun 10, 2025
e276b75
Merge pull request #192 from wri/feat/TM-2103_dashboard_migrate_impac…
LimberHope Jun 10, 2025
dff1952
[TM-2068] Add financial indicators to airtable.
roguenet Jun 10, 2025
ae371c2
[TM-2103] fix uuid type
LimberHope Jun 10, 2025
f07401a
Merge pull request #199 from wri/feat/TM-2103_dashboard_migrate_impac…
LimberHope Jun 10, 2025
69ae191
Merge pull request #198 from wri/feat/TM-2068-financial-indicators-ai…
roguenet Jun 10, 2025
7c95fec
[TM-2088] feat: update Project DTO to allow nullable treesPlantedCoun…
Scriptmatico Jun 10, 2025
9de624e
[TM-2088] feat: update getLightDto method in ProjectProcessor to acce…
Scriptmatico Jun 10, 2025
db8175b
[TM-2088] feat: remove unused Project import and add eslint directive…
Scriptmatico Jun 10, 2025
c75141d
[TM-2088] feat: enhance loadAssociationData method with comprehensive…
Scriptmatico Jun 11, 2025
6725b6c
[TM-2088] update test for loadAssociationData to use ts-expect-error …
Scriptmatico Jun 11, 2025
6ae0f2e
[TM-2088] test: update loadAssociationData test to handle nullable tr…
Scriptmatico Jun 11, 2025
9cb988d
[TM-2088] ignore method for unit test
Scriptmatico Jun 11, 2025
3d00ec3
[TM-2068] Add the missing "year" field.
roguenet Jun 11, 2025
d2ba455
Merge pull request #202 from wri/feat/TM-2068-financial-indicator-year
roguenet Jun 11, 2025
c6f033b
Merge pull request #191 from wri/feat/TM-2088-Add-support-for-trees-p…
Scriptmatico Jun 11, 2025
75723a5
[TM-2150] change expiration for token in reset password
pachonjcl Jun 12, 2025
43593f6
Merge pull request #203 from wri/fix/TM-2150_change_reset_password_ex…
pachonjcl Jun 12, 2025
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
7 changes: 5 additions & 2 deletions apps/dashboard-service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { CacheService } from "./dashboard/dto/cache.service";
import { RedisModule } from "@nestjs-modules/ioredis";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { DashboardProcessor } from "./dashboard/worker/dashboard.processor";
import { TreeRestorationGoalController } from "./dashboard/tree-restoration-goal.controller";
import { TreeRestorationGoalService } from "./dashboard/dto/tree-restoration-goal.service";

@Module({
imports: [
Expand All @@ -30,15 +32,16 @@ import { DashboardProcessor } from "./dashboard/worker/dashboard.processor";
}),
BullModule.registerQueue({ name: "dashboard" })
],
controllers: [TotalSectionHeaderController],
controllers: [TotalSectionHeaderController, TreeRestorationGoalController],
providers: [
{
provide: APP_FILTER,
useClass: SentryGlobalFilter
},
TotalSectionHeaderService,
CacheService,
DashboardProcessor
DashboardProcessor,
TreeRestorationGoalService
]
})
export class AppModule {}
24 changes: 23 additions & 1 deletion apps/dashboard-service/src/dashboard/dto/cache.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,33 @@ describe("CacheService", () => {
expect(result).toBe("not-json");
});

it("should return null if redis returns null", async () => {
it("should return null if redis returns null and no factory provided", async () => {
(redisMock.get as jest.Mock).mockResolvedValue(null);
const result = await service.get("key1");
expect(result).toBeNull();
});

it("should use factory to generate and cache value when cache miss", async () => {
(redisMock.get as jest.Mock).mockResolvedValue(null);
const factory = jest.fn().mockResolvedValue({ newData: "value" });

const result = await service.get("key1", factory);

expect(factory).toHaveBeenCalled();
expect(redisMock.set).toHaveBeenCalledWith("key1", JSON.stringify({ newData: "value" }));
expect(result).toEqual({ newData: "value" });
});

it("should handle string values from factory", async () => {
(redisMock.get as jest.Mock).mockResolvedValue(null);
const factory = jest.fn().mockResolvedValue("string value");

const result = await service.get("key1", factory);

expect(factory).toHaveBeenCalled();
expect(redisMock.set).toHaveBeenCalledWith("key1", "string value");
expect(result).toBe("string value");
});
});

describe("getCacheKeyFromQuery", () => {
Expand Down
25 changes: 18 additions & 7 deletions apps/dashboard-service/src/dashboard/dto/cache.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,27 @@ export class CacheService {
await this.redis.set(key, value);
}

async get(key: string) {
async get(key: string, factory?: () => Promise<string | object>) {
const data = await this.redis.get(key);
if (typeof data === "string") {
try {
return JSON.parse(data);
} catch {
return data;
if (data !== null) {
if (typeof data === "string") {
try {
return JSON.parse(data);
} catch {
return data;
}
}
return data;
}
return data;

if (factory != null) {
const result = await factory();
const valueToStore = typeof result === "string" ? result : JSON.stringify(result);
await this.redis.set(key, valueToStore);
return result;
}

return null;
}

async del(key: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { JsonApiDto } from "@terramatch-microservices/common/decorators";
import { ApiProperty } from "@nestjs/swagger";
import { populateDto } from "@terramatch-microservices/common/dto/json-api-attributes";

class TreeRestorationData {
@ApiProperty({
description: "Due date for this restoration data"
})
dueDate: Date;

@ApiProperty({
description: "Number of tree species for this period"
})
treeSpeciesAmount: number;

@ApiProperty({
description: "Tree species goal for calculating percentage"
})
treeSpeciesGoal: number;
}

@JsonApiDto({ type: "treeRestorationGoals" })
export class TreeRestorationGoalDto {
constructor(data: TreeRestorationGoalDto) {
populateDto<TreeRestorationGoalDto>(this, data);
}

@ApiProperty({
description: "Total number of trees grown goal for for-profit organizations"
})
forProfitTreeCount: number;

@ApiProperty({
description: "Total number of trees grown goal for non-profit organizations"
})
nonProfitTreeCount: number;

@ApiProperty({
description: "Total trees grown goal across all organizations"
})
totalTreesGrownGoal: number;

@ApiProperty({
description: "Trees under restoration data across all organizations by due date",
type: [TreeRestorationData]
})
treesUnderRestorationActualTotal: TreeRestorationData[];

@ApiProperty({
description: "Trees under restoration data for for-profit organizations by due date",
type: [TreeRestorationData]
})
treesUnderRestorationActualForProfit: TreeRestorationData[];

@ApiProperty({
description: "Trees under restoration data for non-profit organizations by due date",
type: [TreeRestorationData]
})
treesUnderRestorationActualNonProfit: TreeRestorationData[];

@ApiProperty({
description: "Timestamp when the data was last updated",
type: String,
nullable: true
})
lastUpdatedAt: string | null;
}
Loading
Loading