Skip to content

Commit

Permalink
Add a filter to check if the bot is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Lelek committed Jun 17, 2024
1 parent 88c0fab commit 0d73bff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/bot/checkApplications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getApiClients } from "../services/filplusService";
import {
getAllocators,
getAllocatorsWithSSABotEnable,
getApplications,
postApplicationRefill,
postApplicationTotalDCReached,
Expand Down Expand Up @@ -39,7 +39,7 @@ export const checkApplications = async (): Promise<void> => {
data: allocators,
error: allocatorsError,
success: allocatorSuccess,
} = await getAllocators();
} = await getAllocatorsWithSSABotEnable();
if (!allocatorSuccess) {
logError(`Get Allocators Error: ${allocatorsError}`);
}
Expand Down
46 changes: 25 additions & 21 deletions src/services/backendService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,31 @@ import {
*
* @returns {Promise<RequestAllocatorsReturn>} The list of allocators
*/
export const getAllocators = async (): Promise<RequestAllocatorsReturn> => {
logDebug(`Requesting allocators from backend`);
try {
const response = await axios({
method: "GET",
url: `${config.backendApi}/allocators`,
});
return {
data: response.data,
error: "",
success: true,
};
} catch (error) {
const errMessage = `Error accessing Backend API /allocator: ${error.message}`;
return {
data: [],
error: errMessage,
success: false,
};
}
};
export const getAllocatorsWithSSABotEnable =
async (): Promise<RequestAllocatorsReturn> => {
logDebug(`Requesting allocators from backend`);
try {
const response = await axios({
method: "GET",
url: `${config.backendApi}/allocators`,
});
const allocatorsWithSSABotEnable = response.data.filter(
(allocator) => allocator.disable_ssa_bot !== true,
);
return {
data: allocatorsWithSSABotEnable,
error: "",
success: true,
};
} catch (error) {
const errMessage = `Error accessing Backend API /allocator: ${error.message}`;
return {
data: [],
error: errMessage,
success: false,
};
}
};

/**
* Gets all the applications from the backend.
Expand Down

0 comments on commit 0d73bff

Please sign in to comment.