Commit c6179ef6 authored by nanahira's avatar nanahira

use matching tag only

parent 8206c598
Pipeline #9695 failed with stages
in 57 seconds
......@@ -32,7 +32,7 @@ export class PicSourceInstance extends PicSource {
const page = this.nextPage();
const data = await this.ctx.http.get<PicInfo[]>(this.config.endpoint, {
params: {
tags: picTags.join('+'),
tags: picTags.length ? picTags.join('+') : undefined,
limit: 1000,
page: page,
},
......@@ -47,6 +47,12 @@ export class PicSourceInstance extends PicSource {
this.page = 1;
return this.randomPic(picTags);
}
const matchingData = picTags.length
? data.filter((d) => d.tags.split(' ').some((t) => picTags.includes(t)))
: data;
if (!matchingData.length) {
return;
}
const pic = Random.pick(data);
return {
url: this.config.useOriginal ? pic.file_url : pic.sample_url,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment