Skip to content

Commit 2093ee0

Browse files
authored
Merge pull request #39 from unisoncomputing/cp/search-user-id
Add UserID to search results
2 parents cc99032 + e3890f0 commit 2093ee0

21 files changed

+112
-71
lines changed

src/Share/Web/Share/Impl.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import Share.Utils.API
3535
import Share.Utils.Caching
3636
import Share.Utils.Logging qualified as Logging
3737
import Share.Utils.Servant.Cookies qualified as Cookies
38+
import Share.Utils.URI (URIParam (..))
3839
import Share.Web.App
3940
import Share.Web.Authentication qualified as AuthN
4041
import Share.Web.Authorization qualified as AuthZ
@@ -363,8 +364,8 @@ searchEndpoint (MaybeAuthedUserID callerUserId) (Query query) (fromMaybe (Limit
363364
pure (users, projects)
364365
let userResults =
365366
users
366-
<&> \User {user_name, avatar_url, handle} ->
367-
SearchResultUser handle user_name avatar_url
367+
<&> \User {user_name = name, avatar_url = avatarUrl, handle, user_id = userId} ->
368+
SearchResultUser (UserDisplayInfo {handle, name, avatarUrl = unpackURI <$> avatarUrl, userId})
368369
let projectResults =
369370
projects
370371
<&> \(Project {slug, summary, visibility}, ownerHandle) ->

src/Share/Web/Share/Types.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ instance ToJSON DocResponse where
8989
]
9090

9191
data SearchResult
92-
= -- | handle displayName avatarUrl
93-
SearchResultUser UserHandle (Maybe Text) (Maybe URIParam)
92+
= SearchResultUser UserDisplayInfo
9493
| -- | shorthand summary visibility
9594
SearchResultProject ProjectShortHand (Maybe Text) ProjectVisibility
9695
deriving (Show)
9796

9897
instance ToJSON SearchResult where
9998
toJSON = \case
100-
SearchResultUser handle name avatarUrl ->
99+
SearchResultUser (UserDisplayInfo {handle, name, avatarUrl, userId}) ->
101100
Aeson.object
102101
[ "handle" .= fromId @UserHandle @Text handle,
103102
"name" .= name,
104103
"avatarUrl" .= avatarUrl,
104+
"userId" .= userId,
105105
"tag" .= ("User" :: Text)
106106
]
107107
SearchResultProject shorthand summary visibility ->
@@ -156,8 +156,7 @@ instance ToJSON UserDisplayInfo where
156156
"userId" Aeson..= userId
157157
]
158158

159-
data DefinitionNameSearchResult
160-
= DefinitionNameSearchResult
159+
data DefinitionNameSearchResult = DefinitionNameSearchResult
161160
{ token :: Name,
162161
tag :: TermOrTypeTag
163162
}
@@ -179,8 +178,7 @@ instance ToJSON DefinitionSearchResults where
179178
[ "results" .= results
180179
]
181180

182-
data DefinitionSearchResult
183-
= DefinitionSearchResult
181+
data DefinitionSearchResult = DefinitionSearchResult
184182
{ fqn :: Name,
185183
summary :: DefSync.TermOrTypeSummary,
186184
project :: ProjectShortHand,

transcripts/run-transcripts.zsh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
unset UNISON_SYNC_VERSION
6+
57
while ! ( curl http://localhost:5424/health > /dev/null 2> /dev/null ) do \
68
echo "Waiting for share server to come up, did you run 'make serve'?"; \
79
sleep 1; \

transcripts/share-apis/code-browse/account.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"unison"
99
],
1010
"primaryEmail": "[email protected]",
11-
"userId": "U-43efd5e7-139a-40b2-8a35-3f99b054dc84"
11+
"userId": "U-<UUID>"
1212
},
13-
"status": 200
13+
"status": [
14+
{
15+
"status_code": 200
16+
}
17+
]
1418
}

transcripts/share-apis/code-browse/codebase-browse.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,9 @@
128128
"namespaceListingFQN": "names",
129129
"namespaceListingHash": "#77bp25t820hpn7t6andan3evac2o5gon8ulggl3kq2galktlbo10jkpub3rli3teop6h5ikgjhuirk87hf58g7cir4pk0ra6a9r5rro"
130130
},
131-
"status": 200
131+
"status": [
132+
{
133+
"status_code": 200
134+
}
135+
]
132136
}

transcripts/share-apis/code-browse/codebase-definition-by-hash-constructor.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,9 @@
7171
}
7272
}
7373
},
74-
"status": 200
74+
"status": [
75+
{
76+
"status_code": 200
77+
}
78+
]
7579
}

transcripts/share-apis/code-browse/codebase-definition-by-hash-term.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,9 @@
8080
},
8181
"typeDefinitions": {}
8282
},
83-
"status": 200
83+
"status": [
84+
{
85+
"status_code": 200
86+
}
87+
]
8488
}

transcripts/share-apis/code-browse/codebase-definition-by-name-encoded.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,9 @@
190190
},
191191
"typeDefinitions": {}
192192
},
193-
"status": 200
193+
"status": [
194+
{
195+
"status_code": 200
196+
}
197+
]
194198
}

transcripts/share-apis/code-browse/codebase-definition-by-name-should-minimally-suffix-again.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,9 @@
8080
},
8181
"typeDefinitions": {}
8282
},
83-
"status": 200
83+
"status": [
84+
{
85+
"status_code": 200
86+
}
87+
]
8488
}

transcripts/share-apis/code-browse/codebase-definition-by-name-should-minimally-suffix.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,9 @@
8080
},
8181
"typeDefinitions": {}
8282
},
83-
"status": 200
83+
"status": [
84+
{
85+
"status_code": 200
86+
}
87+
]
8488
}

0 commit comments

Comments
 (0)