installed prisma for py

This commit is contained in:
Dobromir Popov
2024-11-06 12:54:32 +02:00
parent 3dd7e315c7
commit efbe12f173
8 changed files with 53 additions and 22 deletions

View File

@ -1,10 +1,11 @@
import os
import asyncio
from pathlib import Path
from .storage import store_transaction
from .storage import store_transaction, prisma_client
from .SolanaAPI import SolanaAPI
LOG_DIRECTORY = "path/to/log/directory"
FILE_MASK = "*.log"
LOG_DIRECTORY = "logs"
FILE_MASK = "wh_*.json"
async def process_log_file(file_path):
# Read the file and extract transaction data
@ -22,8 +23,18 @@ async def process_log_file(file_path):
solana_signature = "extracted_solana_signature"
details = {}
# Store the transaction
await store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details)
# Process the webhook data
solana_api = SolanaAPI()
transaction_data = await solana_api.process_wh(data)
# Check if the transaction already exists
existing_transaction = await prisma_client.transaction.find_first(
where={'solana_signature': solana_signature}
)
if not existing_transaction:
# Store the transaction if it doesn't exist
await store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details)
# Rename the file to append '_saved'
new_file_path = file_path.with_name(file_path.stem + "_saved" + file_path.suffix)