freddyaboulton HF Staff commited on
Commit
5f709c4
·
1 Parent(s): 9f33305

Add ordering and increase default limit

Browse files
Files changed (2) hide show
  1. app.py +4 -1
  2. data/custom_components.db +0 -0
app.py CHANGED
@@ -38,6 +38,9 @@ class CustomComponent(Model):
38
  subdomain = fields.CharField(max_length=600, null=True)
39
  likes = fields.IntField(default=0)
40
 
 
 
 
41
 
42
  CustomComponentPydantic = pydantic_model_creator(CustomComponent)
43
 
@@ -235,7 +238,7 @@ async def get_names_and_tags():
235
 
236
  @app.get("/components", response_model=list[CustomComponentPydantic])
237
  @app.get("/components/", response_model=list[CustomComponentPydantic])
238
- async def get_components(skip: int = 0, limit: int = 10, name_or_tags: str = None):
239
  if name_or_tags:
240
  filter_set = []
241
  for n in name_or_tags.split(","):
 
38
  subdomain = fields.CharField(max_length=600, null=True)
39
  likes = fields.IntField(default=0)
40
 
41
+ class Meta:
42
+ ordering = ["-likes"]
43
+
44
 
45
  CustomComponentPydantic = pydantic_model_creator(CustomComponent)
46
 
 
238
 
239
  @app.get("/components", response_model=list[CustomComponentPydantic])
240
  @app.get("/components/", response_model=list[CustomComponentPydantic])
241
+ async def get_components(skip: int = 0, limit: int = 1000, name_or_tags: str = None):
242
  if name_or_tags:
243
  filter_set = []
244
  for n in name_or_tags.split(","):
data/custom_components.db CHANGED
Binary files a/data/custom_components.db and b/data/custom_components.db differ