Skip to content

Commit 5710c53

Browse files
authored
fix: infer turbo status from turbo expiration date (#539)
* fix: infer turbo status from turbo expiration date * fix: update schema.sql
1 parent 6face7c commit 5710c53

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/helpers/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export async function getSpace(id: string, includeDeleted = false, network = DEF
106106
};
107107
}
108108

109-
const query = `SELECT settings, domain, deleted, flagged, verified, turbo, hibernated FROM spaces WHERE id = ? AND deleted in (?) LIMIT 1`;
109+
const query = `SELECT settings, domain, deleted, flagged, verified, turbo, turbo_expiration, hibernated FROM spaces WHERE id = ? AND deleted in (?) LIMIT 1`;
110110
const spaces = await db.queryAsync(query, [id.toLowerCase(), includeDeleted ? [0, 1] : [0]]);
111111

112112
if (!spaces[0]) return false;
@@ -118,7 +118,7 @@ export async function getSpace(id: string, includeDeleted = false, network = DEF
118118
verified: spaces[0].verified === 1,
119119
flagged: spaces[0].flagged === 1,
120120
hibernated: spaces[0].hibernated === 1,
121-
turbo: spaces[0].turbo === 1
121+
turbo: spaces[0].turbo === 1 || spaces[0].turbo_expiration > Date.now() / 1e3
122122
};
123123
}
124124

test/schema.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CREATE TABLE spaces (
77
flagged INT NOT NULL DEFAULT '0',
88
hibernated INT NOT NULL DEFAULT '0',
99
turbo INT NOT NULL DEFAULT '0',
10+
turbo_expiration BIGINT NOT NULL DEFAULT '0',
1011
proposal_count INT NOT NULL DEFAULT '0',
1112
vote_count INT NOT NULL DEFAULT '0',
1213
follower_count INT NOT NULL DEFAULT '0',
@@ -20,6 +21,7 @@ CREATE TABLE spaces (
2021
INDEX flagged (flagged),
2122
INDEX hibernated (hibernated),
2223
INDEX turbo (turbo),
24+
INDEX turbo_expiration (turbo_expiration),
2325
INDEX proposal_count (proposal_count),
2426
INDEX vote_count (vote_count),
2527
INDEX follower_count (follower_count),

0 commit comments

Comments
 (0)