Skip to content

Commit 400cb85

Browse files
Merge pull request #2091 from AletheiaFact/poc-verification-request-dashboard
Dashboard for data percentage view of verification request
2 parents 956a964 + 77b070b commit 400cb85

30 files changed

+1424
-240
lines changed

public/locales/en/timeAgo.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"minutesAgo_one": "{{count}} minute ago",
3+
"minutesAgo_other": "{{count}} minutes ago",
4+
"hoursAgo_one": "{{count}} hour ago",
5+
"hoursAgo_other": "{{count}} hours ago",
6+
"daysAgo_one": "{{count}} day ago",
7+
"daysAgo_other": "{{count}} days ago"
8+
}

public/locales/en/verificationRequest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@
8484
"viewFullPage": "View full page",
8585
"automated_monitoring": "Automated Monitoring",
8686
"filterBySourceChannel": "Filter by Source Channel",
87+
"activity": {
88+
"Posted": "Verification request #{{hash}} verified and forwarded",
89+
"In Triage": "Verification request #{{hash}} in the verification process",
90+
"Pre Triage": "New verification request received by {{source}}",
91+
"Declined": "Verification request #{{hash}} checked and archived"
92+
},
93+
"dashboard": {
94+
"title": "Reports Dashboard",
95+
"subtitle": "Transparency and public monitoring",
96+
"totalReports": "Total Reports",
97+
"verified": "Verified",
98+
"inAnalysis": "In Analysis",
99+
"pending": "Pending",
100+
"receivedThisMonth": "Received this month",
101+
"ofTotal": "of total",
102+
"sourcesTitle": "Report Sources",
103+
"sourcesSubtitle": "Distribution by reception channel",
104+
"statusTitle": "Report Status",
105+
"statusSubtitle": "Distribution by verification status",
106+
"activityTitle": "Recent Activity",
107+
"activitySubtitle": "Latest updates from the system",
108+
"errorLoading": "Error fetching statistics"
109+
},
87110
"errorUpdatingStatus": "Error updating status:",
88111
"identifiedPersonalities": "People Mentioned",
89112
"loadingPersonalities": "Loading personalities...",

public/locales/pt/timeAgo.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"minutesAgo_one": "Há {{count}} minuto",
3+
"minutesAgo_other": "Há {{count}} minutos",
4+
"hoursAgo_one": "Há {{count}} hora",
5+
"hoursAgo_other": "Há {{count}} horas",
6+
"daysAgo_one": "Há {{count}} dia",
7+
"daysAgo_other": "Há {{count}} dias"
8+
}

public/locales/pt/verificationRequest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@
8484
"viewFullPage": "Ver página completa",
8585
"automated_monitoring": "Monitoramento Automatizado",
8686
"filterBySourceChannel": "Filtrar por Canal de Origem",
87+
"activity": {
88+
"Posted": "Denúncia #{{hash}} verificada e encaminhada",
89+
"In Triage": "Denúncia #{{hash}} em processo de verificação",
90+
"Pre Triage": "Nova denúncia recebida via {{source}}",
91+
"Declined": "Denúncia #{{hash}} verificada e arquivada"
92+
},
93+
"dashboard": {
94+
"title": "Painel de Denúncias",
95+
"subtitle": "Transparência e acompanhamento público",
96+
"totalReports": "Total de Denúncias",
97+
"verified": "Verificadas",
98+
"inAnalysis": "Em Análise",
99+
"pending": "Pendentes",
100+
"receivedThisMonth": "Recebidas este mês",
101+
"ofTotal": "do total",
102+
"sourcesTitle": "Fontes de Denúncias",
103+
"sourcesSubtitle": "Distribuição por canal de recebimento",
104+
"statusTitle": "Status das Denúncias",
105+
"statusSubtitle": "Distribuição por estado de verificação",
106+
"activityTitle": "Atividade Recente",
107+
"activitySubtitle": "Últimas atualizações do sistema",
108+
"errorLoading": "Erro ao buscar as estatísticas"
109+
},
87110
"errorUpdatingStatus": "Erro ao atualizar status:",
88111
"identifiedPersonalities": "Pessoas Mencionadas",
89112
"loadingPersonalities": "Carregando personalidades...",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
interface StatsCount {
3+
total: number;
4+
totalThisMonth: number;
5+
verified: number;
6+
inAnalysis: number;
7+
pending: number;
8+
}
9+
10+
11+
interface StatsSourceChannels {
12+
label: string;
13+
value: number;
14+
percentage: number;
15+
}
16+
17+
18+
interface StatsRecentActivity {
19+
id: string;
20+
status: string;
21+
sourceChannel: string;
22+
data_hash: string;
23+
timestamp: Date;
24+
}
25+
26+
27+
interface StatsDto {
28+
statsCount: StatsCount;
29+
statsSourceChannels: StatsSourceChannels[];
30+
statsRecentActivity: StatsRecentActivity[];
31+
}
32+
33+
export type {
34+
StatsCount,
35+
StatsSourceChannels,
36+
StatsRecentActivity,
37+
StatsDto,
38+
};

