mirror of
https://github.com/movie-web/backend.git
synced 2025-09-13 14:53:25 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b8016023a4 | ||
|
6f48b62275 | ||
|
709d871a51 | ||
|
b2400775fb | ||
|
c6720d390a | ||
|
d55e0897a9 | ||
|
4937f148c6 | ||
|
f54a45256b | ||
|
f1f7660ea2 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "backend",
|
"name": "backend",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://github.com/movie-web/backend",
|
"homepage": "https://github.com/movie-web/backend",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@@ -8,7 +8,7 @@ const fragments = {
|
|||||||
dockerdev: dockerFragment,
|
dockerdev: dockerFragment,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const version = '1.0.3';
|
export const version = process.env.npm_package_version ?? 'unknown';
|
||||||
|
|
||||||
export const conf = createConfigLoader()
|
export const conf = createConfigLoader()
|
||||||
.addFromEnvironment('MWB_')
|
.addFromEnvironment('MWB_')
|
||||||
|
@@ -363,20 +363,29 @@
|
|||||||
},
|
},
|
||||||
"error_message": {
|
"error_message": {
|
||||||
"name": "error_message",
|
"name": "error_message",
|
||||||
"type": "varchar(255)",
|
"type": "text",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "string"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
"full_error": {
|
"full_error": {
|
||||||
"name": "full_error",
|
"name": "full_error",
|
||||||
"type": "varchar(255)",
|
"type": "text",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"hostname": {
|
||||||
|
"name": "hostname",
|
||||||
|
"type": "varchar(255)",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
"mappedType": "string"
|
"mappedType": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
25
src/db/migrations/Migration20231111160045.ts
Normal file
25
src/db/migrations/Migration20231111160045.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20231111160045 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table "provider_metrics" add column "hostname" varchar(255) not null;',
|
||||||
|
);
|
||||||
|
this.addSql(
|
||||||
|
'alter table "provider_metrics" alter column "error_message" type text using ("error_message"::text);',
|
||||||
|
);
|
||||||
|
this.addSql(
|
||||||
|
'alter table "provider_metrics" alter column "full_error" type text using ("full_error"::text);',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table "provider_metrics" alter column "error_message" type varchar(255) using ("error_message"::varchar(255));',
|
||||||
|
);
|
||||||
|
this.addSql(
|
||||||
|
'alter table "provider_metrics" alter column "full_error" type varchar(255) using ("full_error"::varchar(255));',
|
||||||
|
);
|
||||||
|
this.addSql('alter table "provider_metrics" drop column "hostname";');
|
||||||
|
}
|
||||||
|
}
|
@@ -40,9 +40,12 @@ export class ProviderMetric {
|
|||||||
@Property({ name: 'embed_id', nullable: true })
|
@Property({ name: 'embed_id', nullable: true })
|
||||||
embedId?: string;
|
embedId?: string;
|
||||||
|
|
||||||
@Property({ name: 'error_message', nullable: true })
|
@Property({ name: 'error_message', nullable: true, type: 'text' })
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
|
|
||||||
@Property({ name: 'full_error', nullable: true })
|
@Property({ name: 'full_error', nullable: true, type: 'text' })
|
||||||
fullError?: string;
|
fullError?: string;
|
||||||
|
|
||||||
|
@Property({ name: 'hostname' })
|
||||||
|
hostname!: string;
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ export type Metrics = {
|
|||||||
| 'type'
|
| 'type'
|
||||||
| 'provider_id'
|
| 'provider_id'
|
||||||
| 'embed_id'
|
| 'embed_id'
|
||||||
|
| 'hostname'
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ export async function setupMetrics(app: FastifyInstance) {
|
|||||||
'tmdb_id',
|
'tmdb_id',
|
||||||
'type',
|
'type',
|
||||||
'embed_id',
|
'embed_id',
|
||||||
|
'hostname',
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@@ -37,19 +37,25 @@ export const metricsRouter = makeRouter((app) => {
|
|||||||
window: '30m',
|
window: '30m',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hostname = req.headers.origin?.slice(0, 255) ?? 'unknown origin';
|
||||||
|
|
||||||
const entities = body.items.map((v) => {
|
const entities = body.items.map((v) => {
|
||||||
|
const errorMessage = v.errorMessage?.slice(0, 200);
|
||||||
|
const truncatedFullError = v.fullError?.slice(0, 2000);
|
||||||
|
|
||||||
const metric = new ProviderMetric();
|
const metric = new ProviderMetric();
|
||||||
em.assign(metric, {
|
em.assign(metric, {
|
||||||
providerId: v.providerId,
|
providerId: v.providerId,
|
||||||
embedId: v.embedId,
|
embedId: v.embedId,
|
||||||
fullError: v.fullError,
|
fullError: truncatedFullError,
|
||||||
errorMessage: v.errorMessage,
|
errorMessage: errorMessage,
|
||||||
episodeId: v.episodeId,
|
episodeId: v.episodeId,
|
||||||
seasonId: v.seasonId,
|
seasonId: v.seasonId,
|
||||||
status: v.status,
|
status: v.status,
|
||||||
title: v.title,
|
title: v.title,
|
||||||
tmdbId: v.tmdbId,
|
tmdbId: v.tmdbId,
|
||||||
type: v.type,
|
type: v.type,
|
||||||
|
hostname,
|
||||||
});
|
});
|
||||||
return metric;
|
return metric;
|
||||||
});
|
});
|
||||||
@@ -63,6 +69,7 @@ export const metricsRouter = makeRouter((app) => {
|
|||||||
title: entity.title,
|
title: entity.title,
|
||||||
tmdb_id: entity.tmdbId,
|
tmdb_id: entity.tmdbId,
|
||||||
type: entity.type,
|
type: entity.type,
|
||||||
|
hostname,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user