2019-03-24 00:29:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-03-25 02:57:33 +00:00
|
|
|
const knex = require('./knex');
|
|
|
|
|
|
|
|
async function matchTags(rawTags) {
|
2019-05-06 00:01:57 +00:00
|
|
|
const tagEntries = await knex('tags').whereIn('tags.tag', rawTags.map(tag => tag.toLowerCase()));
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2019-09-10 14:48:04 +00:00
|
|
|
return Array.from(new Set(tagEntries.map((tag => tag.alias_for || tag.id)).sort())); // reduce to tag name and filter duplicates
|
2019-03-25 02:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { matchTags };
|