From 94ed01c88a728b012c979c821580b87a1a34cbca Mon Sep 17 00:00:00 2001 From: MrEisbear Date: Sat, 20 Sep 2025 19:49:44 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20To-Do.=20Deleted=20non=20backend=20tasks?= =?UTF-8?q?=20and=20added=20important=20note=20about=20collect=20system.?= =?UTF-8?q?=20Added=20COLLECT=5FCOOLDOWN=20default=20to=2024=20hours=20if?= =?UTF-8?q?=20not=20set=20in=20env.=20Fixed=20.gitignore=20to=20ignore=20v?= =?UTF-8?q?scode=20settings=20and=20python=20cache=20files.=20Added=20new?= =?UTF-8?q?=20transaction=20history=20to=20To-Do=20and=20marked=20as=20fin?= =?UTF-8?q?ished=20-=20Needs=20to=20be=20tested=C2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit why tf am I commiting this on main branch? --- .gitignore | 6 ++++++ To-Do.md | 11 +++-------- interbend/routes/transaction_routes.py | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 9 deletions(-) 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'])