Download spectrum/api/queries/channel/metaData.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 886 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/channel/metaData.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/channel/metaData.js
-
curl -L -o metaData.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/channel/metaData.js
886 Bytes
| // TODO: Flow type again | |
| import Raven from 'shared/raven'; | |
| import type { DBChannel } from 'shared/types'; | |
| import type { GraphQLContext } from '../../'; | |
| import { canViewChannel } from '../../utils/permissions'; | |
| export default async (root: DBChannel, _: any, ctx: GraphQLContext) => { | |
| const { user, loaders } = ctx; | |
| const { id, memberCount: rootMemberCount } = root; | |
| if (!(await canViewChannel(user, id, loaders))) { | |
| return { | |
| members: 0, | |
| }; | |
| } | |
| if (typeof rootMemberCount === 'number') { | |
| return { | |
| members: rootMemberCount, | |
| }; | |
| } | |
| // Fallback if there's no denormalized memberCount, also report to Sentry | |
| Raven.captureException( | |
| new Error(`Channel with ID "${id}" does not have denormalized memberCount.`) | |
| ); | |
| return { | |
| members: await loaders.channelMemberCount | |
| .load(id) | |
| .then(res => (res && res.reduction) || 0), | |
| }; | |
| }; | |