-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from poap-xyz/feat/search-drops
Search drops
- Loading branch information
Showing
16 changed files
with
272 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Search Drops | ||
|
||
There are two ways that drops can be searched, by exact word in name or fuzzy | ||
search in name and description. | ||
|
||
## Exact word search | ||
|
||
When searching for a whole word, use `fetch` method: | ||
|
||
```typescript | ||
const data: PaginatedResult<Drop> = await dropsClient.fetch({ | ||
sortField: DropsSortFields.Name, | ||
sortDir: Order.ASC, | ||
limit: 3, | ||
offset: 0, | ||
name: 'POAP', | ||
}); | ||
``` | ||
|
||
## Fuzzy search | ||
|
||
When given a generic search input, and to match any part of the words used in | ||
the name of the description, use `search` method: | ||
|
||
```typescript | ||
const data: PaginatedResult<Drop> = await dropsClient.search({ | ||
limit: 3, | ||
offset: 0, | ||
search: 'POAP', | ||
}); | ||
``` |
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,3 @@ | ||
{ | ||
"SearchDrops": "Search Drops" | ||
} |
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,60 @@ | ||
import { DropResponse } from '../types/DropResponse'; | ||
|
||
export const SEARCH_DROPS_QUERY = ` | ||
query SearchDrops( | ||
$limit: Int! | ||
$offset: Int! | ||
$args: search_drops_args! | ||
$orderBy: [drops_order_by!] | ||
) { | ||
search_drops( | ||
limit: $limit | ||
offset: $offset | ||
args: $args | ||
order_by: $orderBy | ||
) { | ||
id | ||
fancy_id | ||
name | ||
description | ||
city | ||
country | ||
channel | ||
platform | ||
location_type | ||
drop_url | ||
image_url | ||
animation_url | ||
year | ||
start_date | ||
timezone | ||
private | ||
created_date | ||
expiry_date | ||
end_date | ||
stats_by_chain_aggregate { | ||
aggregate { | ||
sum { | ||
transfer_count | ||
poap_count | ||
} | ||
} | ||
} | ||
email_claims_stats { | ||
total | ||
} | ||
drop_image { | ||
gateways { | ||
type | ||
url | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export interface SearchDropsResponse { | ||
data: { | ||
search_drops: DropResponse[]; | ||
}; | ||
} |
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,10 @@ | ||
import { DropImageGatewayType } from './dropImage'; | ||
|
||
interface DropImageGatewayResponse { | ||
type: DropImageGatewayType; | ||
url: string; | ||
} | ||
|
||
export interface DropImageResponse { | ||
gateways: Array<DropImageGatewayResponse>; | ||
} |
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,35 @@ | ||
import { DropImageResponse } from './DropImageResponse'; | ||
|
||
export interface DropResponse { | ||
id: number; | ||
fancy_id: string; | ||
name: string; | ||
description: string; | ||
city: string; | ||
country: string; | ||
channel: string; | ||
platform: string; | ||
location_type: string; | ||
drop_url: string; | ||
image_url: string; | ||
animation_url: string; | ||
year: number; | ||
start_date: string; | ||
timezone: string; | ||
private: boolean; | ||
created_date: string; | ||
expiry_date: string; | ||
end_date: string; | ||
stats_by_chain_aggregate: { | ||
aggregate: { | ||
sum: { | ||
transfer_count: number; | ||
poap_count: number; | ||
}; | ||
}; | ||
}; | ||
email_claims_stats: { | ||
total: number; | ||
}; | ||
drop_image?: DropImageResponse; | ||
} |
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,5 @@ | ||
import { PaginationInput } from '@poap-xyz/utils'; | ||
|
||
export interface SearchDropsInput extends PaginationInput { | ||
search: string; | ||
} |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
export * from './input'; | ||
export * from './DropImageResponse'; | ||
export * from './DropResponse'; | ||
export * from './SearchDropsInput'; |
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 @@ | ||
export * from './removeSpecialCharacters'; |
Oops, something went wrong.