Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
refactor: remove repository metadata from other search results except…
Browse files Browse the repository at this point in the history
… RepoMatch
  • Loading branch information
erzhtor committed Apr 13, 2023
1 parent dbc8b4b commit 52c6bf9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const CommitSearchResult: React.FunctionComponent<Props> = ({
repoName={result.repository}
repoStars={result.repoStars}
className={containerClassName}
keyValuePairs={result.keyValuePairs}
as={as}
>
<CommitSearchResultMatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ export const FileContentSearchResult: React.FunctionComponent<React.PropsWithChi
className={classNames(styles.copyButtonContainer, containerClassName)}
resultClassName={resultContainerStyles.highlightResult}
rankingDebug={result.debug}
keyValuePairs={result.keyValuePairs}
ref={rootRef}
>
<div data-testid="file-search-result" data-expanded={expanded}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const FilePathSearchResult: React.FunctionComponent<FilePathSearchResult
repoName={result.repository}
repoStars={result.repoStars}
rankingDebug={result.debug}
keyValuePairs={result.keyValuePairs}
className={classNames(styles.copyButtonContainer, containerClassName)}
>
<div className={classNames(styles.searchResultMatch, 'p-2')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export const SymbolSearchResult: React.FunctionComponent<SymbolSearchResultProps
repoStars={result.repoStars}
className={classNames(searchResultStyles.copyButtonContainer, containerClassName)}
resultClassName={styles.symbolsOverride}
keyValuePairs={result.keyValuePairs}
>
<div className={styles.symbols}>
{result.repoLastFetched && <LastSyncedIcon lastSyncedTime={result.repoLastFetched} />}
Expand Down
4 changes: 0 additions & 4 deletions client/shared/src/search/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export interface PathMatch {
branches?: string[]
commit?: string
debug?: string
keyValuePairs?: Record<string, string>
}

export interface ContentMatch {
Expand All @@ -57,7 +56,6 @@ export interface ContentMatch {
chunkMatches?: ChunkMatch[]
hunks?: DecoratedHunk[]
debug?: string
keyValuePairs?: Record<string, string>
}

export interface DecoratedHunk {
Expand Down Expand Up @@ -107,7 +105,6 @@ export interface SymbolMatch {
commit?: string
symbols: MatchedSymbol[]
debug?: string
keyValuePairs?: Record<string, string>
}

export interface MatchedSymbol {
Expand Down Expand Up @@ -142,7 +139,6 @@ export interface CommitMatch {
content: MarkdownText
// Array of [line, character, length] triplets
ranges: number[][]
keyValuePairs?: Record<string, string>
}

export interface RepositoryMatch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export const SymbolSearchResult: React.FunctionComponent<SymbolSearchResultProps
repoStars={result.repoStars}
className={classNames(searchResultStyles.copyButtonContainer, containerClassName)}
resultClassName={styles.symbolsOverride}
keyValuePairs={result.keyValuePairs}
>
<div className={styles.symbols}>
{result.repoLastFetched && <LastSyncedIcon lastSyncedTime={result.repoLastFetched} />}
Expand Down
4 changes: 0 additions & 4 deletions cmd/frontend/internal/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ func fromPathMatch(fm *result.FileMatch, repoCache map[api.RepoID]*types.Searche
if r, ok := repoCache[fm.Repo.ID]; ok {
pathEvent.RepoStars = r.Stars
pathEvent.RepoLastFetched = r.LastFetched
pathEvent.KeyValuePairs = r.KeyValuePairs
}

if fm.InputRev != nil {
Expand Down Expand Up @@ -411,7 +410,6 @@ func fromContentMatch(fm *result.FileMatch, repoCache map[api.RepoID]*types.Sear
if r, ok := repoCache[fm.Repo.ID]; ok {
contentEvent.RepoStars = r.Stars
contentEvent.RepoLastFetched = r.LastFetched
contentEvent.KeyValuePairs = r.KeyValuePairs
}

if fm.Debug != nil {
Expand Down Expand Up @@ -451,7 +449,6 @@ func fromSymbolMatch(fm *result.FileMatch, repoCache map[api.RepoID]*types.Searc
if r, ok := repoCache[fm.Repo.ID]; ok {
symbolMatch.RepoStars = r.Stars
symbolMatch.RepoLastFetched = r.LastFetched
symbolMatch.KeyValuePairs = r.KeyValuePairs
}

if fm.InputRev != nil {
Expand Down Expand Up @@ -516,7 +513,6 @@ func fromCommit(commit *result.CommitMatch, repoCache map[api.RepoID]*types.Sear
if r, ok := repoCache[commit.Repo.ID]; ok {
commitEvent.RepoStars = r.Stars
commitEvent.RepoLastFetched = r.LastFetched
commitEvent.KeyValuePairs = r.KeyValuePairs
}

return commitEvent
Expand Down
50 changes: 23 additions & 27 deletions internal/search/streaming/http/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ type EventContentMatch struct {
// Type is always FileMatchType. Included here for marshalling.
Type MatchType `json:"type"`

Path string `json:"path"`
PathMatches []Range `json:"pathMatches,omitempty"`
RepositoryID int32 `json:"repositoryID"`
Repository string `json:"repository"`
RepoStars int `json:"repoStars,omitempty"`
RepoLastFetched *time.Time `json:"repoLastFetched,omitempty"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
Hunks []DecoratedHunk `json:"hunks"`
LineMatches []EventLineMatch `json:"lineMatches,omitempty"`
ChunkMatches []ChunkMatch `json:"chunkMatches,omitempty"`
Debug string `json:"debug,omitempty"`
KeyValuePairs map[string]*string `json:"keyValuePairs,omitempty"`
Path string `json:"path"`
PathMatches []Range `json:"pathMatches,omitempty"`
RepositoryID int32 `json:"repositoryID"`
Repository string `json:"repository"`
RepoStars int `json:"repoStars,omitempty"`
RepoLastFetched *time.Time `json:"repoLastFetched,omitempty"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
Hunks []DecoratedHunk `json:"hunks"`
LineMatches []EventLineMatch `json:"lineMatches,omitempty"`
ChunkMatches []ChunkMatch `json:"chunkMatches,omitempty"`
Debug string `json:"debug,omitempty"`
}

func (e *EventContentMatch) eventMatch() {}
Expand All @@ -44,16 +43,15 @@ type EventPathMatch struct {
// Type is always PathMatchType. Included here for marshalling.
Type MatchType `json:"type"`

Path string `json:"path"`
PathMatches []Range `json:"pathMatches,omitempty"`
RepositoryID int32 `json:"repositoryID"`
Repository string `json:"repository"`
RepoStars int `json:"repoStars,omitempty"`
RepoLastFetched *time.Time `json:"repoLastFetched,omitempty"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
Debug string `json:"debug,omitempty"`
KeyValuePairs map[string]*string `json:"keyValuePairs,omitempty"`
Path string `json:"path"`
PathMatches []Range `json:"pathMatches,omitempty"`
RepositoryID int32 `json:"repositoryID"`
Repository string `json:"repository"`
RepoStars int `json:"repoStars,omitempty"`
RepoLastFetched *time.Time `json:"repoLastFetched,omitempty"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
Debug string `json:"debug,omitempty"`
}

func (e *EventPathMatch) eventMatch() {}
Expand Down Expand Up @@ -128,8 +126,7 @@ type EventSymbolMatch struct {
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`

Symbols []Symbol `json:"symbols"`
KeyValuePairs map[string]*string `json:"keyValuePairs,omitempty"`
Symbols []Symbol `json:"symbols"`
}

func (e *EventSymbolMatch) eventMatch() {}
Expand Down Expand Up @@ -165,8 +162,7 @@ type EventCommitMatch struct {
RepoLastFetched *time.Time `json:"repoLastFetched,omitempty"`
Content string `json:"content"`
// [line, character, length]
Ranges [][3]int32 `json:"ranges"`
KeyValuePairs map[string]*string `json:"keyValuePairs,omitempty"`
Ranges [][3]int32 `json:"ranges"`
}

func (e *EventCommitMatch) eventMatch() {}
Expand Down

0 comments on commit 52c6bf9

Please sign in to comment.