Skip to content

Commit

Permalink
Merge branch 'main' into kalvis/mantine-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
magicznyleszek authored Dec 18, 2024
2 parents 2df7caa + fefb4bb commit 717f080
Show file tree
Hide file tree
Showing 36 changed files with 479 additions and 324 deletions.
3 changes: 3 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const decorators = [
];

export const parameters = {
options: {
storySort: (a, b) => a.title === b.title ? 0 : a.title.localeCompare(b.title, undefined, {numeric: true}),
},
actions: {argTypesRegex: '^on[A-Z].*'},
controls: {
matchers: {
Expand Down
18 changes: 4 additions & 14 deletions dependencies/pip/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ amqp==5.2.0
asgiref==3.8.1
# via
# django
# django-allauth
# django-cors-headers
asttokens==2.4.1
# via stack-data
Expand Down Expand Up @@ -109,7 +110,6 @@ cryptography==42.0.5
# azure-storage-blob
# jwcrypto
# paramiko
# pyjwt
# pyopenssl
cssselect==1.2.0
# via pyquery
Expand All @@ -131,7 +131,6 @@ defusedxml==0.7.1
# via
# -r dependencies/pip/requirements.in
# djangorestframework-xml
# python3-openid
# pyxform
deprecated==1.2.14
# via fabric
Expand Down Expand Up @@ -171,7 +170,7 @@ django==4.2.15
# djangorestframework
# jsonfield
# model-bakery
django-allauth==0.61.1
django-allauth==65.1.0
# via -r dependencies/pip/requirements.in
django-amazon-ses==4.0.1
# via -r dependencies/pip/requirements.in
Expand Down Expand Up @@ -413,7 +412,6 @@ oauthlib==3.2.2
# via
# -r dependencies/pip/requirements.in
# django-oauth-toolkit
# requests-oauthlib
openpyxl==3.1.3
# via
# -r dependencies/pip/requirements.in
Expand Down Expand Up @@ -488,10 +486,8 @@ pygments==2.17.2
# via
# -r dependencies/pip/requirements.in
# ipython
pyjwt[crypto]==2.8.0
# via
# django-allauth
# twilio
pyjwt==2.8.0
# via twilio
pymongo==4.6.3
# via -r dependencies/pip/requirements.in
pynacl==1.5.0
Expand Down Expand Up @@ -531,8 +527,6 @@ python-dateutil==2.9.0.post0
# freezegun
# pandas
# python-crontab
python3-openid==3.2.0
# via django-allauth
pytz==2024.1
# via
# flower
Expand All @@ -559,19 +553,15 @@ requests==2.31.0
# -r dependencies/pip/requirements.in
# azure-core
# coveralls
# django-allauth
# django-oauth-toolkit
# google-api-core
# google-cloud-storage
# httmock
# requests-oauthlib
# responses
# smsapi-client
# stripe
# twilio
# yubico-client
requests-oauthlib==2.0.0
# via django-allauth
responses==0.25.0
# via -r dependencies/pip/requirements.in
rpds-py==0.18.0
Expand Down
18 changes: 4 additions & 14 deletions dependencies/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ amqp==5.2.0
asgiref==3.8.1
# via
# django
# django-allauth
# django-cors-headers
async-timeout==4.0.3
# via
Expand Down Expand Up @@ -92,7 +93,6 @@ cryptography==42.0.5
# via
# azure-storage-blob
# jwcrypto
# pyjwt
# pyopenssl
cssselect==1.2.0
# via pyquery
Expand All @@ -102,7 +102,6 @@ defusedxml==0.7.1
# via
# -r dependencies/pip/requirements.in
# djangorestframework-xml
# python3-openid
# pyxform
dict2xml==1.7.5
# via -r dependencies/pip/requirements.in
Expand Down Expand Up @@ -139,7 +138,7 @@ django==4.2.15
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth==0.61.1
django-allauth==65.1.0
# via -r dependencies/pip/requirements.in
django-amazon-ses==4.0.1
# via -r dependencies/pip/requirements.in
Expand Down Expand Up @@ -335,7 +334,6 @@ oauthlib==3.2.2
# via
# -r dependencies/pip/requirements.in
# django-oauth-toolkit
# requests-oauthlib
openpyxl==3.1.3
# via
# -r dependencies/pip/requirements.in
Expand Down Expand Up @@ -381,10 +379,8 @@ pycparser==2.22
# via cffi
pygments==2.17.2
# via -r dependencies/pip/requirements.in
pyjwt[crypto]==2.8.0
# via
# django-allauth
# twilio
pyjwt==2.8.0
# via twilio
pymongo==4.6.3
# via -r dependencies/pip/requirements.in
pyopenssl==24.1.0
Expand All @@ -406,8 +402,6 @@ python-dateutil==2.9.0.post0
# celery
# pandas
# python-crontab
python3-openid==3.2.0
# via django-allauth
pytz==2024.1
# via
# flower
Expand All @@ -433,18 +427,14 @@ requests==2.31.0
# via
# -r dependencies/pip/requirements.in
# azure-core
# django-allauth
# django-oauth-toolkit
# google-api-core
# google-cloud-storage
# requests-oauthlib
# responses
# smsapi-client
# stripe
# twilio
# yubico-client
requests-oauthlib==2.0.0
# via django-allauth
responses==0.25.0
# via -r dependencies/pip/requirements.in
rpds-py==0.18.0
Expand Down
24 changes: 7 additions & 17 deletions jsapp/js/account/usage/usage.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ export interface AssetWithUsage {
asset: string;
uid: string;
asset__name: string;
nlp_usage_current_month: {
total_nlp_asr_seconds: number;
total_nlp_mt_characters: number;
};
nlp_usage_current_year: {
nlp_usage_current_period: {
total_nlp_asr_seconds: number;
total_nlp_mt_characters: number;
};
Expand All @@ -27,28 +23,22 @@ export interface AssetWithUsage {
total_nlp_mt_characters: number;
};
storage_bytes: number;
submission_count_current_month: number;
submission_count_current_year: number;
submission_count_current_period: number;
submission_count_all_time: number;
deployment_status: string;
}

export interface UsageResponse {
current_month_start: string;
current_month_end: string;
current_year_start: string;
current_year_end: string;
current_period_start: string;
current_period_end: string;
total_submission_count: {
current_month: number;
current_year: number;
current_period: number;
all_time: number;
};
total_storage_bytes: number;
total_nlp_usage: {
asr_seconds_current_month: number;
mt_characters_current_month: number;
asr_seconds_current_year: number;
mt_characters_current_year: number;
asr_seconds_current_period: number;
mt_characters_current_period: number;
asr_seconds_all_time: number;
mt_characters_all_time: number;
};
Expand Down
22 changes: 4 additions & 18 deletions jsapp/js/account/usage/usage.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import useWhenStripeIsEnabled from 'js/hooks/useWhenStripeIsEnabled.hook';
import {ProductsContext} from '../useProducts.hook';
import {UsageContext} from 'js/account/usage/useUsage.hook';
import {OneTimeAddOnsContext} from '../useOneTimeAddonList.hook';
import moment from 'moment';
import {YourPlan} from 'js/account/usage/yourPlan.component';
import cx from 'classnames';
import LimitNotifications from 'js/components/usageLimits/limitNotifications.component';
Expand Down Expand Up @@ -55,27 +54,14 @@ export default function Usage() {
const location = useLocation();

const dateRange = useMemo(() => {
let startDate: string;
const endDate = usage.billingPeriodEnd
? formatDate(usage.billingPeriodEnd)
: formatDate(
moment(usage.currentMonthStart).add(1, 'month').toISOString()
);
switch (usage.trackingPeriod) {
case 'year':
startDate = formatDate(usage.currentYearStart);
break;
default:
startDate = formatDate(usage.currentMonthStart);
break;
}
const startDate = formatDate(usage.currentPeriodStart);
const endDate = formatDate(usage.currentPeriodEnd);
return t('##start_date## to ##end_date##')
.replace('##start_date##', startDate)
.replace('##end_date##', endDate);
}, [
usage.currentYearStart,
usage.currentMonthStart,
usage.billingPeriodEnd,
usage.currentPeriodStart,
usage.currentPeriodEnd,
usage.trackingPeriod,
]);

Expand Down
10 changes: 3 additions & 7 deletions jsapp/js/account/usage/usageProjectBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,14 @@ const ProjectBreakdown = () => {

const renderProjectRow = (project: AssetWithUsage) => {
const periodSubmissions =
project[
`submission_count_current_${usage.trackingPeriod}`
].toLocaleString();
project.submission_count_current_period.toLocaleString();

const periodASRSeconds = convertSecondsToMinutes(
project[`nlp_usage_current_${usage.trackingPeriod}`].total_nlp_asr_seconds
project.nlp_usage_current_period.total_nlp_asr_seconds
).toLocaleString();

const periodMTCharacters =
project[
`nlp_usage_current_${usage.trackingPeriod}`
].total_nlp_mt_characters.toLocaleString();
project.nlp_usage_current_period.total_nlp_mt_characters.toLocaleString();

return (
<tr key={project.asset}>
Expand Down
21 changes: 9 additions & 12 deletions jsapp/js/account/usage/useUsage.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ export interface UsageState {
submissions: number;
transcriptionMinutes: number;
translationChars: number;
currentMonthStart: string;
currentYearStart: string;
billingPeriodEnd: string | null;
currentPeriodStart: string;
currentPeriodEnd: string;
trackingPeriod: RecurringInterval;
lastUpdated?: String | null;
}
Expand All @@ -22,9 +21,8 @@ const INITIAL_USAGE_STATE: UsageState = Object.freeze({
submissions: 0,
transcriptionMinutes: 0,
translationChars: 0,
currentMonthStart: '',
currentYearStart: '',
billingPeriodEnd: null,
currentPeriodStart: '',
currentPeriodEnd: '',
trackingPeriod: 'month',
lastUpdated: '',
});
Expand All @@ -49,15 +47,14 @@ const loadUsage = async (
}
return {
storage: usage.total_storage_bytes,
submissions: usage.total_submission_count[`current_${trackingPeriod}`],
submissions: usage.total_submission_count.current_period,
transcriptionMinutes: convertSecondsToMinutes(
usage.total_nlp_usage[`asr_seconds_current_${trackingPeriod}`]
usage.total_nlp_usage.asr_seconds_current_period
),
translationChars:
usage.total_nlp_usage[`mt_characters_current_${trackingPeriod}`],
currentMonthStart: usage.current_month_start,
currentYearStart: usage.current_year_start,
billingPeriodEnd: usage[`current_${trackingPeriod}_end`],
usage.total_nlp_usage.mt_characters_current_period,
currentPeriodStart: usage.current_period_start,
currentPeriodEnd: usage.current_period_end,
trackingPeriod,
lastUpdated,
};
Expand Down
Loading

0 comments on commit 717f080

Please sign in to comment.