Skip to content

add sorting to database query of repo_units #2603

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

Closed
wants to merge 5 commits into from

Conversation

daviian
Copy link
Member

@daviian daviian commented Sep 25, 2017

If sorting is wrong and UnitTypeCode is not the first one, a user can't visit to the Code Tab even with required permissions.

Furthermore fixes wrong redirect to leftmost accessible tab in repo view.

@daviian daviian force-pushed the bugfix/unit-type-sort branch from 401000e to e86ed4f Compare September 25, 2017 18:19
@daviian daviian changed the base branch from release/v1.2 to master September 25, 2017 18:20
@lafriks
Copy link
Member

lafriks commented Sep 25, 2017

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Sep 25, 2017
@lafriks
Copy link
Member

lafriks commented Sep 25, 2017

Can you add integration test for this?

@daviian
Copy link
Member Author

daviian commented Sep 25, 2017

@lafriks Hopefully 😄

@daviian
Copy link
Member Author

daviian commented Sep 25, 2017

@lafriks Changed repo_unit fixtures. Wrong sorting breaks all integration tests which call /user2/repo1 without adding sorting.

@codecov-io
Copy link

codecov-io commented Sep 25, 2017

Codecov Report

Merging #2603 into master will not change coverage.
The diff coverage is 50%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2603   +/-   ##
======================================
  Coverage    27.3%   27.3%           
======================================
  Files          86      86           
  Lines       17139   17139           
======================================
  Hits         4680    4680           
  Misses      11781   11781           
  Partials      678     678
Impacted Files Coverage Δ
models/repo_unit.go 7.69% <50%> (ø) ⬆️

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 26e49b8...0fc1ad6. Read the comment docs.

@lunny
Copy link
Member

lunny commented Sep 26, 2017

But index is the column really designed for sorting.

@lafriks
Copy link
Member

lafriks commented Sep 26, 2017

@lunny but it's not used anywhere. And current code logic depends on unit types to be in type order when checking rights and it fails if it is not so

@Morlinest
Copy link
Member

@lafriks If you merge #2601, repo home will not fail... This PR can solve problem with showing leftmost tab.

@lafriks
Copy link
Member

lafriks commented Sep 26, 2017

Might be that home just need to be changed so that order would not matter and fixtures moved to that PR than this one would not be needed at all

@Morlinest
Copy link
Member

@lafriks Don't need to move fixtures there. That PR is just to fix function implementation that @daviian pointed me to while trying to solve sorting. This PR can be (at least quick) fix for redirecting to tabs in good order.

@Morlinest
Copy link
Member

@daviian Can you use index column for sorting If we implement #2601?

@daviian
Copy link
Member Author

daviian commented Sep 26, 2017

@lunny @lafriks @Morlinest As long as index has the same sorting as the tab ordering in repo view it is fine to use index to sort types.

And since index is the integer value of the UnitType constant it is.

@lunny lunny added the type/bug label Sep 28, 2017
@lunny lunny added this to the 1.3.0 milestone Sep 28, 2017
@lunny
Copy link
Member

lunny commented Sep 28, 2017

which issue will this PR fix?

@daviian
Copy link
Member Author

daviian commented Sep 28, 2017

@lunny Use the models/fixtures/repo_unit.yml I provided in this PR and run integration tests. A lot of tests will fail because of wrong sorting.

@Morlinest
Copy link
Member

Morlinest commented Sep 28, 2017

@daviian Index is not integer value of UnitType. It should be taken from Unit.Idx I think, but now it's just starting from 0 and is another bug.

Edit: Index from range is used as Index.
Edit2: Now I found places, where just int value of unit is used...

@Morlinest
Copy link
Member

@lunny What should be source for Index? I think it should be Unit.Idx, right?

@lunny
Copy link
Member

lunny commented Sep 28, 2017

@Morlinest yes.

@lunny
Copy link
Member

lunny commented Sep 28, 2017

LGTM

@tboerger tboerger 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 Sep 28, 2017
@Morlinest
Copy link
Member

@lunny Then #2621

@lafriks
Copy link
Member

lafriks commented Sep 28, 2017

Actually I think fix should go into home handler so that it would not crash even if units come in different order

@lunny
Copy link
Member

lunny commented Sep 28, 2017

@lafriks Yes, it's not conflict with them. index is the sort column for design. This PR maybe not fix the crash but fixed that.

@lafriks
Copy link
Member

lafriks commented Sep 28, 2017

Yes that's why I ask to hold on with this PR merging so that other can be fixed properly

@Morlinest
Copy link
Member

@lafriks @lunny I think you have 1 PR for everything now :). This PR is about getting units sorted from DB, #2601 fixes home handler and #2621 fixes creating new repo units + fixes existing index data in DB.

@daviian
Copy link
Member Author

daviian commented Sep 28, 2017

@lafriks You mean that the Home handler should be capable of knowing the correct order of unit types (to open the leftmost accessible tab) without doing sorting at db layer?

@lafriks
Copy link
Member

lafriks commented Sep 28, 2017

Yes. I think it should take unit order from models.AllUnitTypes and use it and then check if each of them is enabled

@Morlinest
Copy link
Member

We can improve it later. And then we can just remove Index from DB as it will be useless.

@lunny
Copy link
Member

lunny commented Sep 29, 2017

@lafriks could this be merged?

@daviian
Copy link
Member Author

daviian commented Oct 1, 2017

Close in favour of #2621

@daviian daviian closed this Oct 1, 2017
@daviian daviian deleted the bugfix/unit-type-sort branch October 3, 2017 17:04
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
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/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants