update general statistic and analytic
This commit is contained in:
@@ -186,11 +186,9 @@ export async function getFileViolations(fileId: string, page: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchViolationGeography() {
|
||||
export async function fetchViolationAnalyticStatistic(group: 'domain' | 'tld') {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
/* "group_by": "tld" */
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
@@ -198,8 +196,10 @@ export async function fetchViolationGeography() {
|
||||
version: 1,
|
||||
msg_id: 30009,
|
||||
message_body: {
|
||||
group_by: "domain",
|
||||
token: token
|
||||
group_by: group,
|
||||
action: "group",
|
||||
token: token,
|
||||
sort_direction: 'desc'
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
@@ -210,8 +210,44 @@ export async function fetchViolationGeography() {
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
if (parsed) {
|
||||
return parsed;
|
||||
|
||||
if (parsed?.message_body) {
|
||||
return parsed?.message_body;
|
||||
} else {
|
||||
throw null;
|
||||
}
|
||||
} else {
|
||||
throw (`${response.status}`);
|
||||
}
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchViolationStatistic() {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 30010,
|
||||
message_body: {
|
||||
token: token,
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
|
||||
if (parsed?.message_body) {
|
||||
return parsed?.message_body;
|
||||
} else {
|
||||
throw null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user