Skip to content

Conversation

@deer-wmde
Copy link
Contributor

https://phabricator.wikimedia.org/T383427

based on #912

Adds data points to WikiMetrics model:

  • daily_actions (number of actions in the last day)
  • weekly_actions (number of actions in the last week)
  • monthly_actions (number of actions in the last month)
  • quarterly_actions (number of actions in the last quarter)

@deer-wmde
Copy link
Contributor Author

deer-wmde commented Apr 16, 2025

currently Laravel is not happy with the prepared statement:

$m->saveMetrics($w)

   Illuminate\Database\QueryException  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?), '%Y%m%d%H%i%S')) AS sum_actions
FROM
    ? AS rc
INNER JOIN ? AS a ON rc...' at line 2 (Connection: mysql, SQL: SELECT
    SUM(rc_timestamp >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY), '%Y%m%d%H%i%S')) AS sum_actions,
FROM
    mwdb_3f193bc347.mwt_66fa57e4c8_recentchanges AS rc
INNER JOIN mwdb_3f193bc347.mwt_66fa57e4c8_actor AS a ON rc.rc_actor = a.actor_id
// Conditions below added for consistency with Wikidata: https://phabricator.wikimedia.org/diffusion/ADES/browse/master/src/wikidata/site_stats/sql/active_user_changes.sql
AND a.actor_user != 0
AND rc.rc_bot = 0
AND ( rc.rc_log_type != 'newusers' OR rc.rc_log_type IS NULL)).

@deer-wmde deer-wmde marked this pull request as ready for review April 25, 2025 15:06
$this->assertDatabaseHas('wiki_daily_metrics', [
'wiki_id' => $activeWiki->id,
'date' => Carbon::today()->toDateString()
'date' => Carbon::today()->toDateString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about how we could "properly" test this and concluded that this is one of the main weaknesses of this approach. We're so tightly bound to the implementation / layout of mediawiki's private dbs that this isn't really possible to seed with good test data. Hence why this just lives as a null

Copy link
Contributor

@tarrow tarrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests fixed!

@deer-wmde deer-wmde merged commit 02efa28 into main Apr 25, 2025
5 checks passed
@deer-wmde deer-wmde deleted the de/T383427 branch April 25, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants