Skip to content

Commit cd30b97

Browse files
committed
Tidy
1 parent bc94e8d commit cd30b97

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

Backend.Tests/Mocks/WordRepositoryMock.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,12 @@ public Task<int> CountFrontierWordsWithDomain(string projectId, string domainId,
137137
var count = 0;
138138
foreach (var word in _frontier.Where(w => w.ProjectId == projectId))
139139
{
140-
foreach (var sense in word.Senses)
140+
if (word.Senses.Any(s => s.SemanticDomains.Any(sd => sd.Id == domainId)))
141141
{
142-
if (sense.SemanticDomains.Any(sd => sd.Id == domainId))
142+
count++;
143+
if (maxCount is not null && count >= maxCount)
143144
{
144-
count++;
145-
if (maxCount.HasValue && count >= maxCount.Value)
146-
{
147-
return Task.FromResult(maxCount.Value);
148-
}
145+
return Task.FromResult(maxCount.Value);
149146
}
150147
}
151148
}

Backend/Services/StatisticsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public async Task<double> GetDomainProgressProportion(string projectId, string d
398398
return 0.0;
399399
}
400400

401-
double count = 0.0;
401+
var count = 0.0;
402402
foreach (var dom in domainAndDescendants)
403403
{
404404
if (await _wordRepo.CountFrontierWordsWithDomain(projectId, dom.Id, 1) > 0)

src/backend/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,16 +689,16 @@ export async function getProgressEstimationLineChartRoot(
689689
return response.data ?? undefined;
690690
}
691691

692-
export async function getDomainWordCount(domainId: string): Promise<number> {
693-
const response = await statisticsApi.getDomainWordCount(
692+
export async function getDomainProgress(domainId: string): Promise<number> {
693+
const response = await statisticsApi.getDomainProgressProportion(
694694
{ projectId: LocalStorage.getProjectId(), domainId },
695695
defaultOptions()
696696
);
697697
return response.data;
698698
}
699699

700-
export async function getDomainProgress(domainId: string): Promise<number> {
701-
const response = await statisticsApi.getDomainProgressProportion(
700+
export async function getDomainWordCount(domainId: string): Promise<number> {
701+
const response = await statisticsApi.getDomainWordCount(
702702
{ projectId: LocalStorage.getProjectId(), domainId },
703703
defaultOptions()
704704
);

src/components/TreeView/TreeDepiction/CurrentRow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function CurrentRow(props: TreeRowProps): ReactElement {
3232

3333
function CurrentTile(props: TreeRowProps): ReactElement {
3434
const { animate, currentDomain } = props;
35+
3536
const [senseCount, setSenseCount] = useState<number | undefined>();
3637
const { t } = useTranslation();
3738

src/components/TreeView/TreeDepiction/DomainTileButton.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,15 @@ export default function DomainTileButton(
8484
props: DomainTileButtonProps
8585
): ReactElement {
8686
const { onClick, direction, ...domainTileProps } = props;
87-
const [progress, setProgress] = useState<number | undefined>();
87+
88+
const [progress, setProgress] = useState<number>(0);
8889
const theme = useTheme();
8990

9091
const shouldShowProgress = direction !== Direction.Up;
9192

9293
useEffect(() => {
9394
if (shouldShowProgress) {
94-
setProgress(undefined);
95+
setProgress(0);
9596
getDomainProgress(props.domain.id)
9697
.then(setProgress)
9798
.catch(() => {}); // Silently fail
@@ -123,11 +124,10 @@ export default function DomainTileButton(
123124
sx={{
124125
backgroundColor: theme.palette.primary.main,
125126
borderBottomLeftRadius: theme.shape.borderRadius,
126-
borderBottomRightRadius:
127-
progress === 1 ? theme.shape.borderRadius : 0,
127+
borderBottomRightRadius: progress * theme.shape.borderRadius,
128128
height: "100%",
129-
transition: "width 1s ease-in-out",
130-
width: `${(progress ?? 0) * 100}%`,
129+
transition: "width .75s ease-in-out",
130+
width: `${progress * 100}%`,
131131
}}
132132
/>
133133
</Box>

0 commit comments

Comments
 (0)