Fix matching from share, add fix script

This commit is contained in:
Jonathan Cremin 2017-10-23 21:05:58 +01:00
parent 183d58a540
commit 62b7121301
7 changed files with 152 additions and 60 deletions

View file

@ -4,7 +4,7 @@ import services from '../lib/services';
import render from '../lib/render';
import models from '../models';
const debug = debuglog('combinefm:share');
const debug = debuglog('combine.fm:share');
const recentQuery = {
include: [

View file

@ -23,9 +23,14 @@ export default function* () {
if (!share) {
share = yield create(music);
const job = queue.create('search', share).save((err) => {
if (!err) console.log(job.id);
});
for (const service of services) {
if (service.id === share.service) {
continue; // eslint-disable-line no-continue
}
const job = queue.create('search', {share: share, service: service}).save((err) => {
if (!err) console.log(job.id);
});
}
}
share = share.toJSON();

View file

@ -1,7 +1,13 @@
import kue from 'kue';
import services from '../lib/services';
import render from '../lib/render';
import models from '../models';
import { find, create, findMatchesAsync } from '../lib/share';
import { find, create } from '../lib/share';
const queue = kue.createQueue({
redis: process.env.REDIS_URL,
});
export default function* (serviceId, type, itemId, format) {
this.assert(type === 'album' || type === 'track', 400, { error: 'Invalid type' });
@ -26,7 +32,15 @@ export default function* (serviceId, type, itemId, format) {
if (!share) {
share = yield create(music);
findMatchesAsync(share);
for (const service of services) {
if (service.id === share.service) {
continue; // eslint-disable-line no-continue
}
const job = queue.create('search', {share: share, service: service}).save((err) => {
if (!err) console.log(job.id);
});
}
}
}