1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 19:29:56 +00:00

Solve the problem of inaccurate sorting of the database

This commit is contained in:
zxj96
2019-05-29 15:11:18 +08:00
parent 835fcb8ddb
commit ae8365854e
2 changed files with 12 additions and 2 deletions

View File

@@ -86,7 +86,7 @@ class MylibRepoListView extends React.Component {
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th> <th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
<th width="38%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {this.props.sortBy === 'name' && sortIcon}</a></th> <th width="38%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {this.props.sortBy === 'name' && sortIcon}</a></th>
<th width="14%"><span className="sr-only">{gettext('Actions')}</span></th> <th width="14%"><span className="sr-only">{gettext('Actions')}</span></th>
<th width={showStorageBackend ? '15%' : '20%'} onClick={this.sortBySize}>{gettext('Size')} {this.props.sortBy === 'size' && sortIcon}</th> <th width={showStorageBackend ? '15%' : '20%'}><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {this.props.sortBy === 'size' && sortIcon}</a></th>
{showStorageBackend ? <th width="10%">{gettext('Storage backend')}</th> : null} {showStorageBackend ? <th width="10%">{gettext('Storage backend')}</th> : null}
<th width={showStorageBackend ? '15%' : '20%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {this.props.sortBy === 'time' && sortIcon}</a></th> <th width={showStorageBackend ? '15%' : '20%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {this.props.sortBy === 'time' && sortIcon}</a></th>
</tr> </tr>

View File

@@ -618,12 +618,22 @@ export const Utils = {
break; break;
case 'size-asc': case 'size-asc':
comparator = function(a, b) { comparator = function(a, b) {
if (a.size === b.size) {
var result = _this.compareTwoWord(a.repo_name, b.repo_name);
return result;
}
let reult = _this.compareTwoSize(a.size, b.size); let reult = _this.compareTwoSize(a.size, b.size);
return reult; return reult;
}; };
break; break;
case 'size-desc': case 'size-desc':
comparator = function(a, b) { comparator = function(a, b) {
if (a.size === b.size) {
var result = _this.compareTwoWord(a.repo_name, b.repo_name);
return -result;
}
let reult = _this.compareTwoSize(a.size, b.size); let reult = _this.compareTwoSize(a.size, b.size);
return -reult; return -reult;
}; };
@@ -711,7 +721,7 @@ export const Utils = {
let bFileName = b.match(fileSizeName)[0]; let bFileName = b.match(fileSizeName)[0];
let aBytes = aFileName * (1000 ** aIndex); let aBytes = aFileName * (1000 ** aIndex);
let bBytes = bFileName * (1000 ** bIndex); let bBytes = bFileName * (1000 ** bIndex);
return aBytes < bBytes ? -1 : 1; return aBytes < bBytes ? -1 : 1;
}, },