mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
Merge pull request #103 from iPromKnight/hotfix-actually-use-the-index
Hotfix: actually utilise the new compound index.
This commit is contained in:
@@ -78,7 +78,7 @@ services:
|
|||||||
# - "15692:15692"
|
# - "15692:15692"
|
||||||
volumes:
|
volumes:
|
||||||
- rabbitmq:/var/lib/rabbitmq
|
- rabbitmq:/var/lib/rabbitmq
|
||||||
hostname: ${RabbitMqConfiguration__Host}
|
hostname: ${RABBITMQ_HOST}
|
||||||
restart: *restart-policy
|
restart: *restart-policy
|
||||||
healthcheck: *rabbitmq-health
|
healthcheck: *rabbitmq-health
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ RUN dotnet publish -c Release --no-restore -o out -a $TARGETARCH
|
|||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
|
||||||
|
|
||||||
|
ENV ASPNETCORE_URLS=http://+:5050
|
||||||
|
|
||||||
WORKDIR /App
|
WORKDIR /App
|
||||||
COPY --from=build /App/out .
|
COPY --from=build /App/out .
|
||||||
RUN addgroup -S metadata && adduser -S -G metadata metadata
|
RUN addgroup -S metadata && adduser -S -G metadata metadata
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface IMongoMetadataQuery {
|
export interface IMongoMetadataQuery {
|
||||||
PrimaryTitle: { $regex: RegExp };
|
$text: { $search: string },
|
||||||
TitleType: {$in: string[]};
|
TitleType: string;
|
||||||
StartYear?: string;
|
StartYear?: string;
|
||||||
}
|
}
|
||||||
@@ -26,20 +26,11 @@ export class MongoRepository implements IMongoRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getImdbId(title: string, category: string, year?: string | number) : Promise<string | null> {
|
async getImdbId(title: string, category: string, year?: string | number) : Promise<string | null> {
|
||||||
const seriesTypes : string[] = ['tvSeries'];
|
const titleType: string = category === TorrentType.Series ? 'tvSeries' : 'movie';
|
||||||
const movieTypes : string[] = ['movie', 'tvMovie'];
|
|
||||||
|
|
||||||
let titleTypes: string[] = [];
|
|
||||||
|
|
||||||
if (category === TorrentType.Series) {
|
|
||||||
titleTypes = seriesTypes;
|
|
||||||
} else if (category === TorrentType.Movie) {
|
|
||||||
titleTypes = movieTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const query: IMongoMetadataQuery = {
|
const query: IMongoMetadataQuery = {
|
||||||
PrimaryTitle: { $regex: new RegExp(title, 'i') },
|
$text: { $search: title },
|
||||||
TitleType: {$in: titleTypes}
|
TitleType: titleType,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (year) {
|
if (year) {
|
||||||
@@ -47,7 +38,7 @@ export class MongoRepository implements IMongoRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await ImdbEntryModel.findOne(query, '_id').maxTimeMS(30000);
|
const result = await ImdbEntryModel.findOne(query, '_id', {score: {$meta: "textScore" }}).sort({score: {$meta: "textScore"}}).limit(10).maxTimeMS(30000);
|
||||||
return result ? result._id : null;
|
return result ? result._id : null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Query exceeded the 30 seconds time limit', error);
|
this.logger.error('Query exceeded the 30 seconds time limit', error);
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ xdescribe('MongoRepository Tests - Manual Tests against real cluster. Skipped by
|
|||||||
expect(result).toBe('tt0084726');
|
expect(result).toBe('tt0084726');
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
|
it('should get Tom and Jerry imdbId correctly', async () => {
|
||||||
|
await mongoRepository.connect();
|
||||||
|
const result = await mongoRepository.getImdbId('Tom and Jerry Tales', TorrentType.Series);
|
||||||
|
expect(result).toBe('tt0780438');
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
it('should get Return of the Jedi correctly', async () => {
|
it('should get Return of the Jedi correctly', async () => {
|
||||||
await mongoRepository.connect();
|
await mongoRepository.connect();
|
||||||
const result = await mongoRepository.getImdbId('Star Wars: Episode VI - Return of the Jedi', TorrentType.Movie, 1983);
|
const result = await mongoRepository.getImdbId('Star Wars: Episode VI - Return of the Jedi', TorrentType.Movie, 1983);
|
||||||
|
|||||||
Reference in New Issue
Block a user