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"
|
||||
volumes:
|
||||
- rabbitmq:/var/lib/rabbitmq
|
||||
hostname: ${RabbitMqConfiguration__Host}
|
||||
hostname: ${RABBITMQ_HOST}
|
||||
restart: *restart-policy
|
||||
healthcheck: *rabbitmq-health
|
||||
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
|
||||
|
||||
ENV ASPNETCORE_URLS=http://+:5050
|
||||
|
||||
WORKDIR /App
|
||||
COPY --from=build /App/out .
|
||||
RUN addgroup -S metadata && adduser -S -G metadata metadata
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface IMongoMetadataQuery {
|
||||
PrimaryTitle: { $regex: RegExp };
|
||||
TitleType: {$in: string[]};
|
||||
$text: { $search: string },
|
||||
TitleType: string;
|
||||
StartYear?: string;
|
||||
}
|
||||
@@ -26,20 +26,11 @@ export class MongoRepository implements IMongoRepository {
|
||||
}
|
||||
|
||||
async getImdbId(title: string, category: string, year?: string | number) : Promise<string | null> {
|
||||
const seriesTypes : string[] = ['tvSeries'];
|
||||
const movieTypes : string[] = ['movie', 'tvMovie'];
|
||||
const titleType: string = category === TorrentType.Series ? 'tvSeries' : 'movie';
|
||||
|
||||
let titleTypes: string[] = [];
|
||||
|
||||
if (category === TorrentType.Series) {
|
||||
titleTypes = seriesTypes;
|
||||
} else if (category === TorrentType.Movie) {
|
||||
titleTypes = movieTypes;
|
||||
}
|
||||
|
||||
const query: IMongoMetadataQuery = {
|
||||
PrimaryTitle: { $regex: new RegExp(title, 'i') },
|
||||
TitleType: {$in: titleTypes}
|
||||
$text: { $search: title },
|
||||
TitleType: titleType,
|
||||
};
|
||||
|
||||
if (year) {
|
||||
@@ -47,7 +38,7 @@ export class MongoRepository implements IMongoRepository {
|
||||
}
|
||||
|
||||
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;
|
||||
} catch (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');
|
||||
}, 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 () => {
|
||||
await mongoRepository.connect();
|
||||
const result = await mongoRepository.getImdbId('Star Wars: Episode VI - Return of the Jedi', TorrentType.Movie, 1983);
|
||||
|
||||
Reference in New Issue
Block a user