Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Places: make functional queries for places: status=online,active
  • Loading branch information
Misterblue committed Jun 13, 2021
1 parent 12f635a commit 24020bd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Entities/EntityFilters/PlaceFilterInfo.ts
Expand Up @@ -14,6 +14,7 @@
'use strict'

import { Request } from 'express';
import { Places } from '@Entities/Places';
import { PlaceEntity } from '@Entities/PlaceEntity';

import { CriteriaFilter } from '@Entities/EntityFilters/CriteriaFilter';
Expand All @@ -34,6 +35,8 @@ import { Logger } from '@Tools/Logging';
export class PlaceFilterInfo extends CriteriaFilter {

private _maturity: string[];
private _checkIfOnline: boolean = false;
private _checkIfActive: boolean = false;
private _tags: string[];
private _ascending: number = 1;
private _orderByName: boolean = false;
Expand Down Expand Up @@ -87,8 +90,10 @@ export class PlaceFilterInfo extends CriteriaFilter {
for (const stat of statuses) {
switch (stat) {
case 'online':
this._checkIfOnline = true;
break;
case 'active':
this._checkIfActive = true;
break;
default:
break;
Expand Down Expand Up @@ -183,15 +188,21 @@ export class PlaceFilterInfo extends CriteriaFilter {
const criteria:VKeyedCollection = {};
if (this._maturity) {
/* tslint:disable-next-line */
criteria['maturity'] = { '$in': this._maturity }
criteria['maturity'] = { '$in': this._maturity };
};
if (this._checkIfActive) {
criteria.currentAttendance = { '$gt': 0 };
};
if (this._checkIfOnline) {
criteria.lastActivity = { '$gte': Places.dateWhenNotActive() };
};
if (this._tags) {
/* tslint:disable-next-line */
criteria['tags'] = { '$in': this._tags }
criteria['tags'] = { '$in': this._tags };
};
if (this._search) {
/* tslint:disable-next-line */
criteria['name'] = { '$regex': this._search, '$options': 'i' }
criteria['name'] = { '$regex': this._search, '$options': 'i' };
};
return criteria;
};
Expand Down

0 comments on commit 24020bd

Please sign in to comment.