From cdad4d9305ed160fd359985e8feee03609fd051d Mon Sep 17 00:00:00 2001 From: freyamade Date: Mon, 22 Jul 2024 01:19:45 +0200 Subject: [PATCH] moving to xivapi beta --- backend/api/views/xivgear.py | 3 +- backend/api/xivapi_item_search_client.py | 32 ++++++-------------- frontend/src/components/modals/changelog.vue | 28 +++-------------- 3 files changed, 15 insertions(+), 48 deletions(-) diff --git a/backend/api/views/xivgear.py b/backend/api/views/xivgear.py index 4ded58f..0859084 100644 --- a/backend/api/views/xivgear.py +++ b/backend/api/views/xivgear.py @@ -149,8 +149,7 @@ def get(self, request: Request, id: str) -> Response: gear_names = XIVAPISearchClient.get_item_information(*sa_gear.values()) except requests.HTTPError as e: return Response({'message': e.response.text}, 400) - - if len(gear_names) != len(sa_gear): + except ValueError: return Response({'message': 'Could not find some of the items on XIVAPI, please try again later!'}, 400) # Use the returned map to calculate the min and max ils, and also replace IDs with names in sa_gear diff --git a/backend/api/xivapi_item_search_client.py b/backend/api/xivapi_item_search_client.py index 0f19d79..52d9cd9 100644 --- a/backend/api/xivapi_item_search_client.py +++ b/backend/api/xivapi_item_search_client.py @@ -9,9 +9,7 @@ class XIVAPISearchClient: - url = 'https://xivapi.com/search' - indexes = 'item' - columns = ','.join(['ID', 'Name', 'LevelItem']) + url = 'https://beta.xivapi.com/api/1/sheet/Item' @classmethod def get_item_information(cls, *item_ids: int) -> Dict[str, Dict[str, str]]: @@ -19,26 +17,16 @@ def get_item_information(cls, *item_ids: int) -> Dict[str, Dict[str, str]]: Given the Item IDs, retrieve their data from XIVAPI and return a map of ids to the name and item_level """ results = {} - # Compile the payload body and send it to the URL - payload = { - 'indexes': cls.indexes, - 'columns': cls.columns, - 'body': { - 'query': { - 'ids': { - 'values': item_ids, - } - }, - 'size': len(item_ids), - }, - } - url = cls.url - if API_KEY is not None: - url += f'?private_key={API_KEY}' - response = requests.post(url, json=payload) + item_ids = set(item_ids) + rows = ','.join(str(item_id) for item_id in item_ids) + url = f'{cls.url}?rows={rows}&fields=row_id,LevelItem.value,Name' + response = requests.get(url) response.raise_for_status() - for item in response.json().get('Results', []): - results[item['ID']] = {'name': item['Name'], 'item_level': item['LevelItem']} + for item in response.json().get('rows', []): + results[item['row_id']] = {'name': item['fields']['Name'], 'item_level': item['fields']['LevelItem']['value']} + + if len(results) != len(item_ids): + raise ValueError(f'Expected {len(item_ids)} items, retrieved {len(results)}') return results diff --git a/frontend/src/components/modals/changelog.vue b/frontend/src/components/modals/changelog.vue index b62ddde..5222a91 100644 --- a/frontend/src/components/modals/changelog.vue +++ b/frontend/src/components/modals/changelog.vue @@ -12,36 +12,16 @@

{{ version }}

-
expand_more FFXIV 7.01 Update expand_more
+
expand_more FFXIV 7.05 Update expand_more

- Added the following new types of Gear released in 7.01; + Added the following new types of Gear released in 7.05;

-
expand_more XIVGear Support expand_more
-

You can now also import BIS data from XIVGear.app

-

If you provide a URL that contains multiple sets, you will be prompted with a popup to select which one to load.

-

Please note that this feature is only on the main BIS pages, the quick signup form can only handle single set URLs!

- -
expand_more Dalamud Plugin expand_more
-

I am happy to announce that the Dalamud plugin that was teased in the last release is finally up and ready to use.

-

Currently, it must be installed as a custom plugin repo due to Dalamud Team's build systems being on hold

-

The code and installation instructions are located here!

-

If there are any questions or issues, please report them as you would anything with the website itself!

- -
expand_more API Schema expand_more
-

In the last release, API Keys were added to allow external access for possibly building an ecosystem of tools.

-

However, it only dawned on me recently that the API isn't obvious for anyone other than me.

-

There is now an OpenAPI schema available at https://savageaim.com/backend/schema/.

-

This set of documentation is mostly manually written so if there are any questions, feel free to ask on Discord/Github!

-
expand_more Fixes & Improvements expand_more
-

Fixed handling issues when XIVApi has not been updated with new items yet, when trying to import XIVGear sets.

-

Fixed a bug causing the popup generated by the "Add New" button on the Team Membership forms to not display any information.

-

Improved fetching of Teams from the database to improve speed and lessen the load on the server.

-

Added "API Schema" and "Plugin" links to the footer icons.

+

Moved to new beta version of XIVAPI, should fix XIVGear importing!