Skip to content

Commit e2b2aee

Browse files
authored
fix: clean up deleted spaces from ranking (#1058)
Previously deleted spaces were not properly handled in ranking, because rankedSpaces kept those deleted spaces and they were filtered away in SQL query meaning that we would receive less spaces than expected. To avoid this we now always clean up old spaces so deleted spaces get removed and in ranking we allow deleted spaces to show up, but this will only happen for around 120s after space was deleted and otherwise ranking will be still functional.
1 parent d44c600 commit e2b2aee

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/graphql/operations/ranking.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ export default async function (_parent, args, context, info) {
7777
if (!filteredSpaces.length) return { items: [], metrics };
7878

7979
const query = `
80-
SELECT s.* FROM spaces s WHERE s.deleted = 0
81-
AND s.id IN (?)
80+
SELECT s.* FROM spaces s WHERE s.id IN (?)
8281
GROUP BY s.id
8382
ORDER BY FIELD(s.id, ?) ASC
8483
`;

src/helpers/spaces.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export let rankedSpaces: Metadata[] = [];
2424

2525
export let networkSpaceCounts: Record<string, number> = {};
2626

27-
export const spacesMetadata: Record<string, Metadata> = {};
27+
export let spacesMetadata: Record<string, Metadata> = {};
2828

2929
type Metadata = {
3030
id: string;
@@ -102,6 +102,7 @@ function sortSpaces() {
102102
}
103103

104104
function mapSpaces(spaces: Record<string, any>) {
105+
spacesMetadata = {};
105106
networkSpaceCounts = {};
106107

107108
Object.entries(spaces).forEach(([id, space]: any) => {

0 commit comments

Comments
 (0)