adding mariadb

This commit is contained in:
Ulysia 2024-12-28 15:09:44 +01:00
parent 13035edc40
commit be1ec59e0e
2 changed files with 36 additions and 33 deletions

View file

@ -4,11 +4,31 @@ services:
container_name: hypixel-auc-notifier
build: .
restart: unless-stopped
depends_on:
- db
env_file:
- .env
environment:
NODE_ENV: "production"
DB_HOST: db
DB_USER: root
DB_PASSWORD: example
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./config.json:/app/dist/src/config.json
db:
image: mariadb
restart: always
environment:
MARIADB_ROOT_PASSWORD: example
adminer:
image: adminer
restart: always
depends_on:
- db
ports:
- 8080:8080

View file

@ -24,7 +24,7 @@ const webhookRegex = /https:\/\/discord.com\/api\/webhooks\/(.+)\/(.+)/;
const bazaarPrice = {
RECOMBOBULATOR_3000: 0,
HOT_POTATO_BOOK: 0,
FUMING_POTATO_BOOK: 0,
FUMING_POTATO_BOOK: 0
};
async function initialize() {
@ -43,16 +43,15 @@ async function initialize() {
itemDatas: itemDatas,
bazaarData: bazaarPrice,
workerNumber: j,
maxPrice: maxPrice,
},
maxPrice: maxPrice
}
});
workers[j].on('message', async (result) => {
if (result.itemData !== undefined) {
let averagePrice: number | null = itemDatas[result.itemData.id]?.cleanPrice || null;
if (
result.auctionData.lbin - result.auctionData.price >=
config.data.minSnipeProfit &&
result.auctionData.lbin - result.auctionData.price >= config.data.minSnipeProfit &&
(averagePrice || averagePrice! - result.auctionData.price >= config.data.minAvgProfit)
) {
let mustBuyMessage = '';
@ -63,16 +62,11 @@ async function initialize() {
.setDescription(
`${mustBuyMessage}\nAuction:
\`\`\`/viewauction ${result.auctionData.auctionID}\`\`\`
\nProfit: \`${addNotation(
'oneLetters',
result.auctionData.profit
)} (${result.auctionData.percentProfit}%)\`
\nProfit: \`${addNotation('oneLetters', result.auctionData.profit)} (${result.auctionData.percentProfit
}%)\`
\nCost: \`${addNotation('oneLetters', result.auctionData.price)}\`
\nLBIN: \`${addNotation('oneLetters', result.auctionData.lbin)}\`
\nSales/Day: \`${addNotation(
'oneLetters',
result.auctionData.sales
)}\`
\nSales/Day: \`${addNotation('oneLetters', result.auctionData.sales)}\`
\nType: \`${result.auctionData.ahType}\`
\nAverage Price: \`${averagePrice ? addNotation('oneLetters', averagePrice) : 'N/A'}\``
);
@ -80,16 +74,14 @@ async function initialize() {
await webhook.send({
username: process.env.WEBHOOK_NAME,
avatarURL: process.env.WEBHOOK_PROFILE_PICTURE,
embeds: [embed],
embeds: [embed]
});
}
} else if (result === 'finished') {
doneWorkers++;
if (doneWorkers === worker_count) {
doneWorkers = 0;
console.log(
`Completed in ${(Date.now() - startingTime) / 1000} seconds`
);
console.log(`Completed in ${(Date.now() - startingTime) / 1000} seconds`);
startingTime = 0;
workers[0].emit('done');
}
@ -122,9 +114,7 @@ async function initialize() {
asyncInterval(
async () => {
return new Promise(async (resolve) => {
const ahFirstPage = await axios.get(
'https://api.hypixel.net/skyblock/auctions?page=0'
);
const ahFirstPage = await axios.get('https://api.hypixel.net/skyblock/auctions?page=0');
const totalPages = ahFirstPage.data.totalPages;
if (ahFirstPage.data.lastUpdated === lastUpdated) {
resolve();
@ -156,14 +146,10 @@ async function getLBINs(): Promise<void> {
}
async function getMoulberry(): Promise<void> {
const moulberryAvgs = await axios.get(
'https://moulberry.codes/auction_averages/3day.json'
);
const moulberryAvgs = await axios.get('https://moulberry.codes/auction_averages/3day.json');
const avgData = moulberryAvgs.data;
const cleanPriceAvgs = await axios.get(
'https://moulberry.codes/auction_averages_lbin/1day.json'
);
const cleanPriceAvgs = await axios.get('https://moulberry.codes/auction_averages_lbin/1day.json');
const cleanPriceData = cleanPriceAvgs.data;
for (const item of Object.keys(avgData)) {
@ -182,12 +168,9 @@ async function getMoulberry(): Promise<void> {
async function getBzData(): Promise<void> {
const bzData = await axios.get('https://api.hypixel.net/skyblock/bazaar');
bazaarPrice['RECOMBOBULATOR_3000'] =
bzData.data.products.RECOMBOBULATOR_3000.quick_status.buyPrice;
bazaarPrice['HOT_POTATO_BOOK'] =
bzData.data.products.HOT_POTATO_BOOK.quick_status.buyPrice;
bazaarPrice['FUMING_POTATO_BOOK'] =
bzData.data.products.FUMING_POTATO_BOOK.quick_status.buyPrice;
bazaarPrice['RECOMBOBULATOR_3000'] = bzData.data.products.RECOMBOBULATOR_3000.quick_status.buyPrice;
bazaarPrice['HOT_POTATO_BOOK'] = bzData.data.products.HOT_POTATO_BOOK.quick_status.buyPrice;
bazaarPrice['FUMING_POTATO_BOOK'] = bzData.data.products.FUMING_POTATO_BOOK.quick_status.buyPrice;
}
initialize();