Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detected file language to code search #10256

Merged

Conversation

lafriks
Copy link
Member

@lafriks lafriks commented Feb 12, 2020

There are multiple things improved in code search:

  • Detect code language for each indexed file and allow filter search by specifying language
  • Show total file counts in each language for specified query
  • Add commit ID the file is indexed for so View file would open actually indexed file version
  • Add last indexed at field to file with time file was indexed at
  • Ignore files in vendor directories

Screenshot:
image

Selected language filter:
image

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Feb 12, 2020
@lafriks lafriks added this to the 1.12.0 milestone Feb 12, 2020
@lafriks lafriks added the type/changelog Adds the changelog for a new Gitea version label Feb 12, 2020
@lafriks lafriks force-pushed the feat/code_search_detect_language branch 2 times, most recently from 3604c57 to 6c02baf Compare February 12, 2020 20:24
@codecov-io
Copy link

codecov-io commented Feb 12, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@266d09f). Click here to learn what that means.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #10256   +/-   ##
=========================================
  Coverage          ?   43.75%           
=========================================
  Files             ?      586           
  Lines             ?    81113           
  Branches          ?        0           
=========================================
  Hits              ?    35491           
  Misses            ?    41234           
  Partials          ?     4388
Impacted Files Coverage Δ
models/issue.go 53.82% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 266d09f...79ddfd1. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 12, 2020
modules/indexer/code/bleve.go Outdated Show resolved Hide resolved
modules/indexer/code/bleve.go Outdated Show resolved Hide resolved
modules/indexer/code/bleve.go Outdated Show resolved Hide resolved
modules/indexer/code/bleve.go Show resolved Hide resolved
modules/indexer/code/bleve.go Show resolved Hide resolved
@lunny
Copy link
Member

lunny commented Feb 14, 2020

I think a better UI is always list all the languages even you check one of the languages. And if you use one and hightlight one. Otherwise once you click the language, you cannot back to the previous UI or click another language.

@lafriks
Copy link
Member Author

lafriks commented Feb 14, 2020

@lunny that's really not possible imho as bleve returns stats based on query in single request. Showing all languages would require execute separate search without language filter and would make things at least twice as slow

@guillep2k
Copy link
Member

@lunny that's really not possible imho as bleve returns stats based on query in single request. Showing all languages would require execute separate search without language filter and would make things at least twice as slow

Can you use the laguage stats table for a list of languagues?

@lafriks
Copy link
Member Author

lafriks commented Feb 14, 2020

@lunny that's really not possible imho as bleve returns stats based on query in single request. Showing all languages would require execute separate search without language filter and would make things at least twice as slow

Can you use the laguage stats table for a list of languagues?

No, code language stats are for repository, search can be global and filters are shown per-file ocurrance count

@lafriks lafriks force-pushed the feat/code_search_detect_language branch 4 times, most recently from 4f6ac41 to d708a81 Compare February 16, 2020 16:33
Copy link
Member

@guillep2k guillep2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 16, 2020
@lunny
Copy link
Member

lunny commented Feb 17, 2020

I will not block this PR. But I think we still need that languages stat bar. We may need two requests.

@lafriks
Copy link
Member Author

lafriks commented Feb 17, 2020

That can be improved later but it should be measured how much performance hit would it make

@lunny
Copy link
Member

lunny commented Feb 17, 2020

Or we could add a button to return to all languages. i.e. All languages >> <selected language>

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 17, 2020
@guillep2k
Copy link
Member

@lafriks Maybe the language list can be actually asked to bleve itself? The indexer should know what languages are indexed at any given time, since it's metadata.

@lafriks
Copy link
Member Author

lafriks commented Feb 18, 2020

@guillep2k language list is already returned by bleve using facets: https://github.com/go-gitea/gitea/pull/10256/files#diff-b34c4c9dfe1f4d61c3585819d795f655R352

To get language list for results for all languages would require doing separate request to bleve with other query without language condition just to get them

@lafriks lafriks force-pushed the feat/code_search_detect_language branch from b2e9115 to ca5d728 Compare February 18, 2020 10:11
@lafriks
Copy link
Member Author

lafriks commented Feb 18, 2020

@lunny @guillep2k ok, I added additional query to bleve to get language stats for query if filtering by language, see updates screenshot above

@lafriks lafriks force-pushed the feat/code_search_detect_language branch from ca5d728 to bc2cd44 Compare February 18, 2020 10:20
@lunny
Copy link
Member

lunny commented Feb 18, 2020

Pagination is not correct.

@lafriks
Copy link
Member Author

lafriks commented Feb 18, 2020

@lunny I already fixed pagination today, or what do you mean?

Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you select one language, I found there is still pagination problem.

@lafriks
Copy link
Member Author

lafriks commented Feb 18, 2020

@lunny what problem exactly? Works for me just fine both when language is selected and when not

@lafriks
Copy link
Member Author

lafriks commented Feb 18, 2020

gitea-codesearch-languages

@guillep2k
Copy link
Member

Perhaps if you're on page 2 of C# and click on say JavaScript (which only got one page) the page number remains as 2 and that causes a problem? (didn't check myself).

@lafriks
Copy link
Member Author

lafriks commented Feb 18, 2020

@guillep2k no, I specifically create url without page number when clicking on language to go to page one in such cases

@lunny
Copy link
Member

lunny commented Feb 19, 2020

@lafriks when you click that language only one page.

Move langauge detection to separate module to be more reusable

Add option to disable vendored file exclusion from file search

Allways show all language stats for search
@lafriks lafriks force-pushed the feat/code_search_detect_language branch from 03869df to 8ade039 Compare February 19, 2020 08:25
@lafriks
Copy link
Member Author

lafriks commented Feb 19, 2020

@lunny fixed, I introduced bug when adding language stats with separate bleve query :)

@guillep2k
Copy link
Member

Somehow the "Update Branch" button is not available ATM. I'm unable to update+merge.

@guillep2k
Copy link
Member

Ping LG-TM

@guillep2k guillep2k merged commit 3c45cf8 into go-gitea:master Feb 20, 2020
@lafriks lafriks deleted the feat/code_search_detect_language branch February 21, 2020 05:24
@mooror
Copy link

mooror commented Aug 3, 2020

This is such a useful feature, I can't wait to upgrade to the 12 release! Big thank you to @lafriks and everyone else who contributed to this feature.

Keep up the great work guys,
Benjamin

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants