mirror of
https://github.com/norohind/jubilant-system-web.git
synced 2025-04-24 20:40:57 +03:00
Add now/by-name endpoint
This commit is contained in:
parent
910d3579df
commit
9dc27157ff
@ -99,3 +99,7 @@ class SqliteModel:
|
||||
squad[pretty_key] = squad.pop(key)
|
||||
|
||||
return squads
|
||||
|
||||
def name2tags(self, name: str) -> list[dict]:
|
||||
v = self.get_db().execute(sqlite_sql_requests.name2tags, {'name': name}).fetchall()
|
||||
return v
|
||||
|
@ -43,3 +43,12 @@ from squadrons_current_data
|
||||
where tag like :tag
|
||||
order by platform;
|
||||
"""
|
||||
|
||||
name2tags = """select
|
||||
platform,
|
||||
squad_id,
|
||||
updated as updated_at,
|
||||
name,
|
||||
tag
|
||||
from squadrons_current_data
|
||||
where lower(name) = lower(:name);"""
|
||||
|
@ -67,6 +67,11 @@ class SquadsInfoByTag:
|
||||
resp.text = json.dumps(model_answer)
|
||||
|
||||
|
||||
class SquadsName2Tags:
|
||||
def on_get(self, req: falcon.request.Request, resp: falcon.response.Response, name: str):
|
||||
resp.content_type = falcon.MEDIA_JSON
|
||||
resp.text = json.dumps(model.name2tags(name))
|
||||
|
||||
class AppFixedLogging(falcon.App):
|
||||
def _python_error_handler(self, req: falcon.request.Request, resp: falcon.response.Response, error, params):
|
||||
__exception__ = error
|
||||
@ -79,6 +84,7 @@ application.add_route('/squads/now/by-tag/{details_type}/{tag}', SquadsInfoByTag
|
||||
|
||||
application.add_route('/api/squads/now/by-tag/{details_type}/{tag}', SquadsInfoByTag(is_pattern=False))
|
||||
application.add_route('/api/squads/now/search/by-tag/{details_type}/{tag}', SquadsInfoByTag(is_pattern=True))
|
||||
application.add_route('/api/squads/now/by-name/{name}', SquadsName2Tags())
|
||||
|
||||
if __name__ == '__main__':
|
||||
import waitress
|
||||
|
Loading…
x
Reference in New Issue
Block a user