Page MenuHomePhabricator

๐Ÿ“ˆ Platform API: Update when WikiMetrics.php saves daily metrics
Closed, ResolvedPublic

Description

As suggested in T414945: ๐Ÿ“ˆ Investigate wiki metrics collected by the Platform API, remove the conditions that doesn't save metrics if the Wiki is deleted. A check for whether metrics are equal is enough to prevent duplicate data from being stored.

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptTue, Jan 20, 11:01 AM
Ollie.Shotton_WMDE renamed this task from Platform API: Update when WikiMetrics.php saves daily metrics to ๐Ÿ“ˆ Platform API: Update when WikiMetrics.php saves daily metrics.Tue, Jan 20, 11:02 AM

outdooracorn closed https://github.com/wbstack/api/pull/1038

Update when WikiMetrics saves daily metrics

Deployed to staging and running kubectl exec -it deployment/api-queue-default -- sh -c "php artisan job:dispatchNow UpdateWikiDailyMetricJob"

with the intent of also checking the output of the job

Ran with a number of Wikis getting updates. I manually looked at one Wiki (179). We can see the last two Metrics for it look like:

App\WikiDailyMetrics {#6534
        id: "179_2025-11-21",
        wiki_id: "179",
        pages: 1,
        is_deleted: 1,
        date: "2025-11-21",
        created_at: "2025-11-21 23:00:42",
        updated_at: "2025-11-21 23:00:42",
        daily_actions: null,
        weekly_actions: null,
        monthly_actions: null,
        quarterly_actions: null,
        number_of_triples: 0,
        monthly_casual_users: 0,
        monthly_active_users: 0,
        item_count: 0,
        property_count: 0,
        lexeme_count: 0,
        entity_schema_count: 0,
        total_user_count: null,
      },
      App\WikiDailyMetrics {#6544
        id: "179_2026-01-22",
        wiki_id: "179",
        pages: 1,
        is_deleted: 1,
        date: "2026-01-22",
        created_at: "2026-01-22 14:20:46",
        updated_at: "2026-01-22 14:20:46",
        daily_actions: null,
        weekly_actions: null,
        monthly_actions: null,
        quarterly_actions: null,
        number_of_triples: 0,
        monthly_casual_users: 0,
        monthly_active_users: 0,
        item_count: 0,
        property_count: 0,
        lexeme_count: 0,
        entity_schema_count: 0,
        total_user_count: 2,
      },

so all looks great. Continuing on to production

shipped to prod and run there. I see new entries for some delete Wikis e.g.

WikiDailyMetrics::where(["wiki_id" =>  2689])->get()
= Illuminate\Database\Eloquent\Collection {#6631
    all: [
      App\WikiDailyMetrics {#6538
        id: "2689_2025-12-06",
        wiki_id: "2689",
        pages: 0,
        is_deleted: 1,
        date: "2025-12-06",
        created_at: "2025-12-06 23:06:11",
        updated_at: "2025-12-06 23:06:11",
        daily_actions: 11,
        weekly_actions: 11,
        monthly_actions: 11,
        quarterly_actions: 11,
        number_of_triples: 4685,
        monthly_casual_users: 0,
        monthly_active_users: 1,
        item_count: 5,
        property_count: 6,
        lexeme_count: 0,
        entity_schema_count: 0,
        total_user_count: null,
      },
      App\WikiDailyMetrics {#6549
        id: "2689_2026-01-22",
        wiki_id: "2689",
        pages: 0,
        is_deleted: 1,
        date: "2026-01-22",
        created_at: "2026-01-22 14:38:45",
        updated_at: "2026-01-22 14:38:45",
        daily_actions: 0,
        weekly_actions: 0,
        monthly_actions: 0,
        quarterly_actions: 11,
        number_of_triples: 4685,
        monthly_casual_users: 0,
        monthly_active_users: 0,
        item_count: 5,
        property_count: 6,
        lexeme_count: 0,
        entity_schema_count: 0,
        total_user_count: 0,
      },
    ],
  }

Looks good, thank you everyone!
I would wait a couple days to see how the next jobs run (to check the condition 'if nothing changed, don't create a row')

The values for deleted wikis got populated and the growth of the table stabilized again. The content of new records also seems meaningful.

image.png (319ร—640 px, 22 KB)