add tags and rating_distribution to Item api
This commit is contained in:
parent
1fe394c10e
commit
d3cf4da641
3 changed files with 6 additions and 3 deletions
|
@ -263,7 +263,8 @@ class ItemInSchema(Schema):
|
|||
cover_image_url: str | None
|
||||
rating: float | None
|
||||
rating_count: int | None
|
||||
rating_distribution: dict[str, int] | None
|
||||
rating_distribution: list[int] | None
|
||||
tags: list[str] | None
|
||||
# brief is deprecated
|
||||
brief: str = Field(deprecated=True, alias="display_description")
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ class DiscoverGenerator(BaseJob):
|
|||
}
|
||||
)
|
||||
for i in items:
|
||||
i.tags
|
||||
i.rating
|
||||
i.rating_count
|
||||
i.rating_distribution
|
||||
|
|
|
@ -153,9 +153,10 @@ class TagTest(TestCase):
|
|||
t2 = "tag 2"
|
||||
t3 = "tag 3"
|
||||
TagManager.tag_item_for_owner(self.user2.identity, self.book1, [t1, t3])
|
||||
self.assertEqual(self.book1.tags, [t1, t3])
|
||||
# self.book1.tags is precached when self.book1 was created (and indexed)
|
||||
self.assertEqual(TagManager.indexable_tags_for_item(self.book1), [t1, t3])
|
||||
TagManager.tag_item_for_owner(self.user2.identity, self.book1, [t2, t3])
|
||||
self.assertEqual(self.book1.tags, [t2, t3])
|
||||
self.assertEqual(TagManager.indexable_tags_for_item(self.book1), [t2, t3])
|
||||
m = Mark(self.user2.identity, self.book1)
|
||||
self.assertEqual(m.tags, [t2, t3])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue