-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/gap-search-api: Added controller function for gap search API
- Loading branch information
Showing
5 changed files
with
119 additions
and
1 deletion.
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
56 changes: 56 additions & 0 deletions
56
backend/src/governance/api/response/gov-action-proposal.response.ts
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,56 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Expose } from 'class-transformer'; | ||
import { VoteStatus } from 'src/governance/enums/vote-status.enum'; | ||
|
||
export class GovernanceActionProposalResponse { | ||
@ApiProperty({ | ||
description: 'Unique governance proposal ID', | ||
example: '1', | ||
}) | ||
@Expose({ name: 'id' }) | ||
id: number; | ||
|
||
@ApiProperty({ | ||
description: 'Governance action proposal TX hash,', | ||
example: | ||
'28a5c50e900fbc155a98d78d2081e49ca4d6f004f2604e758a64357119db1b05#0', | ||
}) | ||
@Expose({ name: 'tx_hash' }) | ||
txHash: string; | ||
|
||
@ApiProperty({ | ||
description: 'Title of a governance action proposal', | ||
example: 'Random title', | ||
}) | ||
@Expose({ name: 'title' }) | ||
title: string; | ||
|
||
@ApiProperty({ | ||
description: 'Category of a governance action proposal', | ||
example: 'InfoAction', | ||
}) | ||
@Expose({ name: 'category' }) | ||
category: string; | ||
|
||
@ApiProperty({ | ||
description: 'Abstract of a governance action proposal', | ||
example: | ||
'This is a random abstract of a governance action proposal abstract. No longer than 2500 chars', | ||
}) | ||
@Expose({ name: 'abstract' }) | ||
abstract: string; | ||
|
||
@ApiProperty({ | ||
description: 'Metadata URL of a governance action proposal', | ||
example: 'https://some.random.url', | ||
}) | ||
@Expose({ name: 'metadata_url' }) | ||
metadataUrl: string; | ||
|
||
@ApiProperty({ | ||
description: 'Vote Status for a Given Governance Action Proposal for a particular user.', | ||
example: 'Pending', | ||
}) | ||
@Expose({ name: 'vote_status' }) | ||
voteStatus: VoteStatus; | ||
} |
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,14 @@ | ||
export enum VoteStatus { | ||
/** | ||
* Unvoted - There are neither votes nor reasoning for the associated GAP | ||
*/ | ||
Unvoted = 'Unvoted', | ||
/** | ||
* Pending - There is no vote but there is a reasoning for the associated GAP | ||
*/ | ||
Pending = 'Pending', | ||
/** | ||
* Voted - There are both votes and a reasoning for the associated GAP | ||
*/ | ||
Voted = 'Voted', | ||
} |
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
14 changes: 14 additions & 0 deletions
14
backend/src/governance/util/pagination/gap-pagination.config.ts
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,14 @@ | ||
import { FilterOperator, PaginateConfig } from 'nestjs-paginate'; | ||
import { Vote } from 'src/governance/entities/vote.entity'; | ||
|
||
export const GAP_PAGINATION_CONFIG: PaginateConfig<Vote> = { | ||
relations: ['govActionProposal'], | ||
sortableColumns: ['submitTime', 'govActionProposal.title'], | ||
filterableColumns: { | ||
govActionType: [FilterOperator.EQ, FilterOperator.IN], | ||
vote: [FilterOperator.EQ, FilterOperator.IN], | ||
userId: [FilterOperator.EQ], | ||
}, | ||
searchableColumns: ['govActionProposal.title'], | ||
defaultSortBy: [['submitTime', 'DESC']], | ||
}; |