Skip to content

Commit

Permalink
moving to xivapi beta
Browse files Browse the repository at this point in the history
  • Loading branch information
freyamade committed Jul 21, 2024
1 parent 8f364d8 commit cdad4d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 48 deletions.
3 changes: 1 addition & 2 deletions backend/api/views/xivgear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 10 additions & 22 deletions backend/api/xivapi_item_search_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,24 @@


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]]:
"""
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
28 changes: 4 additions & 24 deletions frontend/src/components/modals/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,16 @@
</div>
<div class="card-content content">
<h2 class="has-text-primary subtitle">{{ version }}</h2>
<div class="divider"><i class="material-icons icon">expand_more</i> FFXIV 7.01 Update <i class="material-icons icon">expand_more</i></div>
<div class="divider"><i class="material-icons icon">expand_more</i> FFXIV 7.05 Update <i class="material-icons icon">expand_more</i></div>
<p>
Added the following new types of Gear released in 7.01;
Added the following new types of Gear released in 7.05;
<ul>
<li>Light-heavy Armour and Accessories - Item Level 710</li>
<!-- <li>Light-heavy Armour and Accessories - Item Level 710</li> -->
</ul>
</p>

<div class="divider"><i class="material-icons icon">expand_more</i> XIVGear Support <i class="material-icons icon">expand_more</i></div>
<p>You can now also import BIS data from XIVGear.app</p>
<p>If you provide a URL that contains multiple sets, you will be prompted with a popup to select which one to load.</p>
<p class="has-text-info">Please note that this feature is only on the main BIS pages, the quick signup form can only handle single set URLs!</p>

<div class="divider"><i class="material-icons icon">expand_more</i> Dalamud Plugin <i class="material-icons icon">expand_more</i></div>
<p>I am happy to announce that the Dalamud plugin that was teased in the last release is finally up and ready to use.</p>
<p>Currently, it must be installed as a custom plugin repo due to Dalamud Team's build systems being on hold</p>
<p>The code and installation instructions are located <a href="https://github.com/SavageAim/plugin" target="_blank">here!</a></p>
<p>If there are any questions or issues, please report them as you would anything with the website itself!</p>

<div class="divider"><i class="material-icons icon">expand_more</i> API Schema <i class="material-icons icon">expand_more</i></div>
<p>In the last release, API Keys were added to allow external access for possibly building an ecosystem of tools.</p>
<p>However, it only dawned on me recently that the API isn't obvious for anyone other than me.</p>
<p>There is now an OpenAPI schema available at <a href="https://savageaim.com/backend/schema/" target="_blank">https://savageaim.com/backend/schema/</a>.</p>
<p>This set of documentation is mostly manually written so if there are any questions, feel free to ask on Discord/Github!</p>

<div class="divider"><i class="material-icons icon">expand_more</i> Fixes &amp; Improvements <i class="material-icons icon">expand_more</i></div>
<p>Fixed handling issues when XIVApi has not been updated with new items yet, when trying to import XIVGear sets.</p>
<p>Fixed a bug causing the popup generated by the "Add New" button on the Team Membership forms to not display any information.</p>
<p>Improved fetching of Teams from the database to improve speed and lessen the load on the server.</p>
<p>Added "API Schema" and "Plugin" links to the footer icons.</p>
<p>Moved to new beta version of XIVAPI, should fix XIVGear importing!</p>
</div>
</div>
</template>
Expand Down

0 comments on commit cdad4d9

Please sign in to comment.