-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* apply contest limits * add contest check on thread creation + return contests with topics * fix config * fix topics contest data + filter to content * fix query * update schema * fix typing * fix types * fix test * Contest - rate limiting UI (#8505) * 8474 affordance for admin * disable creating topic * disable creating topic if user has dust eth value * revert value --------- Co-authored-by: Ryan Bennett <ryan@common.xyz> * move ETH check to command + fix UI limit check * fix topics refresh on thread create page * lint --------- Co-authored-by: Marcin Maslanka <maslankam92@gmail.com>
- Loading branch information
1 parent
f9ad90e
commit c6eaddc
Showing
22 changed files
with
470 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Query } from '@hicommonwealth/core'; | ||
import * as schemas from '@hicommonwealth/schemas'; | ||
import { QueryTypes } from 'sequelize'; | ||
import z from 'zod'; | ||
import { models } from '../database'; | ||
|
||
// GetActiveContestManagers returns all contest managers which are active | ||
// in the specified community and topic, along with the actions within | ||
// each manager's most recent contest | ||
export function GetActiveContestManagers(): Query< | ||
typeof schemas.GetActiveContestManagers | ||
> { | ||
return { | ||
...schemas.GetActiveContestManagers, | ||
auth: [], | ||
body: async ({ payload }) => { | ||
const results = await models.sequelize.query<{ | ||
eth_chain_id: number; | ||
url: string; | ||
contest_address: string; | ||
max_contest_id: number; | ||
actions: Array<z.infer<typeof schemas.ContestAction>>; | ||
}>( | ||
` | ||
SELECT | ||
cn.eth_chain_id, | ||
COALESCE(cn.private_url, cn.url) as url, | ||
cm.contest_address, | ||
co.max_contest_id, | ||
COALESCE(JSON_AGG(ca) FILTER (WHERE ca IS NOT NULL), '[]'::json) as actions | ||
FROM "Communities" c | ||
JOIN "ChainNodes" cn ON c.chain_node_id = cn.id | ||
JOIN "ContestManagers" cm ON cm.community_id = c.id | ||
JOIN "ContestTopics" ct ON cm.contest_address = ct.contest_address | ||
JOIN ( | ||
SELECT contest_address, | ||
MAX(contest_id) AS max_contest_id, | ||
MAX(start_time) as start_time, | ||
MAX(end_time) as end_time | ||
FROM "Contests" | ||
GROUP BY contest_address | ||
) co ON cm.contest_address = co.contest_address | ||
LEFT JOIN "ContestActions" ca on ( | ||
ca.contest_address = cm.contest_address AND | ||
ca.created_at > co.start_time AND | ||
ca.created_at < co.end_time | ||
) | ||
WHERE ct.topic_id = :topic_id | ||
AND cm.community_id = :community_id | ||
AND cm.cancelled = false | ||
AND ( | ||
cm.interval = 0 AND NOW() < co.end_time | ||
OR | ||
cm.interval > 0 | ||
) | ||
GROUP BY cn.eth_chain_id, cn.private_url, cn.url, cm.contest_address, co.max_contest_id | ||
`, | ||
{ | ||
type: QueryTypes.SELECT, | ||
replacements: { | ||
topic_id: payload.topic_id!, | ||
community_id: payload.community_id, | ||
}, | ||
}, | ||
); | ||
|
||
return results; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
.../client/scripts/views/components/NewThreadForm/ContestTopicBanner/ContestTopicBanner.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@import '../../../../../styles/shared'; | ||
|
||
.ContestTopicBanner { | ||
.body { | ||
ul { | ||
list-style: initial; | ||
margin-left: 32px; | ||
line-height: 32px; | ||
margin-bottom: 8px; | ||
|
||
li { | ||
.Text.disabled { | ||
color: $neutral-400; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.