Download spectrum/api/models/threadReaction.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 782 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/threadReaction.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/threadReaction.js
-
curl -L -o threadReaction.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/threadReaction.js
782 Bytes
| // @flow | |
| import { db } from 'shared/db'; | |
| import type { DBThreadReaction } from 'shared/types'; | |
| // prettier-ignore | |
| export const getThreadReactions = (threadIds: Array<string>): Promise<Array<DBThreadReaction>> => { | |
| const distinctMessageIds = threadIds.filter((x, i, a) => a.indexOf(x) == i); | |
| return db | |
| .table('threadReactions') | |
| .getAll(...distinctMessageIds, { index: 'threadId' }) | |
| .filter(row => row.hasFields('deletedAt').not()) | |
| .group('threadId') | |
| .run(); | |
| }; | |
| export const hasReactedToThread = ( | |
| userId: string, | |
| threadId: string | |
| ): Promise<boolean> => { | |
| return db | |
| .table('threadReactions') | |
| .getAll([userId, threadId], { index: 'userIdAndThreadId' }) | |
| .filter(row => row.hasFields('deletedAt').not()) | |
| .count() | |
| .eq(1) | |
| .run(); | |
| }; | |