mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-23 00:29:22 +09:00
feat: add per user pv chart
This commit is contained in:
parent
4c4af2ae84
commit
969e9df889
@ -34,6 +34,7 @@ You should also include the user name that made the change.
|
|||||||
- Add Cloudflare Turnstile CAPTCHA support @CyberRex0
|
- Add Cloudflare Turnstile CAPTCHA support @CyberRex0
|
||||||
- Introduce retention-rate aggregation @syuilo
|
- Introduce retention-rate aggregation @syuilo
|
||||||
- Make possible to export favorited notes @syuilo
|
- Make possible to export favorited notes @syuilo
|
||||||
|
- Add per user pv chart @syuilo
|
||||||
- Server: signToActivityPubGet is set to true by default @syuilo
|
- Server: signToActivityPubGet is set to true by default @syuilo
|
||||||
- Server: improve syslog performance @syuilo
|
- Server: improve syslog performance @syuilo
|
||||||
- Server: improve note scoring for featured notes @CyberRex0
|
- Server: improve note scoring for featured notes @CyberRex0
|
||||||
|
17
packages/backend/migration/1672562400597-PerUserPvChart.js
Normal file
17
packages/backend/migration/1672562400597-PerUserPvChart.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
export class PerUserPvChart1672562400597 {
|
||||||
|
name = 'PerUserPvChart1672562400597'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`CREATE TABLE "__chart__per_user_pv" ("id" SERIAL NOT NULL, "date" integer NOT NULL, "group" character varying(128) NOT NULL, "unique_temp___upv_user" character varying array NOT NULL DEFAULT '{}', "___upv_user" smallint NOT NULL DEFAULT '0', "___pv_user" smallint NOT NULL DEFAULT '0', "unique_temp___upv_visitor" character varying array NOT NULL DEFAULT '{}', "___upv_visitor" smallint NOT NULL DEFAULT '0', "___pv_visitor" smallint NOT NULL DEFAULT '0', CONSTRAINT "UQ_f2a56da57921ca8439f45c1d95f" UNIQUE ("date", "group"), CONSTRAINT "PK_3c938a24f0203b5bd13fab51059" PRIMARY KEY ("id"))`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_f2a56da57921ca8439f45c1d95" ON "__chart__per_user_pv" ("date", "group") `);
|
||||||
|
await queryRunner.query(`CREATE TABLE "__chart_day__per_user_pv" ("id" SERIAL NOT NULL, "date" integer NOT NULL, "group" character varying(128) NOT NULL, "unique_temp___upv_user" character varying array NOT NULL DEFAULT '{}', "___upv_user" smallint NOT NULL DEFAULT '0', "___pv_user" smallint NOT NULL DEFAULT '0', "unique_temp___upv_visitor" character varying array NOT NULL DEFAULT '{}', "___upv_visitor" smallint NOT NULL DEFAULT '0', "___pv_visitor" smallint NOT NULL DEFAULT '0', CONSTRAINT "UQ_f221e45cfac5bea0ce0f3149fbb" UNIQUE ("date", "group"), CONSTRAINT "PK_0085d7542f6772e99b9dcfb0a9c" PRIMARY KEY ("id"))`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_f221e45cfac5bea0ce0f3149fb" ON "__chart_day__per_user_pv" ("date", "group") `);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_f221e45cfac5bea0ce0f3149fb"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "__chart_day__per_user_pv"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_f2a56da57921ca8439f45c1d95"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "__chart__per_user_pv"`);
|
||||||
|
}
|
||||||
|
}
|
@ -57,6 +57,7 @@ import UsersChart from './chart/charts/users.js';
|
|||||||
import ActiveUsersChart from './chart/charts/active-users.js';
|
import ActiveUsersChart from './chart/charts/active-users.js';
|
||||||
import InstanceChart from './chart/charts/instance.js';
|
import InstanceChart from './chart/charts/instance.js';
|
||||||
import PerUserNotesChart from './chart/charts/per-user-notes.js';
|
import PerUserNotesChart from './chart/charts/per-user-notes.js';
|
||||||
|
import PerUserPvChart from './chart/charts/per-user-pv.js';
|
||||||
import DriveChart from './chart/charts/drive.js';
|
import DriveChart from './chart/charts/drive.js';
|
||||||
import PerUserReactionsChart from './chart/charts/per-user-reactions.js';
|
import PerUserReactionsChart from './chart/charts/per-user-reactions.js';
|
||||||
import HashtagChart from './chart/charts/hashtag.js';
|
import HashtagChart from './chart/charts/hashtag.js';
|
||||||
@ -176,6 +177,7 @@ const $UsersChart: Provider = { provide: 'UsersChart', useExisting: UsersChart }
|
|||||||
const $ActiveUsersChart: Provider = { provide: 'ActiveUsersChart', useExisting: ActiveUsersChart };
|
const $ActiveUsersChart: Provider = { provide: 'ActiveUsersChart', useExisting: ActiveUsersChart };
|
||||||
const $InstanceChart: Provider = { provide: 'InstanceChart', useExisting: InstanceChart };
|
const $InstanceChart: Provider = { provide: 'InstanceChart', useExisting: InstanceChart };
|
||||||
const $PerUserNotesChart: Provider = { provide: 'PerUserNotesChart', useExisting: PerUserNotesChart };
|
const $PerUserNotesChart: Provider = { provide: 'PerUserNotesChart', useExisting: PerUserNotesChart };
|
||||||
|
const $PerUserPvChart: Provider = { provide: 'PerUserPvChart', useExisting: PerUserPvChart };
|
||||||
const $DriveChart: Provider = { provide: 'DriveChart', useExisting: DriveChart };
|
const $DriveChart: Provider = { provide: 'DriveChart', useExisting: DriveChart };
|
||||||
const $PerUserReactionsChart: Provider = { provide: 'PerUserReactionsChart', useExisting: PerUserReactionsChart };
|
const $PerUserReactionsChart: Provider = { provide: 'PerUserReactionsChart', useExisting: PerUserReactionsChart };
|
||||||
const $HashtagChart: Provider = { provide: 'HashtagChart', useExisting: HashtagChart };
|
const $HashtagChart: Provider = { provide: 'HashtagChart', useExisting: HashtagChart };
|
||||||
@ -298,6 +300,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
ActiveUsersChart,
|
ActiveUsersChart,
|
||||||
InstanceChart,
|
InstanceChart,
|
||||||
PerUserNotesChart,
|
PerUserNotesChart,
|
||||||
|
PerUserPvChart,
|
||||||
DriveChart,
|
DriveChart,
|
||||||
PerUserReactionsChart,
|
PerUserReactionsChart,
|
||||||
HashtagChart,
|
HashtagChart,
|
||||||
@ -414,6 +417,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$ActiveUsersChart,
|
$ActiveUsersChart,
|
||||||
$InstanceChart,
|
$InstanceChart,
|
||||||
$PerUserNotesChart,
|
$PerUserNotesChart,
|
||||||
|
$PerUserPvChart,
|
||||||
$DriveChart,
|
$DriveChart,
|
||||||
$PerUserReactionsChart,
|
$PerUserReactionsChart,
|
||||||
$HashtagChart,
|
$HashtagChart,
|
||||||
@ -530,6 +534,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
ActiveUsersChart,
|
ActiveUsersChart,
|
||||||
InstanceChart,
|
InstanceChart,
|
||||||
PerUserNotesChart,
|
PerUserNotesChart,
|
||||||
|
PerUserPvChart,
|
||||||
DriveChart,
|
DriveChart,
|
||||||
PerUserReactionsChart,
|
PerUserReactionsChart,
|
||||||
HashtagChart,
|
HashtagChart,
|
||||||
@ -645,6 +650,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$ActiveUsersChart,
|
$ActiveUsersChart,
|
||||||
$InstanceChart,
|
$InstanceChart,
|
||||||
$PerUserNotesChart,
|
$PerUserNotesChart,
|
||||||
|
$PerUserPvChart,
|
||||||
$DriveChart,
|
$DriveChart,
|
||||||
$PerUserReactionsChart,
|
$PerUserReactionsChart,
|
||||||
$HashtagChart,
|
$HashtagChart,
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { Injectable, Inject } from '@nestjs/common';
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
import FederationChart from './charts/federation.js';
|
import FederationChart from './charts/federation.js';
|
||||||
import NotesChart from './charts/notes.js';
|
import NotesChart from './charts/notes.js';
|
||||||
import UsersChart from './charts/users.js';
|
import UsersChart from './charts/users.js';
|
||||||
import ActiveUsersChart from './charts/active-users.js';
|
import ActiveUsersChart from './charts/active-users.js';
|
||||||
import InstanceChart from './charts/instance.js';
|
import InstanceChart from './charts/instance.js';
|
||||||
import PerUserNotesChart from './charts/per-user-notes.js';
|
import PerUserNotesChart from './charts/per-user-notes.js';
|
||||||
|
import PerUserPvChart from './charts/per-user-pv.js';
|
||||||
import DriveChart from './charts/drive.js';
|
import DriveChart from './charts/drive.js';
|
||||||
import PerUserReactionsChart from './charts/per-user-reactions.js';
|
import PerUserReactionsChart from './charts/per-user-reactions.js';
|
||||||
import HashtagChart from './charts/hashtag.js';
|
import HashtagChart from './charts/hashtag.js';
|
||||||
@ -13,7 +15,6 @@ import PerUserFollowingChart from './charts/per-user-following.js';
|
|||||||
import PerUserDriveChart from './charts/per-user-drive.js';
|
import PerUserDriveChart from './charts/per-user-drive.js';
|
||||||
import ApRequestChart from './charts/ap-request.js';
|
import ApRequestChart from './charts/ap-request.js';
|
||||||
import type { OnApplicationShutdown } from '@nestjs/common';
|
import type { OnApplicationShutdown } from '@nestjs/common';
|
||||||
import { bindThis } from '@/decorators.js';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ChartManagementService implements OnApplicationShutdown {
|
export class ChartManagementService implements OnApplicationShutdown {
|
||||||
@ -27,6 +28,7 @@ export class ChartManagementService implements OnApplicationShutdown {
|
|||||||
private activeUsersChart: ActiveUsersChart,
|
private activeUsersChart: ActiveUsersChart,
|
||||||
private instanceChart: InstanceChart,
|
private instanceChart: InstanceChart,
|
||||||
private perUserNotesChart: PerUserNotesChart,
|
private perUserNotesChart: PerUserNotesChart,
|
||||||
|
private perUserPvChart: PerUserPvChart,
|
||||||
private driveChart: DriveChart,
|
private driveChart: DriveChart,
|
||||||
private perUserReactionsChart: PerUserReactionsChart,
|
private perUserReactionsChart: PerUserReactionsChart,
|
||||||
private hashtagChart: HashtagChart,
|
private hashtagChart: HashtagChart,
|
||||||
@ -41,6 +43,7 @@ export class ChartManagementService implements OnApplicationShutdown {
|
|||||||
this.activeUsersChart,
|
this.activeUsersChart,
|
||||||
this.instanceChart,
|
this.instanceChart,
|
||||||
this.perUserNotesChart,
|
this.perUserNotesChart,
|
||||||
|
this.perUserPvChart,
|
||||||
this.driveChart,
|
this.driveChart,
|
||||||
this.perUserReactionsChart,
|
this.perUserReactionsChart,
|
||||||
this.hashtagChart,
|
this.hashtagChart,
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
import Chart from '../../core.js';
|
||||||
|
|
||||||
|
export const name = 'perUserPv';
|
||||||
|
|
||||||
|
export const schema = {
|
||||||
|
'upv.user': { uniqueIncrement: true, range: 'small' },
|
||||||
|
'pv.user': { range: 'small' },
|
||||||
|
'upv.visitor': { uniqueIncrement: true, range: 'small' },
|
||||||
|
'pv.visitor': { range: 'small' },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const entity = Chart.schemaToEntity(name, schema, true);
|
51
packages/backend/src/core/chart/charts/per-user-pv.ts
Normal file
51
packages/backend/src/core/chart/charts/per-user-pv.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
|
import { DataSource } from 'typeorm';
|
||||||
|
import type { User } from '@/models/entities/User.js';
|
||||||
|
import { AppLockService } from '@/core/AppLockService.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import Chart from '../core.js';
|
||||||
|
import { ChartLoggerService } from '../ChartLoggerService.js';
|
||||||
|
import { name, schema } from './entities/per-user-pv.js';
|
||||||
|
import type { KVs } from '../core.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ユーザーごとのプロフィール被閲覧数に関するチャート
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line import/no-default-export
|
||||||
|
@Injectable()
|
||||||
|
export default class PerUserPvChart extends Chart<typeof schema> {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.db)
|
||||||
|
private db: DataSource,
|
||||||
|
|
||||||
|
private appLockService: AppLockService,
|
||||||
|
private chartLoggerService: ChartLoggerService,
|
||||||
|
) {
|
||||||
|
super(db, (k) => appLockService.getChartInsertLock(k), chartLoggerService.logger, name, schema, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async commitByUser(user: { id: User['id'] }, key: string): Promise<void> {
|
||||||
|
await this.commit({
|
||||||
|
'upv.user': [key],
|
||||||
|
'pv.user': 1,
|
||||||
|
}, user.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async commitByVisitor(user: { id: User['id'] }, key: string): Promise<void> {
|
||||||
|
await this.commit({
|
||||||
|
'upv.visitor': [key],
|
||||||
|
'pv.visitor': 1,
|
||||||
|
}, user.id);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import { entity as UsersChart } from './charts/entities/users.js';
|
|||||||
import { entity as ActiveUsersChart } from './charts/entities/active-users.js';
|
import { entity as ActiveUsersChart } from './charts/entities/active-users.js';
|
||||||
import { entity as InstanceChart } from './charts/entities/instance.js';
|
import { entity as InstanceChart } from './charts/entities/instance.js';
|
||||||
import { entity as PerUserNotesChart } from './charts/entities/per-user-notes.js';
|
import { entity as PerUserNotesChart } from './charts/entities/per-user-notes.js';
|
||||||
|
import { entity as PerUserPvChart } from './charts/entities/per-user-pv.js';
|
||||||
import { entity as DriveChart } from './charts/entities/drive.js';
|
import { entity as DriveChart } from './charts/entities/drive.js';
|
||||||
import { entity as PerUserReactionsChart } from './charts/entities/per-user-reactions.js';
|
import { entity as PerUserReactionsChart } from './charts/entities/per-user-reactions.js';
|
||||||
import { entity as HashtagChart } from './charts/entities/hashtag.js';
|
import { entity as HashtagChart } from './charts/entities/hashtag.js';
|
||||||
@ -23,6 +24,7 @@ export const entities = [
|
|||||||
ActiveUsersChart.hour, ActiveUsersChart.day,
|
ActiveUsersChart.hour, ActiveUsersChart.day,
|
||||||
InstanceChart.hour, InstanceChart.day,
|
InstanceChart.hour, InstanceChart.day,
|
||||||
PerUserNotesChart.hour, PerUserNotesChart.day,
|
PerUserNotesChart.hour, PerUserNotesChart.day,
|
||||||
|
PerUserPvChart.hour, PerUserPvChart.day,
|
||||||
DriveChart.hour, DriveChart.day,
|
DriveChart.hour, DriveChart.day,
|
||||||
PerUserReactionsChart.hour, PerUserReactionsChart.day,
|
PerUserReactionsChart.hour, PerUserReactionsChart.day,
|
||||||
HashtagChart.hour, HashtagChart.day,
|
HashtagChart.hour, HashtagChart.day,
|
||||||
|
@ -9,15 +9,16 @@ import UsersChart from '@/core/chart/charts/users.js';
|
|||||||
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
||||||
import InstanceChart from '@/core/chart/charts/instance.js';
|
import InstanceChart from '@/core/chart/charts/instance.js';
|
||||||
import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js';
|
import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js';
|
||||||
|
import PerUserPvChart from '@/core/chart/charts/per-user-pv.js';
|
||||||
import DriveChart from '@/core/chart/charts/drive.js';
|
import DriveChart from '@/core/chart/charts/drive.js';
|
||||||
import PerUserReactionsChart from '@/core/chart/charts/per-user-reactions.js';
|
import PerUserReactionsChart from '@/core/chart/charts/per-user-reactions.js';
|
||||||
import HashtagChart from '@/core/chart/charts/hashtag.js';
|
import HashtagChart from '@/core/chart/charts/hashtag.js';
|
||||||
import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
|
import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
|
||||||
import PerUserDriveChart from '@/core/chart/charts/per-user-drive.js';
|
import PerUserDriveChart from '@/core/chart/charts/per-user-drive.js';
|
||||||
import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||||
import type Bull from 'bull';
|
import type Bull from 'bull';
|
||||||
import { bindThis } from '@/decorators.js';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CleanChartsProcessorService {
|
export class CleanChartsProcessorService {
|
||||||
@ -33,6 +34,7 @@ export class CleanChartsProcessorService {
|
|||||||
private activeUsersChart: ActiveUsersChart,
|
private activeUsersChart: ActiveUsersChart,
|
||||||
private instanceChart: InstanceChart,
|
private instanceChart: InstanceChart,
|
||||||
private perUserNotesChart: PerUserNotesChart,
|
private perUserNotesChart: PerUserNotesChart,
|
||||||
|
private perUserPvChart: PerUserPvChart,
|
||||||
private driveChart: DriveChart,
|
private driveChart: DriveChart,
|
||||||
private perUserReactionsChart: PerUserReactionsChart,
|
private perUserReactionsChart: PerUserReactionsChart,
|
||||||
private hashtagChart: HashtagChart,
|
private hashtagChart: HashtagChart,
|
||||||
@ -56,6 +58,7 @@ export class CleanChartsProcessorService {
|
|||||||
this.activeUsersChart.clean(),
|
this.activeUsersChart.clean(),
|
||||||
this.instanceChart.clean(),
|
this.instanceChart.clean(),
|
||||||
this.perUserNotesChart.clean(),
|
this.perUserNotesChart.clean(),
|
||||||
|
this.perUserPvChart.clean(),
|
||||||
this.driveChart.clean(),
|
this.driveChart.clean(),
|
||||||
this.perUserReactionsChart.clean(),
|
this.perUserReactionsChart.clean(),
|
||||||
this.hashtagChart.clean(),
|
this.hashtagChart.clean(),
|
||||||
|
@ -9,15 +9,16 @@ import UsersChart from '@/core/chart/charts/users.js';
|
|||||||
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
||||||
import InstanceChart from '@/core/chart/charts/instance.js';
|
import InstanceChart from '@/core/chart/charts/instance.js';
|
||||||
import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js';
|
import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js';
|
||||||
|
import PerUserPvChart from '@/core/chart/charts/per-user-pv.js';
|
||||||
import DriveChart from '@/core/chart/charts/drive.js';
|
import DriveChart from '@/core/chart/charts/drive.js';
|
||||||
import PerUserReactionsChart from '@/core/chart/charts/per-user-reactions.js';
|
import PerUserReactionsChart from '@/core/chart/charts/per-user-reactions.js';
|
||||||
import HashtagChart from '@/core/chart/charts/hashtag.js';
|
import HashtagChart from '@/core/chart/charts/hashtag.js';
|
||||||
import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
|
import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
|
||||||
import PerUserDriveChart from '@/core/chart/charts/per-user-drive.js';
|
import PerUserDriveChart from '@/core/chart/charts/per-user-drive.js';
|
||||||
import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||||
import type Bull from 'bull';
|
import type Bull from 'bull';
|
||||||
import { bindThis } from '@/decorators.js';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TickChartsProcessorService {
|
export class TickChartsProcessorService {
|
||||||
@ -33,6 +34,7 @@ export class TickChartsProcessorService {
|
|||||||
private activeUsersChart: ActiveUsersChart,
|
private activeUsersChart: ActiveUsersChart,
|
||||||
private instanceChart: InstanceChart,
|
private instanceChart: InstanceChart,
|
||||||
private perUserNotesChart: PerUserNotesChart,
|
private perUserNotesChart: PerUserNotesChart,
|
||||||
|
private perUserPvChart: PerUserPvChart,
|
||||||
private driveChart: DriveChart,
|
private driveChart: DriveChart,
|
||||||
private perUserReactionsChart: PerUserReactionsChart,
|
private perUserReactionsChart: PerUserReactionsChart,
|
||||||
private hashtagChart: HashtagChart,
|
private hashtagChart: HashtagChart,
|
||||||
@ -56,6 +58,7 @@ export class TickChartsProcessorService {
|
|||||||
this.activeUsersChart.tick(false),
|
this.activeUsersChart.tick(false),
|
||||||
this.instanceChart.tick(false),
|
this.instanceChart.tick(false),
|
||||||
this.perUserNotesChart.tick(false),
|
this.perUserNotesChart.tick(false),
|
||||||
|
this.perUserPvChart.tick(false),
|
||||||
this.driveChart.tick(false),
|
this.driveChart.tick(false),
|
||||||
this.perUserReactionsChart.tick(false),
|
this.perUserReactionsChart.tick(false),
|
||||||
this.hashtagChart.tick(false),
|
this.hashtagChart.tick(false),
|
||||||
|
@ -99,6 +99,7 @@ import * as ep___charts_notes from './endpoints/charts/notes.js';
|
|||||||
import * as ep___charts_user_drive from './endpoints/charts/user/drive.js';
|
import * as ep___charts_user_drive from './endpoints/charts/user/drive.js';
|
||||||
import * as ep___charts_user_following from './endpoints/charts/user/following.js';
|
import * as ep___charts_user_following from './endpoints/charts/user/following.js';
|
||||||
import * as ep___charts_user_notes from './endpoints/charts/user/notes.js';
|
import * as ep___charts_user_notes from './endpoints/charts/user/notes.js';
|
||||||
|
import * as ep___charts_user_pv from './endpoints/charts/user/pv.js';
|
||||||
import * as ep___charts_user_reactions from './endpoints/charts/user/reactions.js';
|
import * as ep___charts_user_reactions from './endpoints/charts/user/reactions.js';
|
||||||
import * as ep___charts_users from './endpoints/charts/users.js';
|
import * as ep___charts_users from './endpoints/charts/users.js';
|
||||||
import * as ep___clips_addNote from './endpoints/clips/add-note.js';
|
import * as ep___clips_addNote from './endpoints/clips/add-note.js';
|
||||||
@ -419,6 +420,7 @@ const $charts_notes: Provider = { provide: 'ep:charts/notes', useClass: ep___cha
|
|||||||
const $charts_user_drive: Provider = { provide: 'ep:charts/user/drive', useClass: ep___charts_user_drive.default };
|
const $charts_user_drive: Provider = { provide: 'ep:charts/user/drive', useClass: ep___charts_user_drive.default };
|
||||||
const $charts_user_following: Provider = { provide: 'ep:charts/user/following', useClass: ep___charts_user_following.default };
|
const $charts_user_following: Provider = { provide: 'ep:charts/user/following', useClass: ep___charts_user_following.default };
|
||||||
const $charts_user_notes: Provider = { provide: 'ep:charts/user/notes', useClass: ep___charts_user_notes.default };
|
const $charts_user_notes: Provider = { provide: 'ep:charts/user/notes', useClass: ep___charts_user_notes.default };
|
||||||
|
const $charts_user_pv: Provider = { provide: 'ep:charts/user/pv', useClass: ep___charts_user_pv.default };
|
||||||
const $charts_user_reactions: Provider = { provide: 'ep:charts/user/reactions', useClass: ep___charts_user_reactions.default };
|
const $charts_user_reactions: Provider = { provide: 'ep:charts/user/reactions', useClass: ep___charts_user_reactions.default };
|
||||||
const $charts_users: Provider = { provide: 'ep:charts/users', useClass: ep___charts_users.default };
|
const $charts_users: Provider = { provide: 'ep:charts/users', useClass: ep___charts_users.default };
|
||||||
const $clips_addNote: Provider = { provide: 'ep:clips/add-note', useClass: ep___clips_addNote.default };
|
const $clips_addNote: Provider = { provide: 'ep:clips/add-note', useClass: ep___clips_addNote.default };
|
||||||
@ -743,6 +745,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
|
|||||||
$charts_user_drive,
|
$charts_user_drive,
|
||||||
$charts_user_following,
|
$charts_user_following,
|
||||||
$charts_user_notes,
|
$charts_user_notes,
|
||||||
|
$charts_user_pv,
|
||||||
$charts_user_reactions,
|
$charts_user_reactions,
|
||||||
$charts_users,
|
$charts_users,
|
||||||
$clips_addNote,
|
$clips_addNote,
|
||||||
@ -1061,6 +1064,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
|
|||||||
$charts_user_drive,
|
$charts_user_drive,
|
||||||
$charts_user_following,
|
$charts_user_following,
|
||||||
$charts_user_notes,
|
$charts_user_notes,
|
||||||
|
$charts_user_pv,
|
||||||
$charts_user_reactions,
|
$charts_user_reactions,
|
||||||
$charts_users,
|
$charts_users,
|
||||||
$clips_addNote,
|
$clips_addNote,
|
||||||
|
@ -98,6 +98,7 @@ import * as ep___charts_notes from './endpoints/charts/notes.js';
|
|||||||
import * as ep___charts_user_drive from './endpoints/charts/user/drive.js';
|
import * as ep___charts_user_drive from './endpoints/charts/user/drive.js';
|
||||||
import * as ep___charts_user_following from './endpoints/charts/user/following.js';
|
import * as ep___charts_user_following from './endpoints/charts/user/following.js';
|
||||||
import * as ep___charts_user_notes from './endpoints/charts/user/notes.js';
|
import * as ep___charts_user_notes from './endpoints/charts/user/notes.js';
|
||||||
|
import * as ep___charts_user_pv from './endpoints/charts/user/pv.js';
|
||||||
import * as ep___charts_user_reactions from './endpoints/charts/user/reactions.js';
|
import * as ep___charts_user_reactions from './endpoints/charts/user/reactions.js';
|
||||||
import * as ep___charts_users from './endpoints/charts/users.js';
|
import * as ep___charts_users from './endpoints/charts/users.js';
|
||||||
import * as ep___clips_addNote from './endpoints/clips/add-note.js';
|
import * as ep___clips_addNote from './endpoints/clips/add-note.js';
|
||||||
@ -416,6 +417,7 @@ const eps = [
|
|||||||
['charts/user/drive', ep___charts_user_drive],
|
['charts/user/drive', ep___charts_user_drive],
|
||||||
['charts/user/following', ep___charts_user_following],
|
['charts/user/following', ep___charts_user_following],
|
||||||
['charts/user/notes', ep___charts_user_notes],
|
['charts/user/notes', ep___charts_user_notes],
|
||||||
|
['charts/user/pv', ep___charts_user_pv],
|
||||||
['charts/user/reactions', ep___charts_user_reactions],
|
['charts/user/reactions', ep___charts_user_reactions],
|
||||||
['charts/users', ep___charts_users],
|
['charts/users', ep___charts_users],
|
||||||
['clips/add-note', ep___clips_addNote],
|
['clips/add-note', ep___clips_addNote],
|
||||||
|
37
packages/backend/src/server/api/endpoints/charts/user/pv.ts
Normal file
37
packages/backend/src/server/api/endpoints/charts/user/pv.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { getJsonSchema } from '@/core/chart/core.js';
|
||||||
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
|
import PerUserPvChart from '@/core/chart/charts/per-user-pv.js';
|
||||||
|
import { schema } from '@/core/chart/charts/entities/per-user-notes.js';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
tags: ['charts', 'users'],
|
||||||
|
|
||||||
|
res: getJsonSchema(schema),
|
||||||
|
|
||||||
|
allowGet: true,
|
||||||
|
cacheSec: 60 * 60,
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
span: { type: 'string', enum: ['day', 'hour'] },
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
|
||||||
|
offset: { type: 'integer', nullable: true, default: null },
|
||||||
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['span', 'userId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-default-export
|
||||||
|
@Injectable()
|
||||||
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
|
constructor(
|
||||||
|
private perUserPvChart: PerUserPvChart,
|
||||||
|
) {
|
||||||
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
return await this.perUserPvChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
|||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
|
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import PerUserPvChart from '@/core/chart/charts/per-user-pv.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
import { ApiLoggerService } from '../../ApiLoggerService.js';
|
import { ApiLoggerService } from '../../ApiLoggerService.js';
|
||||||
import type { FindOptionsWhere } from 'typeorm';
|
import type { FindOptionsWhere } from 'typeorm';
|
||||||
@ -90,9 +91,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
|
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private remoteUserResolveService: RemoteUserResolveService,
|
private remoteUserResolveService: RemoteUserResolveService,
|
||||||
|
private perUserPvChart: PerUserPvChart,
|
||||||
private apiLoggerService: ApiLoggerService,
|
private apiLoggerService: ApiLoggerService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me, _1, _2, _3, ip) => {
|
||||||
let user;
|
let user;
|
||||||
|
|
||||||
const isAdminOrModerator = me && (me.isAdmin || me.isModerator);
|
const isAdminOrModerator = me && (me.isAdmin || me.isModerator);
|
||||||
@ -137,6 +139,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
throw new ApiError(meta.errors.noSuchUser);
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (me == null && ip != null) {
|
||||||
|
this.perUserPvChart.commitByVisitor(user, ip);
|
||||||
|
} else if (me && me.id !== user.id) {
|
||||||
|
this.perUserPvChart.commitByUser(user, me.id);
|
||||||
|
}
|
||||||
|
|
||||||
return await this.userEntityService.pack(user, me, {
|
return await this.userEntityService.pack(user, me, {
|
||||||
detail: true,
|
detail: true,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user