Skip to content

Commit

Permalink
Fixed DQL paging
Browse files Browse the repository at this point in the history
  • Loading branch information
Yandawl committed Feb 15, 2021
1 parent 7d501c8 commit 4afb1bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ async def fetch_example_results():
name="Elysium"
)

# Item search with paging
item = await client.index_search(
name="Eden",
indexes=["Item"],
columns=["ID", "Name"],
filters=[
Filter("LevelItem", "gt", 520)
],
sort=Sort("LevelItem", False),
page=0,
per_page=10
)

# Fuzzy search XIVAPI game data for a recipe by name. Results will be in English.
recipe = await client.index_search(
name="Crimson Cider",
Expand All @@ -92,8 +105,7 @@ async def fetch_example_results():
)

filters = [
Filter("ClassJobLevel", "gte", 0),
Filter("ClassJobCategory", "gt", 0),
Filter("ClassJobLevel", "gte", 0)
]

# Get non-npc actions matching a given term (Defiance)
Expand Down
2 changes: 1 addition & 1 deletion pyxivapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__author__ = 'Lethys'
__license__ = 'MIT'
__copyright__ = 'Copyright 2019 (c) Lethys'
__version__ = '0.5.0'
__version__ = '0.5.1'

from .client import XIVAPIClient
from .exceptions import (
Expand Down
11 changes: 7 additions & 4 deletions pyxivapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

from aiohttp import ClientSession

from .exceptions import XIVAPIBadRequest, XIVAPIForbidden, XIVAPINotFound, XIVAPIServiceUnavailable, \
XIVAPIInvalidLanguage, XIVAPIError, XIVAPIInvalidIndex, XIVAPIInvalidColumns, XIVAPIInvalidAlgo
from .exceptions import (
XIVAPIBadRequest, XIVAPIForbidden, XIVAPINotFound, XIVAPIServiceUnavailable,
XIVAPIInvalidLanguage, XIVAPIError, XIVAPIInvalidIndex, XIVAPIInvalidColumns,
XIVAPIInvalidAlgo
)
from .decorators import timed
from .models import Filter, Sort

Expand Down Expand Up @@ -218,7 +221,7 @@ async def pvpteam_by_id(self, lodestone_id):
return await self.process_response(response)

@timed
async def index_search(self, name, indexes=(), columns=(), filters: List[Filter] = (), sort: Sort = None, page=1, per_page=10, language="en", string_algo="match"):
async def index_search(self, name, indexes=(), columns=(), filters: List[Filter] = (), sort: Sort = None, page=0, per_page=10, language="en", string_algo="match"):
"""|coro|
Search for data from on specific indexes.
Parameters
Expand Down Expand Up @@ -304,7 +307,7 @@ async def index_search(self, name, indexes=(), columns=(), filters: List[Filter]
}]
}
},
"from": (page * per_page),
"from": page,
"size": per_page
}
}
Expand Down

0 comments on commit 4afb1bf

Please sign in to comment.