This commit is contained in:
seb
2026-10-24 06:19:37 +02:00
parent 1da82e2eb9
commit 62d0643b99
7 changed files with 365 additions and 0 deletions

View File

@@ -142,6 +142,37 @@ const id = await store.category.ensureByPath({ googleAuthId: 42, parentId: 5, pa
// => 12
```
## `category.generateImage`
*Source: `src/store/category/generateImage.js`*
Generates a mosaic image directly from the category's and its subcategories' articles (grouped by subcategory) and sets it as the new main picture for the category.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `inputOrCategoryId` | `number|object` | The id of the category or an options object. |
| `[maybeOptsOrSize={}]` | `object|number` | Options object or numeric size. |
| `[maybeOptsOrSize.size]` | `number` | Grid size (2 for 2x2, 3 for 3x3, 4 for 4x4). Defaults to 3 (falls back to 2 if < 7 images). |
| `[maybeTx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, fullHash: string, thumbW: number, thumbH: number, thumbHash: string, smallThumbW: number, smallThumbH: number, size: number, grid: string, articleCount: number}>` — The new main image info.
**Throws**
`Error` — If the category is not found, not authorized, size is invalid, or no images are found.
**Example**
```js
const result = await store.category.generateImage(42, 5, { size: 3 });
// => { id: 5, fullHash, thumbW, thumbH, thumbHash, smallThumbW, smallThumbH, size: 3, grid: '3x3', articleCount: 12 }
```
## `category.getCategoryArticles`
*Source: `src/store/category/getCategoryArticles.js`*