Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static async findByPollId(id: string) {
return this.query(SQL`
SELECT *
FROM ${SQL.raw(this.tableName)}
WHERE poll_id = ${id}`)
}
}
{ status, type }: { status?: FilterStatus; type?: FilterType } = {
status: DEFAULT_STATUS,
type: DEFAULT_TYPE
}
) {
let statusQuery
let typeQuery
if (status === 'active') {
statusQuery = SQL`closes_at > extract(epoch from now()) * 1000`
} else if (status === 'expired') {
statusQuery = SQL`closes_at <= extract(epoch from now()) * 1000`
}
if (type === 'district') {
typeQuery = SQL`token_address LIKE '${SQL.raw(DISTRICT_TOKEN.address)}-%'`
} else if (type === 'decentraland') {
typeQuery = SQL`token_address LIKE '0x%'`
}
if (statusQuery && typeQuery) {
return SQL`WHERE ${statusQuery} AND ${typeQuery}`
} else if (statusQuery) {
return SQL`WHERE ${statusQuery}`
} else if (typeQuery) {
return SQL`WHERE ${typeQuery}`
} else {
return SQL``
}
},
findWithAssociations: (whereStatement: SQLStatement = SQL``): SQLStatement =>
static async updateBalances(): Promise {
await this.query(SQL`UPDATE ${SQL.raw(this.tableName)}
SET balance = COALESCE((${VoteQueries.sumAccountBalanceForPollSubquery()}), 0)`)
}