Skip to content

Commit

Permalink
βœ” Build πŸŽ‰ 06-12-2023 ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Dec 6, 2023
1 parent c375358 commit 3ef3f35
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
2 changes: 1 addition & 1 deletion dist/fansubid/server/main.js

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/api/repository/fansub.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, FindOneOptions, FindManyOptions, EntityMetadata, FindConditions, InsertResult, UpdateResult, Not, IsNull } from 'typeorm';
import { Repository, FindOneOptions, FindManyOptions, EntityMetadata, FindConditions, InsertResult, UpdateResult } from 'typeorm';
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';

import { Fansub } from '../entities/Fansub';
Expand All @@ -14,25 +14,25 @@ export class FansubService {
@InjectRepository(Fansub) private fansubRepo: Repository<Fansub>,
private gs: GlobalService,
) {
this.migrateUrlFansub().catch(console.error);
// this.migrateUrlFansub().catch(console.error);
}

async migrateUrlFansub(): Promise<void> {
const fs = await this.fansubRepo.find({
where: [
{ urls: Not(IsNull()) }
]
});
for (const f of fs) {
const urls = JSON.parse(f.urls);
const u = {};
for (const url of urls) {
u[url.name] = url.url;
}
f.urls = JSON.stringify(u);
}
await this.fansubRepo.save(fs);
}
// async migrateUrlFansub(): Promise<void> {
// const fs = await this.fansubRepo.find({
// where: [
// { urls: Not(IsNull()) }
// ]
// });
// for (const f of fs) {
// const urls = JSON.parse(f.urls);
// const u = {};
// for (const url of urls) {
// u[url.name] = url.url;
// }
// f.urls = JSON.stringify(u);
// }
// await this.fansubRepo.save(fs);
// }

new(): Fansub {
return new Fansub();
Expand Down
43 changes: 20 additions & 23 deletions src/api/repository/rss-feed.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// NodeJS Library
import { URL } from 'node:url';

import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, FindManyOptions, FindOneOptions, EntityMetadata, FindConditions, InsertResult, UpdateResult, Not, IsNull, Equal } from 'typeorm';
import { Repository, FindManyOptions, FindOneOptions, EntityMetadata, FindConditions, InsertResult, UpdateResult } from 'typeorm';
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';

import { RssFeed } from '../entities/RssFeed';
Expand All @@ -17,27 +14,27 @@ export class RssFeedService {
@InjectRepository(RssFeed) private rssFeedRepo: Repository<RssFeed>,
private gs: GlobalService,
) {
this.migrateUrlRssFeedPath().catch(console.error);
// this.migrateUrlRssFeedPath().catch(console.error);
}

async migrateUrlRssFeedPath(): Promise<void> {
const rssFeed = await this.rssFeedRepo.find({
where: [
{ link: Not(IsNull()) }
],
relations: ['fansub_']
});
for (const rf of rssFeed) {
try {
await this.rssFeedRepo.update(
{ link: Equal(rf.link) },
{ link: new URL(rf.link).pathname }
);
} catch (e) {
await this.rssFeedRepo.remove(rf);
}
}
}
// async migrateUrlRssFeedPath(): Promise<void> {
// const rssFeed = await this.rssFeedRepo.find({
// where: [
// { link: Not(IsNull()) }
// ],
// relations: ['fansub_']
// });
// for (const rf of rssFeed) {
// try {
// await this.rssFeedRepo.update(
// { link: Equal(rf.link) },
// { link: new URL(rf.link).pathname }
// );
// } catch (e) {
// await this.rssFeedRepo.remove(rf);
// }
// }
// }

new(): RssFeed {
return new RssFeed();
Expand Down

0 comments on commit 3ef3f35

Please sign in to comment.