Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 89 additions & 13 deletions api/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ paths:
description: Successfully retrieved interest data
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/TokenInfo'
schema:
type: array
items:
$ref: '#/components/schemas/TokenInfo'
'401':
description: Unauthorized
content:
Expand Down Expand Up @@ -70,8 +70,8 @@ paths:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/VkAuthCallbackResponse'
schema:
$ref: '#/components/schemas/VkAuthCallbackResponse'
'400':
description: Bad request
content:
Expand Down Expand Up @@ -201,8 +201,8 @@ paths:
description: Successfully saved user search query
content:
application/json:
schema:
$ref: '#/components/schemas/SaveUserQueryResponse'
schema:
$ref: '#/components/schemas/SaveUserQueryResponse'
'400':
description: Bad request
content:
Expand Down Expand Up @@ -247,10 +247,10 @@ paths:
description: Successfully retrieved user search queries
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/UserSearchQuery'
schema:
type: array
items:
$ref: '#/components/schemas/UserSearchQuery'
'401':
description: Unauthorized
content:
Expand Down Expand Up @@ -336,6 +336,12 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Token not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: Conflict - already subscribed
content:
Expand Down Expand Up @@ -431,6 +437,49 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
tags: [user]
summary: Update user's token subscription
operationId: updateUserTokenSub
security:
- cookieAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateUserTokenSubRequest'
responses:
'200':
description: Successfully updated user's token sub
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateUserTokenSubResponse'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

components:
securitySchemes:
Expand Down Expand Up @@ -613,6 +662,9 @@ components:
type: string
method:
type: string
threshold:
type: number
format: float64
current_interest:
type: number
format: float64
Expand All @@ -622,7 +674,31 @@ components:
last_scan:
type: string
format: date-time
required: [id, token, category, method, current_interest, previous_interest, last_scan]
required: [id, token, category, method, threshold, current_interest, previous_interest, last_scan]
UpdateUserTokenSubRequest:
type: object
properties:
id:
type: string
minLength: 1
maxLength: 128
threshold:
type: number
method:
type: string
minLength: 1
maxLength: 128
required: [id, threshold, method]
UpdateUserTokenSubResponse:
type: object
properties:
current_interest:
type: number
format: float64
previous_interest:
type: number
format: float64
required: [current_interest, previous_interest]

Error:
type: object
Expand Down
5 changes: 5 additions & 0 deletions app/pages/token-subscriptions/ui/token-subscriptions.ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export const TokenSubscriptionsPage = () => {
<Badge variant="outline">
{mapMethodToLabel(subscription.method)}
</Badge>

<Badge variant="outline">
Уведомить при изменении на{' '}
{Math.round((subscription.threshold - 1) * 100)}%
</Badge>
</div>
</div>

Expand Down
85 changes: 84 additions & 1 deletion app/shared/api/gen/v1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export interface paths {
};
/** Get user's token subs */
get: operations['getUserTokenSubs'];
put?: never;
/** Update user's token subscription */
put: operations['updateUserTokenSub'];
/** Subscribe user to specified token */
post: operations['subscribeUserToToken'];
/** Delete user's token subscription */
Expand Down Expand Up @@ -209,12 +210,25 @@ export interface components {
category: string;
method: string;
/** Format: float64 */
threshold: number;
/** Format: float64 */
current_interest: number;
/** Format: float64 */
previous_interest: number;
/** Format: date-time */
last_scan: string;
};
UpdateUserTokenSubRequest: {
id: string;
threshold: number;
method: string;
};
UpdateUserTokenSubResponse: {
/** Format: float64 */
current_interest: number;
/** Format: float64 */
previous_interest: number;
};
Error: {
error: string;
};
Expand Down Expand Up @@ -663,6 +677,66 @@ export interface operations {
};
};
};
updateUserTokenSub: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
'application/json': components['schemas']['UpdateUserTokenSubRequest'];
};
};
responses: {
/** @description Successfully updated user's token sub */
200: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': components['schemas']['UpdateUserTokenSubResponse'];
};
};
/** @description Bad request */
400: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Unauthorized */
401: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Internal server error */
500: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': components['schemas']['Error'];
};
};
};
};
subscribeUserToToken: {
parameters: {
query?: never;
Expand Down Expand Up @@ -703,6 +777,15 @@ export interface operations {
'application/json': components['schemas']['Error'];
};
};
/** @description Token not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Conflict - already subscribed */
409: {
headers: {
Expand Down
1 change: 1 addition & 0 deletions app/shared/api/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const mockFetch = async (input: RequestInfo, init?: RequestInit) => {
token: 'россия',
category: 'news',
method: 'denormalized',
threshold: 1.5,
current_interest: 55,
previous_interest: 0,
last_scan: '2026-01-09T00:00:00Z',
Expand Down
Loading