Beamlnwza commited on
Commit
2b30a41
·
1 Parent(s): d99687a

adjust view index = 0

Browse files
Files changed (1) hide show
  1. src/endpoints/view.py +7 -4
src/endpoints/view.py CHANGED
@@ -30,7 +30,7 @@ async def view(user: UUID, index: int | None = None) -> ViewResult:
30
  if len(path_objs) == 0:
31
  return ViewResult(user=User(uuid=user), method=Method.index, result=None)
32
 
33
- if index:
34
  result: ViewResult = await view_index(User(uuid=user), index, path_objs)
35
  return result
36
 
@@ -39,7 +39,8 @@ async def view(user: UUID, index: int | None = None) -> ViewResult:
39
 
40
 
41
  async def view_index(user: User, index: int, path_objs) -> ViewResult:
42
- imgs = [obj for obj in path_objs if obj.endswith(f'{str(index).zfill(2)}.png')]
 
43
  if len(imgs) > 0:
44
  img_url = f'https://{BUCKET_NAME}.s3.amazonaws.com/{imgs[0]}'
45
  return ViewResult(user=user, method=Method.index, result=[ViewImage(index=index, image_url=img_url)])
@@ -50,9 +51,11 @@ async def view_index(user: User, index: int, path_objs) -> ViewResult:
50
  async def view_all(user: User, path_objs) -> ViewResult:
51
  img_urls = []
52
  for index in range(0, 88):
53
- imgs = [obj for obj in path_objs if obj.endswith(f'{str(index).zfill(2)}.png')]
 
54
  if len(imgs) > 0:
55
- img_urls.append(f'https://{BUCKET_NAME}.s3.amazonaws.com/{imgs[0]}')
 
56
  else:
57
  return ViewResult(user=user, method=Method.all, result=None)
58
 
 
30
  if len(path_objs) == 0:
31
  return ViewResult(user=User(uuid=user), method=Method.index, result=None)
32
 
33
+ if index or index == 0:
34
  result: ViewResult = await view_index(User(uuid=user), index, path_objs)
35
  return result
36
 
 
39
 
40
 
41
  async def view_index(user: User, index: int, path_objs) -> ViewResult:
42
+ imgs = [obj for obj in path_objs if obj.endswith(
43
+ f'{str(index).zfill(2)}.png')]
44
  if len(imgs) > 0:
45
  img_url = f'https://{BUCKET_NAME}.s3.amazonaws.com/{imgs[0]}'
46
  return ViewResult(user=user, method=Method.index, result=[ViewImage(index=index, image_url=img_url)])
 
51
  async def view_all(user: User, path_objs) -> ViewResult:
52
  img_urls = []
53
  for index in range(0, 88):
54
+ imgs = [obj for obj in path_objs if obj.endswith(
55
+ f'{str(index).zfill(2)}.png')]
56
  if len(imgs) > 0:
57
+ img_urls.append(
58
+ f'https://{BUCKET_NAME}.s3.amazonaws.com/{imgs[0]}')
59
  else:
60
  return ViewResult(user=user, method=Method.all, result=None)
61