Add comment about countR30UsersSQL and countR30UsersV2SQL; fix test

This commit is contained in:
Till Faelligen 2022-05-03 20:38:58 +02:00
parent 1e00d904d0
commit af3fc7daa8
3 changed files with 14 additions and 2 deletions

View file

@ -49,6 +49,10 @@ const countUsersLastSeenAfterSQL = "" +
" GROUP BY localpart" +
" ) u"
// Note on the following countR30UsersSQL and countR30UsersV2SQL: The different checks are intentional.
// This is to ensure the values reported by Dendrite are the same as by Synapse.
// Queries are taken from: https://github.com/matrix-org/synapse/blob/9ce51a47f6e37abd0a1275281806399d874eb026/synapse/storage/databases/main/stats.py
/*
R30Users counts the number of 30 day retained users, defined as:
- Users who have created their accounts more than 30 days ago

View file

@ -49,6 +49,10 @@ const countUsersLastSeenAfterSQL = "" +
" GROUP BY localpart" +
" ) u"
// Note on the following countR30UsersSQL and countR30UsersV2SQL: The different checks are intentional.
// This is to ensure the values reported by Dendrite are the same as by Synapse.
// Queries are taken from: https://github.com/matrix-org/synapse/blob/9ce51a47f6e37abd0a1275281806399d874eb026/synapse/storage/databases/main/stats.py
/*
R30Users counts the number of 30 day retained users, defined as:
- Users who have created their accounts more than 30 days ago
@ -82,6 +86,10 @@ SELECT platform, COUNT(*) FROM (
) u GROUP BY PLATFORM
`
// Note on the following countR30UsersSQL and countR30UsersV2SQL: The different checks are intentional.
// This is to ensure the values reported are the same as Synapse reports.
// Queries are taken from: https://github.com/matrix-org/synapse/blob/9ce51a47f6e37abd0a1275281806399d874eb026/synapse/storage/databases/main/stats.py
/*
R30UsersV2 counts the number of 30 day retained users, defined as users that:
- Appear more than once in the past 60 days

View file

@ -35,7 +35,7 @@ func mustMakeDBs(t *testing.T, dbType test.DBType) (
connStr, close := test.PrepareDBConnectionString(t, dbType)
db, err := sqlutil.Open(&config.DatabaseOptions{
ConnectionString: config.DataSource(connStr),
})
}, nil)
if err != nil {
t.Fatalf("failed to open db: %s", err)
}
@ -144,7 +144,7 @@ func Test_UserStatistics(t *testing.T) {
}
if wantType != gotDB.Engine { // can't use DeepEqual, as the Version might differ
t.Errorf("UserStatistics() gotDB = %+v, want SQLite", gotDB.Engine)
t.Errorf("UserStatistics() got DB engine = %+v, want %s", gotDB.Engine, wantType)
}
})