diff --git a/.gitignore b/.gitignore index 940489f..b5848e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ .venv/ .env .idea/ +.vscode/ +__pycache__/ +*.pyc +instance/ +db.sqlite3 + diff --git a/To-Do.md b/To-Do.md index ada18c2..238ab43 100644 --- a/To-Do.md +++ b/To-Do.md @@ -7,16 +7,11 @@ This file tracks potential new features and improvements for the Interbend banki 1. **Automated Payroll System:** * **Description:** Instead of requiring users to manually call the `/collect` endpoint, a scheduled script could run periodically (e.g., every 24 hours) to automatically distribute salaries to all eligible users. * **Benefits:** Improves user experience, ensures consistent pay, and reduces repeated API calls to the server. + * **Important:** Due to the concept of this whole system it needs to be considered to only pay users who are attend. Bad Idea. + * **Alternative:** Implement system to make sure you can only collect if the host is online. Make admin route to open server (set global bool) 2. **User Transaction History:** * **Description:** Create a new API endpoint (e.g., `GET /transactions`) that allows an authenticated user to retrieve a paginated list of their own transaction history. * **Benefits:** Provides users with transparency and a way to track their finances, which is a core feature of any banking application. -3. **Comprehensive Admin Panel:** - * **Description:** Develop a simple web-based dashboard for administrators. This would be more user-friendly than using API endpoints for administrative tasks. - * **Features:** - * View and manage all users (e.g., edit balance, change job, view profile). - * Manage jobs and their corresponding salaries. - * View system-wide transaction logs and financial statistics. - * A secure login system for administrators. - * **Benefits:** Greatly simplifies the management of the roleplay economy and provides better oversight. + * FINISHED: PLEASE CHECK IF WORKING! \ No newline at end of file diff --git a/interbend/routes/transaction_routes.py b/interbend/routes/transaction_routes.py index 3dfe3a5..c8a2155 100644 --- a/interbend/routes/transaction_routes.py +++ b/interbend/routes/transaction_routes.py @@ -76,7 +76,23 @@ def collect(): current_app.logger.error(f"An unexpected error occurred in /collect: {e}") return jsonify({"error": "An unexpected server error occurred."}), 500 - +@transactions_bp.route('/transactions', methods=['GET']) +@jwt_required +def get_transactions(): + user_bid = request.bid + limit = request.args.get('limit', default=10, type=int) + try: + with db.cursor(dictionary=True) as cur: + cur.execute("SELECT * FROM transactions WHERE source = %s OR target = %s ORDER BY timestamp DESC LIMIT %s", (user_bid, user_bid, limit)) + transactions = cur.fetchall() + return jsonify({"transactions": transactions}), 200 + except mysql.connector.Error as err: + current_app.logger.error(f"Database error in /transactions: {err}") + return jsonify({"error": "A database error occurred, please try again later."}), 500 + except Exception as e: + current_app.logger.error(f"An unexpected error occurred in /transactions: {e}") + return jsonify({"error": "An unexpected server error occurred."}), 500 + # this should be fine @transactions_bp.route('/transfer', methods=['POST'])