Skip to content

Commit

Permalink
[expo] remove topological sort
Browse files Browse the repository at this point in the history
**Summary**

We found multiple bugs in topological sort and it exposes the risk to create garbage data in the database.

We decided to remove the feature and revisit it later.

**Test**

- yarn test

**Issue**

- #140
  • Loading branch information
yssk22 committed Dec 22, 2024
1 parent 4f46ab8 commit 0c114e9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 495 deletions.
14 changes: 5 additions & 9 deletions expo/features/hpsort/HPSortNewScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { WithSafeArea } from '@hpapp/features/common';
import { defineScreen, useScreenTitle } from '@hpapp/features/common/stack';
import { t } from '@hpapp/system/i18n';
import { useState } from 'react';

import HPSortNewConfigForm from './internals/new/HPSortNewConfigForm';
import HPSortNewRoundContainer from './internals/new/HPSortNewRoundContainer';
import { HPSortNewConfig } from './internals/new/types';

export type HPSortNewSceenProps = object;

export default defineScreen('/hpsort/new/', function HPSortNewSceen() {
useScreenTitle(t('New Sort'));
const [config, setConfig] = useState<HPSortNewConfig | null>(null);

return (
<WithSafeArea>
{config === null ? (
<HPSortNewConfigForm onSelect={(config) => setConfig(config)} />
) : (
<HPSortNewRoundContainer config={config} />
)}
<HPSortNewRoundContainer
config={{
numMembersToSelect: 2
}}
/>
</WithSafeArea>
);
});
78 changes: 0 additions & 78 deletions expo/features/hpsort/internals/new/HPSortNewConfigForm.tsx

This file was deleted.

13 changes: 2 additions & 11 deletions expo/features/hpsort/internals/new/HPSortNewRoundContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import HPSortNewRoundMemberSelector from './HPSortNewRoundMemberSelector';
import { HPSortMemberNode, HPSortNewConfig, HPSortNewRoundState } from './types';
import HPSortBase from '../sort/HPSortBase';
import HPSortClassicMergeSort from '../sort/HPSortClassicMergeSort';
import HPSortTopologicalSort from '../sort/HPSortTopologicalSort';

export type HPSortNewRoundContainerProps = {
config: HPSortNewConfig;
Expand All @@ -30,11 +29,7 @@ export default function HPSortNewRoundContainer({ config }: HPSortNewRoundContai
});
return object.shuffle([...members]).map((m) => new HPSortMemberNode(m));
}, [members]);
const [sorter, setSorter] = useState<HPSortBase<HPSortMemberNode>>(
config.numMembersToSelect === 2
? new HPSortClassicMergeSort(list)
: new HPSortTopologicalSort(list, config.numMembersToSelect, true)
);
const [sorter, setSorter] = useState<HPSortBase<HPSortMemberNode>>(new HPSortClassicMergeSort(list));
const comparable = sorter.getComparable();
const [stats, setStats] = useState<HPSortNewRoundState>({
numCompared: 0,
Expand All @@ -50,11 +45,7 @@ export default function HPSortNewRoundContainer({ config }: HPSortNewRoundContai
logEvent('hpsort_retry', {
num_members_to_select: config.numMembersToSelect
});
setSorter(
config.numMembersToSelect === 2
? new HPSortClassicMergeSort(list)
: new HPSortTopologicalSort(list, config.numMembersToSelect)
);
setSorter(new HPSortClassicMergeSort(list));
setStats({
numCompared: 0,
startTime: new Date(),
Expand Down
124 changes: 0 additions & 124 deletions expo/features/hpsort/internals/sort/HPSortTopologicalSort.test.ts

This file was deleted.

Loading

0 comments on commit 0c114e9

Please sign in to comment.