Skip to content

Commit

Permalink
Search Bar #74 (#75)
Browse files Browse the repository at this point in the history
* first working stream

* player and elastic for playlists releases and tracks

* search

* Revert "search"

This reverts commit db069db.

* Revert "Revert "search""

This reverts commit 3cca756.

* search bar

Co-authored-by: abdelillah <aghomari.professionnel@gmail.com>
  • Loading branch information
abdelillah-tech and abdelillah authored May 28, 2022
1 parent 10517ad commit 1f78372
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
12 changes: 0 additions & 12 deletions src/playlists/playlists.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ const playlist1 = data.playlists.fav_1;

const author = data.users.jayz;

const create_expected = {
title: playlist1.title,
owner: playlist1.owner,
tracks: playlist1.tracks,
};

const delete_expected = {
id: playlist1._id,
title: playlist1.title,
msg: 'Playlist deleted',
};

describe('PlaylistsController', () => {
let app: INestApplication;

Expand Down
2 changes: 2 additions & 0 deletions src/playlists/playlists.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class PlaylistsService {
const playlist = new this.playlistModel(createPlaylist);

const savedPlaylist = await playlist.save();
this.playlistsSearchService.insertIndex(savedPlaylist);
return savedPlaylist;
}

Expand Down Expand Up @@ -152,6 +153,7 @@ export class PlaylistsService {
throw new Error("Can't delete playlist");
}

this.playlistsSearchService.deleteIndex(id);
return {
id: playlist._id.toString(),
title: playlist.title,
Expand Down
1 change: 0 additions & 1 deletion src/releases/releases.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import { Test, TestingModule } from '@nestjs/testing';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { ReleasesController } from './releases.controller';
import { ReleasesService } from './releases.service';
import * as request from 'supertest';
import { getModelToken } from '@nestjs/mongoose';
import * as data from '../test-utils/data/mock_data.json';
Expand Down
2 changes: 1 addition & 1 deletion src/releases/releases.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class ReleasesService {
this.logger.log(`Checking if release "${title}" is unique`);
const release = await this.releaseModel
.findOne({ title })
.catch((error) => this.logger.error(`Failed to find release ${title}`));
.catch(() => this.logger.error(`Failed to find release ${title}`));
if (release) {
this.logger.error('Release must be unique.');
throw new BadRequestException('Release must be unique.');
Expand Down
18 changes: 9 additions & 9 deletions src/tracks/tracks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export class TracksService {
},
},
},
{
$project: { id: '$_id', username: '$username', email: '$email' },
},
],
as: 'author',
},
Expand All @@ -230,6 +233,9 @@ export class TracksService {
$expr: ['$$track_id', '$tracks'],
},
},
{
$project: { id: '$_id', title: '$title' },
},
],
as: 'release',
},
Expand All @@ -238,20 +244,14 @@ export class TracksService {
$project: {
id: '$_id',
title: 1,
fileName: 1,
feats: {
id: '$_id',
username: 1,
email: 1,
},
release: {
id: '$_id',
title: 1,
},
author: {
id: '$_id',
username: 1,
email: 1,
},
release: { $arrayElemAt: ['$release', 0] },
author: { $arrayElemAt: ['$author', 0] },
},
},
]);
Expand Down

0 comments on commit 1f78372

Please sign in to comment.