server/verification-request/dto/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export enum VerificationRequestSourceChannel {
2222
Website = "Web",
2323
Instagram = "instagram",
2424
Whatsapp = "whatsapp",
25-
Telegram = "telegram",
2625
AutomatedMonitoring = "automated_monitoring",
2726
}
2827

@@ -85,3 +84,7 @@ export const EXPECTED_STATES = [
8584
"impactArea",
8685
"severity",
8786
];
87+
export interface TimeStamps {
88+
createdAt: Date;
89+
updatedAt: Date;
90+
}

server/verification-request/schemas/verification-request.schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import * as mongoose from "mongoose";
33
import { Group } from "../../group/schemas/group.schema";
44
import { Topic } from "../../topic/schemas/topic.schema";
55
import { ContentModelEnum } from "../../types/enums";
6-
import { SeverityEnum, VerificationRequestStatus } from "../dto/types";
6+
import { SeverityEnum, TimeStamps, VerificationRequestStatus } from "../dto/types";
77

88
export type VerificationRequestDocument = VerificationRequest &
9-
mongoose.Document;
9+
mongoose.Document & TimeStamps;
1010

1111
@Schema({ timestamps: true })
1212
export class VerificationRequest {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { Model } from "mongoose";
2+
import { Test, TestingModule } from "@nestjs/testing";
3+
import { getModelToken } from "@nestjs/mongoose";
4+
import { VerificationRequestStateMachineService } from "../../state-machine/verification-request.state-machine.service";
5+
import { SourceService } from "../../../source/source.service";
6+
import { GroupService } from "../../../group/group.service";
7+
import { HistoryService } from "../../../history/history.service";
8+
import { AiTaskService } from "../../../ai-task/ai-task.service";
9+
import { TopicService } from "../../../topic/topic.service";
10+
import { VerificationRequestService } from "../../verification-request.service";
11+
import { VerificationRequestDocument } from "../../schemas/verification-request.schema";
12+
13+
const mockQuery = {
14+
sort: jest.fn().mockReturnThis(),
15+
limit: jest.fn().mockReturnThis(),
16+
select: jest.fn().mockReturnThis(),
17+
lean: jest.fn().mockReturnThis(),
18+
exec: jest.fn(),
19+
};
20+
21+
const mockVerificationRequestModel = {
22+
find: jest.fn().mockReturnValue(mockQuery),
23+
aggregate: jest.fn().mockReturnThis(),
24+
};
25+
26+
const createVRTestingModule = async () => {
27+
const testingModule: TestingModule = await Test.createTestingModule({
28+
providers: [
29+
VerificationRequestService,
30+
{
31+
provide: getModelToken("VerificationRequest"),
32+
useValue: mockVerificationRequestModel,
33+
},
34+
{
35+
provide: "REQUEST",
36+
useValue: { user: { id: "test-user" } },
37+
},
38+
{ provide: VerificationRequestStateMachineService, useValue: {} },
39+
{ provide: SourceService, useValue: {} },
40+
{ provide: GroupService, useValue: {} },
41+
{ provide: HistoryService, useValue: {} },
42+
{ provide: AiTaskService, useValue: {} },
43+
{ provide: TopicService, useValue: {} },
44+
{ provide: "PersonalityService", useValue: {} },
45+
],
46+
}).compile();
47+
48+
const service = await testingModule.resolve<VerificationRequestService>(VerificationRequestService);
49+
const model = testingModule.get<Model<VerificationRequestDocument>>(getModelToken("VerificationRequest"));
50+
51+
return { service, model, testingModule };
52+
};
53+
54+
export { createVRTestingModule, mockVerificationRequestModel, mockQuery };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { VerificationRequestDocument } from "../../schemas/verification-request.schema";
2+
3+
export const createFakeVerificationRequest = (overrides?: Partial<VerificationRequestDocument>) => ({
4+
_id: "60c72b2f9f1b2c3d4e5f6a7b",
5+
status: "In Triage",
6+
sourceChannel: "Whatsapp",
7+
data_hash: "AABBCCDD1122334455667788",
8+
updatedAt: new Date(),
9+
...overrides,
10+
});

0 commit comments

Comments
 (0)