Commit Graph

64 Commits

Author SHA1 Message Date
Torsten Schulz (local)
d740dbbf73 Enhance money history logging: Implement best-effort insert into money_history for UI visibility across BaseWorker, EventsWorker, and UndergroundWorker, improving tracking of monetary changes. 2025-12-09 08:19:42 +01:00
Torsten Schulz (local)
e8c8c5edb1 Refactor EventsWorker: Move EVENT_RATE_SCALE constant to the struct for better encapsulation and clarity in event probability calculations. 2025-12-09 00:09:12 +01:00
Torsten Schulz (local)
a4d1d79e6e Enhance EventsWorker: Introduce EVENT_RATE_SCALE constant to adjust event frequency, improving control over event triggering rates. 2025-12-09 00:07:55 +01:00
Torsten Schulz (local)
78b5527b15 Enhance change_falukant_user_money: Switch to literal SQL execution for update_money to resolve serialization issues with parameterized calls, improving reliability. 2025-12-08 16:39:57 +01:00
Torsten Schulz (local)
180431b130 Enhance change_falukant_user_money: Implement money clamping logic to ensure updates stay within numeric(10,2) limits, improving data integrity and error handling. 2025-12-08 16:34:57 +01:00
Torsten Schulz (local)
99fbaab816 Enhance change_falukant_user_money: Implement fallback to literal SQL for update_money on failure of parameterized call, improving robustness and error handling. 2025-12-08 16:28:46 +01:00
Torsten Schulz (local)
450497ccd3 Refactor change_falukant_user_money: Update parameter types for database call and enhance logging for better traceability 2025-12-08 16:23:24 +01:00
Torsten Schulz (local)
04a8da8d0c Enhance logging in change_falukant_user_money: Added type logging for parameters to identify unexpected types during execution, improving debugging capabilities. 2025-12-08 16:15:30 +01:00
Torsten Schulz (local)
688b21581d Enhance logging in BaseWorker and DirectorWorker: Added detailed debug logs before database calls in change_falukant_user_money, improving traceability of user ID and money change values during production start and sell operations. 2025-12-08 16:07:08 +01:00
Torsten Schulz (local)
f7c4919a2a Enhance error logging in change_falukant_user_money function: Added detailed logging for parameters before executing the database update and improved error handling for serialization issues, enhancing traceability and debugging capabilities. 2025-12-08 16:01:25 +01:00
Torsten Schulz (local)
ad0033031d Validate money change input in update_money function: Added checks to ensure the money_change value is finite before executing the database update, preventing potential serialization errors with invalid values. 2025-12-08 15:53:31 +01:00
Torsten Schulz (local)
b4b3b1adcc Enhance user notification structure in EventsWorker: Updated the notification process to include detailed event information in the database entries. Notifications now contain event ID, type, and effects, improving clarity and data integrity for user alerts. 2025-12-08 13:29:18 +01:00
Torsten Schulz (local)
9b6883ea84 Implement inheritance logic for player characters in EventsWorker: Added functionality to handle character inheritance before deleting child relations. This includes querying for the user ID, determining the heir, and updating the heir's assets accordingly. Enhanced logging for inheritance events to improve traceability. 2025-12-08 13:22:20 +01:00
Torsten Schulz (local)
d078b6b19a Refactor WebSocket user ID filtering and enhance SQL query security: Updated user ID handling in the WebSocket server to improve filtering logic for numeric user IDs. Implemented parameterized queries in the database operations across multiple worker files to prevent SQL injection vulnerabilities, ensuring safer data handling. 2025-12-08 11:56:04 +01:00
Torsten Schulz (local)
2948586041 Enhance event effect handling in EventsWorker: Updated money change, storage capacity change, and house quality change methods to return absolute values and percentages. Improved JSON response structure for event effects, enhancing clarity and data accuracy in event processing. 2025-12-08 11:51:10 +01:00
Torsten Schulz (local)
0198bcd603 Enhance user notification handling in EventsWorker: Updated the notification process to write user notifications to the database and send WebSocket alerts for each affected user in a region. Improved logging to reflect the number of users notified during regional event processing. 2025-12-08 11:34:20 +01:00
Torsten Schulz (local)
37b2c08555 Add new event effects and implement regional changes: Introduced HouseQualityChange and updated StorageCapacityChange effects in EventsWorker. Implemented regional handling for storage capacity and house quality changes during events, enhancing gameplay dynamics and event impact. Improved logging for affected stocks and houses during changes. 2025-12-08 11:23:34 +01:00
Torsten Schulz (local)
5a3a818d84 Add EventsWorker to worker module: Introduced EventsWorker for handling event-related tasks. Updated main.rs to include EventsWorker in the worker creation process. Adjusted WeatherWorker instantiation to use cloned pool and broker for consistency. 2025-12-08 11:17:16 +01:00
Torsten Schulz (local)
8db82e0ced Refactor transport planning in DirectorWorker: Updated variable naming for clarity by changing 'shipped' to '_shipped' to indicate unused variable. Removed unused get_branch_user_id function from TransportWorker to streamline code and improve maintainability. 2025-12-05 14:20:56 +01:00
Torsten Schulz (local)
f481ef4b73 Refactor inventory handling in DirectorWorker: Updated transport planning logic to ensure inventory is reduced immediately after successful transport creation. Removed redundant inventory updates from the planning phase, enhancing consistency and clarity in inventory management. Improved logging to reflect changes in inventory status during transport operations. 2025-12-05 14:17:57 +01:00
Torsten Schulz (local)
d03d865f75 Refactor ArrivedTransport struct and SQL query in TransportWorker: Updated the ArrivedTransport struct to include source and target branch IDs, and user ID for notifications. Modified the SQL query to join with source and target branches, enhancing transport data retrieval and notification capabilities. 2025-12-05 14:15:22 +01:00
Torsten Schulz (local)
58436bc016 Enhance transport processing in TransportWorker: Updated run_loop and process_arrived_transports methods to include broker for publishing notifications. Improved handling of empty transports and added notifications for transport arrival and inventory updates, ensuring timely user alerts and better transport management. 2025-12-05 14:12:17 +01:00
Torsten Schulz (local)
fbcea09257 Refactor transport handling in TransportWorker: Updated ArrivedTransport struct to allow optional product_id for empty transports. Enhanced validation logic to differentiate between normal and empty transports, improving handling and processing of transport data. Added specific handling for empty transports in the database operations, ensuring accurate vehicle updates and transport deletions. 2025-12-05 14:06:22 +01:00
Torsten Schulz (local)
46d0ea46a8 Refactor weather update query in WeatherWorker: Simplified the SQL logic for assigning random weather types to regions by removing unnecessary joins and using a subquery for random selection. Enhanced comments for clarity on the individual weather assignment process for each region. 2025-12-05 13:36:55 +01:00
Torsten Schulz (local)
b59837feb3 Refactor transport planning logic in DirectorWorker: Improved handling of empty transports for vehicle retrieval when no vehicles are available in the current branch. Enhanced checks for free vehicles and better selling prices in other branches, along with detailed logging for improved traceability during transport operations. 2025-12-05 12:56:59 +01:00
Torsten Schulz (local)
9f2f20cba2 Add empty transport planning in DirectorWorker: Introduced SQL queries and logic to handle empty transports for vehicle retrieval when no transport vehicles are available in the current branch. Enhanced the planning process to check for better selling prices in other branches and available free vehicles, improving transport management and operational efficiency. 2025-12-04 16:31:39 +01:00
Torsten Schulz (local)
940706bed3 Enhance logging and vehicle checks in DirectorWorker: Added SQL queries to verify the existence of vehicles in the source region and routes between regions. Improved debug logging to provide insights into vehicle counts and route availability, enhancing traceability during transport planning operations. 2025-12-03 16:54:22 +01:00
Torsten Schulz (local)
66b19fbe7c Enhance logging in DirectorWorker for transport planning: Added detailed error and status messages throughout the transport planning process, including inventory checks, transport feasibility assessments, and pricing evaluations. This improves traceability and debugging capabilities for transport operations associated with directors. 2025-12-03 16:52:38 +01:00
Torsten Schulz (local)
d2c8b62156 Implement transport management in DirectorWorker: Enhanced the start_transports_stub function to handle transport planning for inventory items associated with a director. Added error handling for transport initiation and improved database interactions for inventory management, ensuring accurate transport planning and logging of potential errors. 2025-12-03 16:42:36 +01:00
Torsten Schulz (local)
e14272e477 Add WeatherWorker to the worker module and update worker creation logic: Introduced WeatherWorker to manage weather-related tasks. Updated the create_workers function to include WeatherWorker alongside existing workers, ensuring comprehensive handling of various operational aspects. 2025-12-02 12:59:40 +01:00
Torsten Schulz (local)
c943e57f80 Enhance production management by adding region_id to ProductionPlan and updating SQL queries: Introduced region_id to the ProductionPlan struct and modified the insert production query to include weather_type_id based on region. Updated finished productions query to account for weather effects on quality ratings, ensuring accurate production assessments. Improved comments for clarity on the impact of weather on production quality. 2025-12-02 09:57:31 +01:00
Torsten Schulz (local)
32dd79bc6e Refactor hourly price recalculation logic: Implemented a two-tier pricing adjustment system based on sales data, comparing city sales against global and parent-region averages. Updated SQL queries to reflect new pricing rules, ensuring dynamic price adjustments within defined tolerances. Enhanced logging for better tracking of affected regions during recalculation. 2025-12-02 09:29:33 +01:00
Torsten Schulz (local)
4a2e814803 Enhance pricing logic in DirectorWorker and implement hourly price recalculation: Added a new worth_percent field to the InventoryItem struct and updated SQL queries to incorporate this value in price calculations. Refactored price computation logic to use a base price derived from worth_percent. Introduced a new hourly price recalculation mechanism that adjusts prices based on sales data from the last hour, ensuring dynamic pricing adjustments. Enhanced logging for better monitoring of price updates. 2025-12-02 08:55:01 +01:00
Torsten Schulz (local)
9ee8c970c7 Add branch capacity query and production limits in DirectorWorker: Introduced a new SQL query to fetch current stock and production values for a branch, enabling dynamic production management. Implemented logic to limit concurrent productions to a maximum of two and updated production creation to handle single production requests efficiently. Enhanced logging for better traceability of production activities. 2025-12-01 16:23:40 +01:00
Torsten Schulz (local)
513862a157 Limit maximum production quantity in DirectorWorker: Updated the production calculation to cap the output at 100 units per start, ensuring it does not exceed available capacity or financial constraints. Enhanced comments for better understanding of the production limits. 2025-12-01 15:55:59 +01:00
Torsten Schulz (local)
bd9fbb80c0 Enhance production job handling in DirectorWorker: Implemented a limit on the number of concurrent production jobs per branch to a maximum of two. Updated SQL query for fetching finished productions to aggregate quality ratings correctly and ensure unique results per production ID. Improved comments for clarity on the logic and SQL structure. 2025-12-01 14:32:31 +01:00
Torsten Schulz (local)
02bd0de75d Refactor user ID filtering in WebSocket server: Enhanced the logic to only filter messages based on user_id if the target user ID is numerically valid. Updated comments for clarity on the filtering behavior and historical context regarding user ID handling. 2025-12-01 13:31:12 +01:00
Torsten Schulz (local)
b8fa644c97 Implement periodic ping frames in WebSocket server for keepalive and update overproduction handling in ProduceWorker to include branch_id. This enhances connection stability and improves notification clarity for overproduction events. 2025-12-01 13:25:23 +01:00
Torsten Schulz (local)
3e9f921f4f Enhance DirectorWorker functionality: Added branch_id to the Director struct and updated SQL queries to include branch_id as a parameter. Improved logging messages to include branch_id for better traceability during production, transport, and sales checks. This change enhances the clarity and functionality of the DirectorWorker's operations. 2025-12-01 11:59:03 +01:00
Torsten Schulz (local)
a0e14788c7 Refactor money update execution in BaseWorker: Simplified the SQL execution by directly constructing the update query without parameterized placeholders, addressing serialization issues. Updated comments for clarity on the handling of money values and ensured compatibility with trusted data sources. Additionally, modified the casting of money in the director query to text for consistent mapping in Rust. 2025-12-01 11:31:37 +01:00
Torsten Schulz (local)
260b3b2962 Refactor SQL parameter handling in BaseWorker: Updated the execution of the money update query to pass parameters in their natural types, allowing PostgreSQL to handle type casting automatically. Improved comments for clarity on the changes made to ensure compatibility with the existing database schema. 2025-12-01 11:18:54 +01:00
Torsten Schulz (local)
25b69e48fe Refactor money update execution in BaseWorker: Updated parameter handling in SQL execution to pass all values as strings, allowing for proper type casting in the database. Enhanced comments for clarity on the changes made to ensure compatibility with existing database schema. 2025-12-01 11:15:46 +01:00
Torsten Schulz (local)
2c91f1868b Refactor SQL execution in BaseWorker: Updated the money update logic to register and execute prepared statements by name, enhancing clarity and consistency with existing code. Improved comments for better understanding of numeric type handling in SQL queries. 2025-12-01 11:09:17 +01:00
Torsten Schulz (local)
0825c05c31 Refactor money update logic in BaseWorker: Simplified the SQL execution by removing named prepared statement caches to avoid signature conflicts during schema changes. Updated comments for clarity on the handling of money change as a numeric type, ensuring compatibility with the database. 2025-12-01 10:59:02 +01:00
Torsten Schulz (local)
d98620ea06 Refactor SQL query in DirectorWorker: Removed unnecessary conditions from the query for fetching transport vehicles, simplifying the logic while maintaining functionality. This change enhances query readability and performance. 2025-12-01 10:55:50 +01:00
Torsten Schulz (local)
6f9e13b290 Update money handling in BaseWorker: Changed SQL query to cast money change to numeric type for compatibility with existing database schema. Updated parameter passing to ensure the value is sent as a string, allowing proper casting in the database. Added comments for clarity on the changes made. 2025-12-01 10:39:32 +01:00
Torsten Schulz (local)
7ae2f0c6c9 Enhance money production calculation in DirectorWorker: Updated the logic to handle cases where available money is zero, allowing production limits to be determined by capacity instead. Added warning logging for unexpected zero money scenarios, improving error handling and visibility in production planning. 2025-12-01 10:37:05 +01:00
Torsten Schulz (local)
cf874a7b8d Refactor map_row_to_production_plan in DirectorWorker: Simplified the parsing of database fields by introducing local variables for required and optional fields. This change enhances readability and maintains default values for optional fields, improving the robustness of production plan creation. 2025-12-01 10:25:33 +01:00
Torsten Schulz (local)
9715723db7 Improve logging in DirectorWorker: Added detailed error messages and production calculations to enhance visibility into production planning and execution. Included checks for running productions and capacity constraints, ensuring better tracking of production processes. 2025-12-01 10:23:42 +01:00
Torsten Schulz (local)
d5017ef1e1 Enhance logging and error handling in DirectorWorker: Added detailed logging for production, transport, and sales checks for directors. Included a warning message when no directors are found for actions, improving visibility into the task execution process. 2025-12-01 10:09:19 +01:00