update tests to match new tag and sorting helper prototypes,

remove getTopReviewsFromStorage and getReviewsByTag from localStorage and main

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu
2022-11-30 14:49:41 -08:00
parent 5621139dd7
commit 5943a5c8ef
3 changed files with 82 additions and 112 deletions

View File

@@ -164,48 +164,6 @@ function addTagsToStorage(ID, addedTags) {
}
}
/**
* Returns the top n reviews by ID. If there are less than n reviews, returns the most possible.
* @param {number} n number of reviews to return
* @returns {Array} list of n reviews that are the top rated
*/
//legacy
export function getTopReviewsFromStorage(n) {
let resultArr = [];
for(let i = 5; i > 0; i--){
let starArr = JSON.parse(localStorage.getItem(`star${i}`));
if(!starArr){
continue;
}
for(let j = starArr.length - 1; j >= 0; j--) {
let review = JSON.parse(localStorage.getItem(`review${starArr[j]}`))
resultArr.push(review);
if(resultArr.length == n) {
break;
}
}
if(resultArr.length == n) {
break;
}
}
return resultArr;
}
/**
* Returns all reviews which contain the same tag specified.
* @param {string} tag to filter by
* @returns {Object} list of reviews that all contain the specified tag
*/
//legacy
export function getReviewsByTag(tag) {
let reviewArr = [];
let tagArr = JSON.parse(localStorage.getItem("!" + tag.toLowerCase()));
for (let i in tagArr){
reviewArr.push(JSON.parse(localStorage.getItem(`review${tagArr[i]}`)));
}
return reviewArr;
}
// legacy function
export function getAllReviewsFromStorage() {
if (!(localStorage.getItem("activeIDS"))) {