Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
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();
};