User Stats Historical Data Population

User Stats Historical Data Population

User Stats Historical Data Population

You can get aggregated user stats for a time frame using User.Stats API endpoint. To prevent any performance issues, this API command is powered by an advanced caching mechanism. In order to populate the caching with historical data (optional), you may follow these steps:

Purpose of the Command

The stats:populate-user-aggregated-stats command is designed to populate the oempro_user_aggregated_stats table with hourly aggregated statistical data for each user.

Command Syntax

php artisan stats:populate-user-aggregated-stats {--startDate=} {--endDate=}
⚠️

Important: This command must be executed inside oempro_system container. Therefore, you can run it with docker exec -ti oempro_system bash -c "<insert-command-here>"

Options

  • -startDate=: The start date for aggregating statistics. The date format should be recognizable by Carbon (e.g., 2024-04-012024-04-01 12:002024-04).
  • -endDate=: The end date for aggregating statistics. The date format is similar to -startDate.

If these options are not provided, the command defaults to processing statistics for the last day.

Usage Examples

  1. Aggregate for the Last Day (Default):
  2. php artisan stats:populate-user-aggregated-stats
  3. Aggregate for a Specific Period:
  4. php artisan stats:populate-user-aggregated-stats --startDate="2024-04-01 00:00:00" --endDate="2024-04-02 23:59:59"
  5. Aggregate for a Month:
  6. php artisan stats:populate-user-aggregated-stats --startDate="2024-04-01" --endDate="2024-04-30"

Command Features

  • Locking Mechanism: The command uses a locking mechanism via Redis to prevent multiple instances from running simultaneously. If the command is already running, you will receive the message The command is already running.
  • Integration with Redis: For the current hour, the command considers data from Redis using StatsCacheHandler. After successfully aggregating the data for the current hour, the Redis cache for that period is cleared to avoid duplicate counting.
  • Logs and Messages: During execution, the command outputs progress information about processing users and periods. The . symbol indicates the processing of a period, while  signifies the presence of non-zero values for metrics.

Verifying the Results

After running the command, you can check the oempro_user_aggregated_stats table in the oempro database to ensure that aggregated statistical data has been populated correctly.

💠
image

Homepage Customer Area Community Portal Contact Us

Footer Social Icons

©Copyright Octeth, Inc. All rights reserved.