Results are now sorted by how many of the tags each result fits

This commit is contained in:
Kylart 2018-03-10 16:06:14 +01:00
parent 2a544c5569
commit ee0b4d6cb7
2 changed files with 13 additions and 4 deletions

View File

@ -31,6 +31,7 @@
no-data-text='No data available, did you register your account and set your MyAnimeList public? If yes, it is possible that the account you entered was wrong.', no-data-text='No data available, did you register your account and set your MyAnimeList public? If yes, it is possible that the account you entered was wrong.',
no-results-text='Seems like you haven\'t watched this one ;)', no-results-text='Seems like you haven\'t watched this one ;)',
rows-per-page-text='Anime per page:', rows-per-page-text='Anime per page:',
:disable-initial-sort='true',
:loading='isLoading', :loading='isLoading',
:headers='headers', :headers='headers',
:items='lists', :items='lists',

View File

@ -34,16 +34,19 @@ export default {
start: entry.myStartDate === '0000-00-00' ? null : entry.myStartDate, start: entry.myStartDate === '0000-00-00' ? null : entry.myStartDate,
end: entry.myEndDate === '0000-00-00' ? null : entry.myEndDate, end: entry.myEndDate === '0000-00-00' ? null : entry.myEndDate,
link: 'https://myanimelist.net/anime/' + entry.id + '/' + entry.title, link: 'https://myanimelist.net/anime/' + entry.id + '/' + entry.title,
tags: entry.tags || 'No tags' tags: entry.tags || 'No tags',
nbCorrespondingTags: 0
} }
if (state.tagsFilter.length) { if (state.tagsFilter.length) {
if (toAdd.tags !== 'No tags') { if (toAdd.tags !== 'No tags') {
_.each(state.tagsFilter, (tag) => { _.each(state.tagsFilter, (tag) => {
_.each(toAdd.tags.split(', '), (tag_) => { _.each(toAdd.tags.split(', '), (tag_) => {
tag === tag_ && result.push(toAdd) if (tag === tag_) {
++toAdd.nbCorrespondingTags
result.push(toAdd)
}
}) })
// _.includes(toAdd.tags, tag) && result.push(toAdd)
}) })
} }
} else { } else {
@ -51,6 +54,11 @@ export default {
} }
}) })
return _.uniqWith(_.orderBy(result, ['title', 'score'], ['asc', 'desc']), _.isEqual) return _.uniqWith(
_.orderBy(
result,
['nbCorrespondingTags', 'title', 'score'],
['desc', 'asc', 'desc']
), _.isEqual)
} }
} }