-
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.
feat(hub-common): introduces types and function modifications for dis…
…cussion post search (#1425)
- Loading branch information
1 parent
57b993f
commit b0080ff
Showing
15 changed files
with
343 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
42 changes: 41 additions & 1 deletion
42
packages/common/src/search/_internal/hubSearchItemsHelpers/formatOgcItemsResponse.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
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
34 changes: 34 additions & 0 deletions
34
packages/common/src/search/_internal/hubSearchItemsHelpers/ogcItemToDiscussionPostResult.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,34 @@ | ||
import { IOgcItem } from "./interfaces"; | ||
import { IPost } from "../../../discussions"; | ||
import { IHubSearchResult } from "../../types"; | ||
|
||
/** | ||
* This method is responsible for converting an OGC item whose properties | ||
* represent an IPost into an IHubSearchResult. Although some fields do not | ||
* apply, this is being done such that result of a discussion post search | ||
* can automatically be used in a gallery. | ||
* @param ogcItem | ||
* @returns IHubSearchResult | ||
*/ | ||
export async function ogcItemToDiscussionPostResult( | ||
ogcItem: IOgcItem | ||
): Promise<IHubSearchResult> { | ||
return { | ||
id: ogcItem.id, | ||
name: ogcItem.properties.title, | ||
summary: ogcItem.properties.body, | ||
createdDate: new Date(ogcItem.properties.createdAt), | ||
createdDateSource: "properties.createdAt", | ||
updatedDate: new Date(ogcItem.properties.updatedAt), | ||
updatedDateSource: "properties.updatedAt", | ||
type: ogcItem.properties.postType, | ||
owner: ogcItem.properties.creator, | ||
location: ogcItem.properties.geometry, | ||
created: new Date(ogcItem.properties.createdAt), | ||
modified: new Date(ogcItem.properties.updatedAt), | ||
title: ogcItem.properties.title, | ||
rawResult: ogcItem.properties, | ||
access: null, | ||
family: null, | ||
} as IHubSearchResult; | ||
} |
6 changes: 1 addition & 5 deletions
6
packages/common/src/search/_internal/hubSearchItemsHelpers/ogcItemToSearchResult.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
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
Oops, something went wrong.