From 050638ae437b458ef653f5559311b739c5883d27 Mon Sep 17 00:00:00 2001 From: Yarne Coppens Date: Thu, 22 Aug 2024 14:10:17 +0200 Subject: [PATCH] Use new refactored API --- static/javascript/statistics.js | 10 ++++++++-- static/javascript/wishlist.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/static/javascript/statistics.js b/static/javascript/statistics.js index 188ab76..0dc91a9 100644 --- a/static/javascript/statistics.js +++ b/static/javascript/statistics.js @@ -171,6 +171,12 @@ async function create_multiple_boardgame_chart(url, card_to_fill, footer_attribu } + function footer_attribute_to_value(obj, footer_attribute){ + if (!footer_attribute) return obj; + const properties = footer_attribute.split('.'); + return footer_attribute_to_value(obj[properties.shift()], properties.join('.')) + } + statistic_data = await makeRequest(url) const card_header = document.createElement('div') @@ -195,7 +201,7 @@ async function create_multiple_boardgame_chart(url, card_to_fill, footer_attribu if (footer_attribute != ''){ for (boardgame_index in boardgames_to_grid){ - let footer_string = boardgames_to_grid[boardgame_index][footer_attribute] + let footer_string = footer_attribute_to_value(boardgames_to_grid[boardgame_index], footer_attribute) if (footer_preamble != ''){ footer_string = footer_preamble + footer_string } @@ -247,7 +253,7 @@ async function loadStatistics(){ const most_expensive_games_card = most_expensive_games_card_col.firstChild statistic_row.appendChild(most_expensive_games_card_col) const most_expensive_games_url = api_url + '/statistics/most_expensive_games?top_amount=6' - create_multiple_boardgame_chart(most_expensive_games_url, most_expensive_games_card, 'price_paid', '\u20AC ') + create_multiple_boardgame_chart(most_expensive_games_url, most_expensive_games_card, 'owned_info.price_paid', '\u20AC ') const shelf_of_shame_card_col = create_statistic_card_col() diff --git a/static/javascript/wishlist.js b/static/javascript/wishlist.js index 7637442..4fb6971 100644 --- a/static/javascript/wishlist.js +++ b/static/javascript/wishlist.js @@ -14,7 +14,7 @@ async function loadWishlistedGames() { }, columns: [ { - data: 'wishlist_priority' + data: 'wishlist_info.wishlist_priority' }, { data: 'thumbnail_url',