[AI assisted]: Improve system console statistics performance (#29899)
```release-note NONE ``` Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6046a304b2
Коммит
ae9e6174e5
@@ -127,9 +127,36 @@ function toLowerCase(config, name) {
|
||||
return name.toLowerCase();
|
||||
}
|
||||
|
||||
const dbRefreshPostStats = async ({dbConfig}) => {
|
||||
if (!knexClient) {
|
||||
knexClient = getKnexClient(dbConfig);
|
||||
}
|
||||
|
||||
// Only run for PostgreSQL
|
||||
if (dbConfig.client !== 'postgres') {
|
||||
return {
|
||||
skipped: true,
|
||||
message: 'Refresh post stats is only supported for PostgreSQL',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
await knexClient.raw('REFRESH MATERIALIZED VIEW posts_by_team_day;');
|
||||
await knexClient.raw('REFRESH MATERIALIZED VIEW bot_posts_by_team_day;');
|
||||
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
} catch (error) {
|
||||
const errorMessage = 'Failed to refresh post statistics materialized views.';
|
||||
return {error, errorMessage};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
dbGetActiveUserSessions,
|
||||
dbGetUser,
|
||||
dbGetUserSession,
|
||||
dbUpdateUserSession,
|
||||
dbRefreshPostStats,
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ const {
|
||||
dbGetUser,
|
||||
dbGetUserSession,
|
||||
dbUpdateUserSession,
|
||||
dbRefreshPostStats,
|
||||
} = require('./db_request');
|
||||
const externalRequest = require('./external_request').default;
|
||||
const {fileExist, writeToFile} = require('./file_util');
|
||||
@@ -42,6 +43,7 @@ module.exports = (on, config) => {
|
||||
dbGetUser,
|
||||
dbGetUserSession,
|
||||
dbUpdateUserSession,
|
||||
dbRefreshPostStats,
|
||||
externalRequest,
|
||||
fileExist,
|
||||
writeToFile,
|
||||
|
||||
Ссылка в новой задаче
Block a user