Download spectrum/api/models/utils.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 918 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/utils.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/utils.js
-
curl -L -o utils.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/utils.js
918 Bytes
| // @flow | |
| import { db } from 'shared/db'; | |
| export type Timeframe = 'daily' | 'weekly' | 'monthly' | 'quarterly'; | |
| export const parseRange = (timeframe?: Timeframe) => { | |
| switch (timeframe) { | |
| case 'daily': { | |
| return { current: 60 * 60 * 24, previous: 60 * 60 * 24 * 2 }; | |
| } | |
| case 'weekly': { | |
| return { current: 60 * 60 * 24 * 7, previous: 60 * 60 * 24 * 14 }; | |
| } | |
| case 'monthly': { | |
| return { current: 60 * 60 * 24 * 30, previous: 60 * 60 * 24 * 60 }; | |
| } | |
| case 'quarterly': { | |
| return { current: 60 * 60 * 24 * 90, previous: 60 * 60 * 24 * 180 }; | |
| } | |
| default: { | |
| return { current: 60 * 60 * 24 * 7, previous: 60 * 60 * 24 * 14 }; | |
| } | |
| } | |
| }; | |
| export const getCount = (table: string, filter: mixed) => { | |
| if (filter) { | |
| return db | |
| .table(table) | |
| .filter(filter) | |
| .count() | |
| .run(); | |
| } | |
| return db | |
| .table(table) | |
| .count() | |
| .run(); | |
| }; | |