Remove completed and canceled issues from the list ()

Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@xored.com>
This commit is contained in:
Sergei Ogorelkov 2022-07-06 13:46:57 +07:00 committed by GitHub
parent 0919892557
commit 8df9011bb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 20 deletions
plugins/tracker-resources/src/components
server/mongo/src

View File

@ -68,6 +68,9 @@
$: selected = !Array.isArray(value) ? ('attachedTo' in value ? value.attachedTo : undefined) : undefined
$: ignoreObjects = !Array.isArray(value) ? ('_id' in value ? [value._id] : []) : undefined
$: docQuery = {
'$lookup.status.category': {
$nin: [tracker.issueStatusCategory.Completed, tracker.issueStatusCategory.Canceled]
},
'parents.parentId': {
$nin: [
...new Set(

View File

@ -96,7 +96,7 @@ abstract class MongoAdapterBase extends TxProcessor {
for (const key in query) {
const value = (query as any)[key]
const tkey = this.checkMixinKey(key, clazz)
const tkey = this.translateKey(key, clazz)
if (value !== null && typeof value === 'object') {
const keys = Object.keys(value)
if (keys[0] === '$like') {
@ -321,25 +321,7 @@ abstract class MongoAdapterBase extends TxProcessor {
if (options.sort !== undefined) {
const sort = {} as any
for (const _key in options.sort) {
let key: string = _key
const arr = key.split('.').filter((p) => p)
key = ''
for (let i = 0; i < arr.length; i++) {
const element = arr[i]
if (element === '$lookup') {
key += arr[++i] + '_lookup'
} else {
if (!key.endsWith('.') && i > 0) {
key += '.'
}
key += arr[i]
if (i !== arr.length - 1) {
key += '.'
}
}
// Check if key is belong to mixin class, we need to add prefix.
key = this.checkMixinKey<T>(key, clazz)
}
const key: string = this.translateKey(_key, clazz)
sort[key] = options.sort[_key] === SortingOrder.Ascending ? 1 : -1
}
pipeline.push({ $sort: sort })
@ -378,6 +360,30 @@ abstract class MongoAdapterBase extends TxProcessor {
return toFindResult(result, total)
}
private translateKey<T extends Doc>(key: string, clazz: Ref<Class<T>>): string {
const arr = key.split('.').filter((p) => p)
let tKey = ''
for (let i = 0; i < arr.length; i++) {
const element = arr[i]
if (element === '$lookup') {
tKey += arr[++i] + '_lookup'
} else {
if (!tKey.endsWith('.') && i > 0) {
tKey += '.'
}
tKey += arr[i]
if (i !== arr.length - 1) {
tKey += '.'
}
}
// Check if key is belong to mixin class, we need to add prefix.
tKey = this.checkMixinKey<T>(tKey, clazz)
}
return tKey
}
private clearExtraLookups (row: any): void {
for (const key in row) {
if (key.endsWith('_lookup')) {