pub(crate) struct EventDB {}
Expand description
The Catalyst Event SQL Database
Implementations§
Source§impl EventDB
impl EventDB
Sourceconst BALLOTS_VOTE_OPTIONS_PER_EVENT_QUERY: &'static str = "SELECT vote_options.objective, proposal.id as proposal_id, objective.id as objective_id
FROM proposal
INNER JOIN objective ON proposal.objective = objective.row_id
INNER JOIN vote_options ON objective.vote_options = vote_options.id
WHERE objective.event = $1;"
const BALLOTS_VOTE_OPTIONS_PER_EVENT_QUERY: &'static str = "SELECT vote_options.objective, proposal.id as proposal_id, objective.id as objective_id FROM proposal INNER JOIN objective ON proposal.objective = objective.row_id INNER JOIN vote_options ON objective.vote_options = vote_options.id WHERE objective.event = $1;"
Ballot vote options per event query template
Sourceconst BALLOTS_VOTE_OPTIONS_PER_OBJECTIVE_QUERY: &'static str = "SELECT vote_options.objective, proposal.id as proposal_id
FROM proposal
INNER JOIN objective ON proposal.objective = objective.row_id
INNER JOIN vote_options ON objective.vote_options = vote_options.id
WHERE objective.event = $1 AND objective.id = $2;"
const BALLOTS_VOTE_OPTIONS_PER_OBJECTIVE_QUERY: &'static str = "SELECT vote_options.objective, proposal.id as proposal_id FROM proposal INNER JOIN objective ON proposal.objective = objective.row_id INNER JOIN vote_options ON objective.vote_options = vote_options.id WHERE objective.event = $1 AND objective.id = $2;"
Ballot vote options per objective query template
Sourceconst BALLOT_VOTE_OPTIONS_QUERY: &'static str = "SELECT vote_options.objective
FROM proposal
INNER JOIN objective ON proposal.objective = objective.row_id
INNER JOIN vote_options ON objective.vote_options = vote_options.id
WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3;"
const BALLOT_VOTE_OPTIONS_QUERY: &'static str = "SELECT vote_options.objective FROM proposal INNER JOIN objective ON proposal.objective = objective.row_id INNER JOIN vote_options ON objective.vote_options = vote_options.id WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3;"
Ballot vote options query template
Sourceconst BALLOT_VOTE_PLANS_QUERY: &'static str = "SELECT proposal_voteplan.bb_proposal_index,
voteplan.id, voteplan.category, voteplan.encryption_key, voteplan.group_id
FROM proposal_voteplan
INNER JOIN proposal ON proposal_voteplan.proposal_id = proposal.row_id
INNER JOIN voteplan ON proposal_voteplan.voteplan_id = voteplan.row_id
INNER JOIN objective ON proposal.objective = objective.row_id
WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3;"
const BALLOT_VOTE_PLANS_QUERY: &'static str = "SELECT proposal_voteplan.bb_proposal_index, voteplan.id, voteplan.category, voteplan.encryption_key, voteplan.group_id FROM proposal_voteplan INNER JOIN proposal ON proposal_voteplan.proposal_id = proposal.row_id INNER JOIN voteplan ON proposal_voteplan.voteplan_id = voteplan.row_id INNER JOIN objective ON proposal.objective = objective.row_id WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3;"
Ballot vote plans query template
Source§impl EventDB
impl EventDB
Sourcepub(crate) async fn get_ballot(
event: EventId,
objective: ObjectiveId,
proposal: ProposalId,
) -> Result<Ballot>
pub(crate) async fn get_ballot( event: EventId, objective: ObjectiveId, proposal: ProposalId, ) -> Result<Ballot>
Get ballot query
Sourcepub(crate) async fn get_objective_ballots(
&self,
event: EventId,
objective: ObjectiveId,
) -> Result<Vec<ProposalBallot>>
pub(crate) async fn get_objective_ballots( &self, event: EventId, objective: ObjectiveId, ) -> Result<Vec<ProposalBallot>>
Get objective’s ballots query
Sourcepub(crate) async fn get_event_ballots(
&self,
event: EventId,
) -> Result<Vec<ObjectiveBallots>>
pub(crate) async fn get_event_ballots( &self, event: EventId, ) -> Result<Vec<ObjectiveBallots>>
Get event’s ballots query
Source§impl EventDB
impl EventDB
Sourceconst OBJECTIVES_QUERY: &'static str = "SELECT objective.row_id, objective.id, objective.title, objective.description, objective.deleted, objective.rewards_currency, objective.rewards_total, objective.extra,
objective_category.name, objective_category.description as objective_category_description
FROM objective
INNER JOIN objective_category on objective.category = objective_category.name
WHERE objective.event = $1
LIMIT $2 OFFSET $3;"
const OBJECTIVES_QUERY: &'static str = "SELECT objective.row_id, objective.id, objective.title, objective.description, objective.deleted, objective.rewards_currency, objective.rewards_total, objective.extra, objective_category.name, objective_category.description as objective_category_description FROM objective INNER JOIN objective_category on objective.category = objective_category.name WHERE objective.event = $1 LIMIT $2 OFFSET $3;"
Objectives query template
Sourceconst VOTING_GROUPS_QUERY: &'static str = "SELECT voteplan.group_id as group, voteplan.token_id as voting_token
FROM voteplan
WHERE objective_id = $1;"
const VOTING_GROUPS_QUERY: &'static str = "SELECT voteplan.group_id as group, voteplan.token_id as voting_token FROM voteplan WHERE objective_id = $1;"
Voting Groups query template
Source§impl EventDB
impl EventDB
Sourceconst PROPOSALS_QUERY: &'static str = "SELECT proposal.id, proposal.title, proposal.summary, proposal.deleted
FROM proposal
INNER JOIN objective on proposal.objective = objective.row_id
WHERE objective.event = $1 AND objective.id = $2
LIMIT $3 OFFSET $4;"
const PROPOSALS_QUERY: &'static str = "SELECT proposal.id, proposal.title, proposal.summary, proposal.deleted FROM proposal INNER JOIN objective on proposal.objective = objective.row_id WHERE objective.event = $1 AND objective.id = $2 LIMIT $3 OFFSET $4;"
Proposals query template
Sourceconst PROPOSAL_QUERY: &'static str = "SELECT proposal.id, proposal.title, proposal.summary, proposal.deleted, proposal.extra,
proposal.funds, proposal.url, proposal.files_url,
proposal.proposer_name, proposal.proposer_contact, proposal.proposer_url, proposal.public_key
FROM proposal
INNER JOIN objective on proposal.objective = objective.row_id
WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3;"
const PROPOSAL_QUERY: &'static str = "SELECT proposal.id, proposal.title, proposal.summary, proposal.deleted, proposal.extra, proposal.funds, proposal.url, proposal.files_url, proposal.proposer_name, proposal.proposer_contact, proposal.proposer_url, proposal.public_key FROM proposal INNER JOIN objective on proposal.objective = objective.row_id WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3;"
Proposal details query template
Source§impl EventDB
impl EventDB
Sourcepub(crate) async fn get_proposal(
event: EventId,
objective: ObjectiveId,
proposal: ProposalId,
) -> Result<Proposal>
pub(crate) async fn get_proposal( event: EventId, objective: ObjectiveId, proposal: ProposalId, ) -> Result<Proposal>
Get proposal query
Sourcepub(crate) async fn get_proposals(
&self,
event: EventId,
objective: ObjectiveId,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Vec<ProposalSummary>>
pub(crate) async fn get_proposals( &self, event: EventId, objective: ObjectiveId, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<ProposalSummary>>
Get proposals query
Source§impl EventDB
impl EventDB
Sourceconst RATINGS_PER_REVIEW_QUERY: &'static str = "SELECT review_rating.metric, review_rating.rating, review_rating.note
FROM review_rating
WHERE review_rating.review_id = $1;"
const RATINGS_PER_REVIEW_QUERY: &'static str = "SELECT review_rating.metric, review_rating.rating, review_rating.note FROM review_rating WHERE review_rating.review_id = $1;"
Rating per review query template
Sourceconst REVIEWS_QUERY: &'static str = "SELECT proposal_review.row_id, proposal_review.assessor
FROM proposal_review
INNER JOIN proposal on proposal.row_id = proposal_review.proposal_id
INNER JOIN objective on proposal.objective = objective.row_id
WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3
LIMIT $4 OFFSET $5;"
const REVIEWS_QUERY: &'static str = "SELECT proposal_review.row_id, proposal_review.assessor FROM proposal_review INNER JOIN proposal on proposal.row_id = proposal_review.proposal_id INNER JOIN objective on proposal.objective = objective.row_id WHERE objective.event = $1 AND objective.id = $2 AND proposal.id = $3 LIMIT $4 OFFSET $5;"
Review query template
Sourceconst REVIEW_TYPES_QUERY: &'static str = "SELECT review_metric.row_id, review_metric.name, review_metric.description,
review_metric.min, review_metric.max, review_metric.map,
objective_review_metric.note, objective_review_metric.review_group
FROM review_metric
INNER JOIN objective_review_metric on review_metric.row_id = objective_review_metric.metric
INNER JOIN objective on objective_review_metric.objective = objective.row_id
WHERE objective.event = $1 AND objective.id = $2
LIMIT $3 OFFSET $4;"
const REVIEW_TYPES_QUERY: &'static str = "SELECT review_metric.row_id, review_metric.name, review_metric.description, review_metric.min, review_metric.max, review_metric.map, objective_review_metric.note, objective_review_metric.review_group FROM review_metric INNER JOIN objective_review_metric on review_metric.row_id = objective_review_metric.metric INNER JOIN objective on objective_review_metric.objective = objective.row_id WHERE objective.event = $1 AND objective.id = $2 LIMIT $3 OFFSET $4;"
Review types query template
Source§impl EventDB
impl EventDB
Sourcepub(crate) async fn get_reviews(
event: EventId,
objective: ObjectiveId,
proposal: ProposalId,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Vec<AdvisorReview>>
pub(crate) async fn get_reviews( event: EventId, objective: ObjectiveId, proposal: ProposalId, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<AdvisorReview>>
Get reviews query
Sourcepub(crate) async fn get_review_types(
&self,
event: EventId,
objective: ObjectiveId,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Vec<ReviewType>>
pub(crate) async fn get_review_types( &self, event: EventId, objective: ObjectiveId, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<ReviewType>>
Get review types query
Source§impl EventDB
impl EventDB
Sourceconst EVENTS_QUERY: &'static str = "SELECT event.row_id, event.name, event.start_time, event.end_time, snapshot.last_updated
FROM event
LEFT JOIN snapshot ON event.row_id = snapshot.event
ORDER BY event.row_id ASC
LIMIT $1 OFFSET $2;"
const EVENTS_QUERY: &'static str = "SELECT event.row_id, event.name, event.start_time, event.end_time, snapshot.last_updated FROM event LEFT JOIN snapshot ON event.row_id = snapshot.event ORDER BY event.row_id ASC LIMIT $1 OFFSET $2;"
Events query template
Sourceconst EVENT_GOALS_QUERY: &'static str = "SELECT goal.idx, goal.name
FROM goal
WHERE goal.event_id = $1;"
const EVENT_GOALS_QUERY: &'static str = "SELECT goal.idx, goal.name FROM goal WHERE goal.event_id = $1;"
Event goals query template
Sourceconst EVENT_QUERY: &'static str = "SELECT event.row_id, event.name, event.start_time, event.end_time,
event.snapshot_start, event.registration_snapshot_time,
event.voting_power_threshold, event.max_voting_power_pct,
event.insight_sharing_start, event.proposal_submission_start, event.refine_proposals_start, event.finalize_proposals_start, event.proposal_assessment_start, event.assessment_qa_start, event.voting_start, event.voting_end, event.tallying_end,
snapshot.last_updated
FROM event
LEFT JOIN snapshot ON event.row_id = snapshot.event
WHERE event.row_id = $1;"
const EVENT_QUERY: &'static str = "SELECT event.row_id, event.name, event.start_time, event.end_time, event.snapshot_start, event.registration_snapshot_time, event.voting_power_threshold, event.max_voting_power_pct, event.insight_sharing_start, event.proposal_submission_start, event.refine_proposals_start, event.finalize_proposals_start, event.proposal_assessment_start, event.assessment_qa_start, event.voting_start, event.voting_end, event.tallying_end, snapshot.last_updated FROM event LEFT JOIN snapshot ON event.row_id = snapshot.event WHERE event.row_id = $1;"
Event details query template
Source§impl EventDB
impl EventDB
Sourceconst DELEGATIONS_BY_EVENT_QUERY: &'static str = "SELECT contribution.voting_key, contribution.voting_group, contribution.voting_weight, contribution.value, contribution.reward_address
FROM contribution
INNER JOIN snapshot ON contribution.snapshot_id = snapshot.row_id
WHERE contribution.stake_public_key = $1 AND snapshot.event = $2;"
const DELEGATIONS_BY_EVENT_QUERY: &'static str = "SELECT contribution.voting_key, contribution.voting_group, contribution.voting_weight, contribution.value, contribution.reward_address FROM contribution INNER JOIN snapshot ON contribution.snapshot_id = snapshot.row_id WHERE contribution.stake_public_key = $1 AND snapshot.event = $2;"
Delegations by event query template
Sourceconst DELEGATOR_SNAPSHOT_INFO_BY_EVENT_QUERY: &'static str = "
SELECT snapshot.as_at, snapshot.last_updated, snapshot.final
FROM snapshot
WHERE snapshot.event = $1
LIMIT 1;"
const DELEGATOR_SNAPSHOT_INFO_BY_EVENT_QUERY: &'static str = " SELECT snapshot.as_at, snapshot.last_updated, snapshot.final FROM snapshot WHERE snapshot.event = $1 LIMIT 1;"
Delegator snapshot info by event query template
Sourceconst DELEGATOR_SNAPSHOT_INFO_BY_LAST_EVENT_QUERY: &'static str = "SELECT snapshot.event, snapshot.as_at, snapshot.last_updated, snapshot.final
FROM snapshot
WHERE snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot)
LIMIT 1;"
const DELEGATOR_SNAPSHOT_INFO_BY_LAST_EVENT_QUERY: &'static str = "SELECT snapshot.event, snapshot.as_at, snapshot.last_updated, snapshot.final FROM snapshot WHERE snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot) LIMIT 1;"
Delegator snapshot info by last event query template
Sourceconst TOTAL_BY_EVENT_VOTING_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power
FROM voter
INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id
WHERE voter.voting_group = $1 AND snapshot.event = $2;"
const TOTAL_BY_EVENT_VOTING_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power FROM voter INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id WHERE voter.voting_group = $1 AND snapshot.event = $2;"
Total By Event Query template
Sourceconst TOTAL_BY_LAST_EVENT_VOTING_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power
FROM voter
INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id AND snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot)
WHERE voter.voting_group = $1;"
const TOTAL_BY_LAST_EVENT_VOTING_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power FROM voter INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id AND snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot) WHERE voter.voting_group = $1;"
Total By Last Event Query template
Sourceconst TOTAL_POWER_BY_EVENT_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power
FROM voter
INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id
WHERE snapshot.event = $1;"
const TOTAL_POWER_BY_EVENT_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power FROM voter INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id WHERE snapshot.event = $1;"
Total voting power by event query template
Sourceconst TOTAL_POWER_BY_LAST_EVENT_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power
FROM voter
INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id
WHERE snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot);"
const TOTAL_POWER_BY_LAST_EVENT_QUERY: &'static str = "SELECT SUM(voter.voting_power)::BIGINT as total_voting_power FROM voter INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id WHERE snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot);"
Total voting power by last event query template
Sourceconst VOTER_BY_EVENT_QUERY: &'static str = "SELECT voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final, SUM(contribution.value)::BIGINT as delegations_power, COUNT(contribution.value) AS delegations_count
FROM voter
INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id
INNER JOIN contribution ON contribution.snapshot_id = snapshot.row_id
WHERE voter.voting_key = $1 AND contribution.voting_key = $1 AND snapshot.event = $2
GROUP BY voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final;"
const VOTER_BY_EVENT_QUERY: &'static str = "SELECT voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final, SUM(contribution.value)::BIGINT as delegations_power, COUNT(contribution.value) AS delegations_count FROM voter INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id INNER JOIN contribution ON contribution.snapshot_id = snapshot.row_id WHERE voter.voting_key = $1 AND contribution.voting_key = $1 AND snapshot.event = $2 GROUP BY voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final;"
Voter By Event Query template
Sourceconst VOTER_BY_LAST_EVENT_QUERY: &'static str = "SELECT snapshot.event, voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final, SUM(contribution.value)::BIGINT as delegations_power, COUNT(contribution.value) AS delegations_count
FROM voter
INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id
INNER JOIN contribution ON contribution.snapshot_id = snapshot.row_id
WHERE voter.voting_key = $1 AND contribution.voting_key = $1 AND snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot)
GROUP BY snapshot.event, voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final;"
const VOTER_BY_LAST_EVENT_QUERY: &'static str = "SELECT snapshot.event, voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final, SUM(contribution.value)::BIGINT as delegations_power, COUNT(contribution.value) AS delegations_count FROM voter INNER JOIN snapshot ON voter.snapshot_id = snapshot.row_id INNER JOIN contribution ON contribution.snapshot_id = snapshot.row_id WHERE voter.voting_key = $1 AND contribution.voting_key = $1 AND snapshot.last_updated = (SELECT MAX(snapshot.last_updated) as last_updated from snapshot) GROUP BY snapshot.event, voter.voting_key, voter.voting_group, voter.voting_power, snapshot.as_at, snapshot.last_updated, snapshot.final;"
Voter By Last Event Query template
Sourceconst VOTER_DELEGATORS_LIST_QUERY: &'static str = "SELECT contribution.stake_public_key
FROM contribution
INNER JOIN snapshot ON contribution.snapshot_id = snapshot.row_id
WHERE contribution.voting_key = $1 AND snapshot.event = $2;"
const VOTER_DELEGATORS_LIST_QUERY: &'static str = "SELECT contribution.stake_public_key FROM contribution INNER JOIN snapshot ON contribution.snapshot_id = snapshot.row_id WHERE contribution.voting_key = $1 AND snapshot.event = $2;"
Voter Delegators List Query template
Source§impl EventDB
impl EventDB
Sourceconst SEARCH_EVENTS_QUERY: &'static str = "SELECT event.row_id, event.name, event.start_time, event.end_time, snapshot.last_updated
FROM event
LEFT JOIN snapshot ON event.row_id = snapshot.event"
const SEARCH_EVENTS_QUERY: &'static str = "SELECT event.row_id, event.name, event.start_time, event.end_time, snapshot.last_updated FROM event LEFT JOIN snapshot ON event.row_id = snapshot.event"
Search for events query template
Sourceconst SEARCH_OBJECTIVES_QUERY: &'static str = "SELECT objective.id, objective.title, objective.description, objective.deleted, objective_category.name, objective_category.description as objective_category_description
FROM objective
INNER JOIN objective_category on objective.category = objective_category.name"
const SEARCH_OBJECTIVES_QUERY: &'static str = "SELECT objective.id, objective.title, objective.description, objective.deleted, objective_category.name, objective_category.description as objective_category_description FROM objective INNER JOIN objective_category on objective.category = objective_category.name"
Search for objectives query template
Sourceconst SEARCH_PROPOSALS_QUERY: &'static str = "SELECT DISTINCT proposal.id, proposal.title, proposal.summary, proposal.deleted
FROM proposal"
const SEARCH_PROPOSALS_QUERY: &'static str = "SELECT DISTINCT proposal.id, proposal.title, proposal.summary, proposal.deleted FROM proposal"
Search for proposals query template
Sourcefn build_where_clause(table: &str, filter: &[SearchConstraint]) -> String
fn build_where_clause(table: &str, filter: &[SearchConstraint]) -> String
Build a where clause
Sourcefn build_order_by_clause(table: &str, order_by: &[SearchOrderBy]) -> String
fn build_order_by_clause(table: &str, order_by: &[SearchOrderBy]) -> String
Build an order by clause
Sourcefn construct_query(search_query: &SearchQuery) -> String
fn construct_query(search_query: &SearchQuery) -> String
Construct a search query
Sourcefn construct_count_query(search_query: &SearchQuery) -> String
fn construct_count_query(search_query: &SearchQuery) -> String
Construct a count query
Sourceasync fn search_total(
search_query: SearchQuery,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<SearchResult>
async fn search_total( search_query: SearchQuery, limit: Option<i64>, offset: Option<i64>, ) -> Result<SearchResult>
Search for a total.
Sourceasync fn search_events(
search_query: SearchQuery,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<SearchResult>
async fn search_events( search_query: SearchQuery, limit: Option<i64>, offset: Option<i64>, ) -> Result<SearchResult>
Search for events
Sourceasync fn search_objectives(
&self,
search_query: SearchQuery,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<SearchResult>
async fn search_objectives( &self, search_query: SearchQuery, limit: Option<i64>, offset: Option<i64>, ) -> Result<SearchResult>
Search for objectives
Sourceasync fn search_proposals(
&self,
search_query: SearchQuery,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<SearchResult>
async fn search_proposals( &self, search_query: SearchQuery, limit: Option<i64>, offset: Option<i64>, ) -> Result<SearchResult>
Search for proposals
Source§impl EventDB
impl EventDB
Sourcepub(crate) async fn search(
&self,
search_query: SearchQuery,
total: bool,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<SearchResult>
pub(crate) async fn search( &self, search_query: SearchQuery, total: bool, limit: Option<i64>, offset: Option<i64>, ) -> Result<SearchResult>
Search query
Source§impl EventDB
impl EventDB
const FUND_CHALLENGES_QUERY: &'static str = "SELECT objective.row_id AS internal_id, objective.id AS id, objective.category AS challenge_type, objective.title AS title, objective.description AS description, objective.rewards_total AS rewards_total, objective.proposers_rewards AS proposers_rewards, (objective.extra->'url') #>> '{}' AS challenge_url, (objective.extra->'sponsor') #>> '{}' AS highlights FROM objective WHERE objective.event = $1;"
const FUND_GOALS_QUERY: &'static str = "SELECT id, name AS goal_name FROM goal WHERE goal.event_id = $1;"
const FUND_GROUPS_QUERY: &'static str = "SELECT voteplan.token_id AS token_identifier, voting_group.name AS group_id FROM voting_group INNER JOIN voteplan ON voteplan.group_id = voting_group.name INNER JOIN objective ON voteplan.objective_id = objective.row_id WHERE objective.event = $1;"
const FUND_QUERY: &'static str = "SELECT this_fund.row_id AS id, this_fund.name AS fund_name, this_fund.description AS fund_goal, this_fund.registration_snapshot_time AS registration_snapshot_time, this_fund.voting_power_threshold AS voting_power_threshold, this_fund.start_time AS fund_start_time, this_fund.end_time AS fund_end_time, this_fund.insight_sharing_start AS insight_sharing_start, this_fund.proposal_submission_start AS proposal_submission_start, this_fund.refine_proposals_start AS refine_proposals_start, this_fund.finalize_proposals_start AS finalize_proposals_start, this_fund.proposal_assessment_start AS proposal_assessment_start, this_fund.assessment_qa_start AS assessment_qa_start, this_fund.snapshot_start AS snapshot_start, this_fund.voting_start AS voting_start, this_fund.voting_end AS voting_end, this_fund.tallying_end AS tallying_end, (this_fund.extra->'url'->'results') #>> '{}' AS results_url, (this_fund.extra->'url'->'survey') #>> '{}' AS survey_url, next_fund.row_id AS next_id, next_fund.start_time AS next_fund_start_time, next_fund.registration_snapshot_time AS next_registration_snapshot_time, next_fund.name AS next_fund_name, next_fund.insight_sharing_start AS next_insight_sharing_start, next_fund.proposal_submission_start AS next_proposal_submission_start, next_fund.refine_proposals_start AS next_refine_proposals_start, next_fund.finalize_proposals_start AS next_finalize_proposals_start, next_fund.proposal_assessment_start AS next_proposal_assessment_start, next_fund.assessment_qa_start AS next_assessment_qa_start, next_fund.snapshot_start AS next_snapshot_start, next_fund.voting_start AS next_voting_start, next_fund.voting_end AS next_voting_end, next_fund.tallying_end AS next_tallying_end FROM event this_fund LEFT JOIN event next_fund ON next_fund.row_id = this_fund.row_id + 1 WHERE this_fund.end_time > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND this_fund.start_time < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' ORDER BY this_fund.row_id DESC LIMIT 1;"
const FUND_VOTE_PLANS_QUERY: &'static str = "SELECT voteplan.row_id AS id, voteplan.id AS chain_voteplan_id, voteplan.category AS chain_voteplan_payload, voteplan.encryption_key AS chain_vote_encryption_key, event.row_id AS fund_id, voteplan.token_id AS token_identifier FROM voteplan INNER JOIN objective ON voteplan.objective_id = objective.row_id INNER JOIN event ON objective.event = event.row_id WHERE event.row_id = $1;"
Source§impl EventDB
impl EventDB
Sourcepub(crate) async fn schema_version_check() -> Result<i32>
pub(crate) async fn schema_version_check() -> Result<i32>
Check the schema version. return the current schema version if its current. Otherwise return an error.
Source§impl EventDB
impl EventDB
Sourcepub(crate) fn is_deep_query_enabled() -> bool
pub(crate) fn is_deep_query_enabled() -> bool
Determine if deep query inspection is enabled.
Sourcepub(crate) fn modify_deep_query(enable: bool)
pub(crate) fn modify_deep_query(enable: bool)
Modify the deep query inspection setting.
§Arguments
enable
- Set theDeepQueryInspection
setting to this value.
Sourcepub(crate) async fn query_stream(
stmt: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<impl Stream<Item = Result<Row>>>
pub(crate) async fn query_stream( stmt: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<impl Stream<Item = Result<Row>>>
Query the database and return a async stream of rows.
If deep query inspection is enabled, this will log the query plan inside a rolled-back transaction, before running the query.
§Arguments
stmt
-&str
SQL statement.params
-&[&(dyn ToSql + Sync)]
SQL parameters.
§Returns
anyhow::Result<impl Stream<Item = anyhow::Result<Row>>>
Sourceasync fn explain_analyze_rollback(
stmt: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<()>
async fn explain_analyze_rollback( stmt: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<()>
Prepend EXPLAIN ANALYZE
to the query, and rollback the transaction.
Sourceasync fn explain_analyze_commit(
stmt: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<()>
async fn explain_analyze_commit( stmt: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<()>
Prepend EXPLAIN ANALYZE
to the query, and commit the transaction.
Sourceasync fn explain_analyze(
stmt: &str,
params: &[&(dyn ToSql + Sync)],
rollback: bool,
) -> Result<()>
async fn explain_analyze( stmt: &str, params: &[&(dyn ToSql + Sync)], rollback: bool, ) -> Result<()>
Prepend EXPLAIN ANALYZE
to the query.
Log the query plan inside a transaction that may be committed or rolled back.
§Arguments
stmt
-&str
SQL statement.params
-&[&(dyn ToSql + Sync)]
SQL parameters.rollback
-bool
whether to roll back the transaction or not.
Auto Trait Implementations§
impl Freeze for EventDB
impl RefUnwindSafe for EventDB
impl Send for EventDB
impl Sync for EventDB
impl Unpin for EventDB
impl UnwindSafe for EventDB
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.