add tags to summary query
This commit is contained in:
1 parent
1322033d41
commit
4b9f1ba43b
3 files changed
+6
-1
No files matched your search
@@ -13,6 +13,7 @@ export interface TeamQueryConfig {
|
||||
|
||||
export interface SummaryConfig {
|
||||
type?: MonitorType | MonitorType[];
|
||||
tags?: string | string[];
|
||||
}
|
||||
|
||||
export interface IMonitorsRepository {
|
||||
|
||||
@@ -292,6 +292,10 @@ class MongoMonitorsRepository implements IMonitorsRepository {
|
||||
if (config?.type !== undefined) {
|
||||
match.type = Array.isArray(config.type) ? { $in: config.type } : config.type;
|
||||
}
|
||||
if (config?.tags !== undefined) {
|
||||
const tagIds = (Array.isArray(config.tags) ? config.tags : [config.tags]).map((tag) => new mongoose.Types.ObjectId(tag));
|
||||
match.tags = { $in: tagIds };
|
||||
}
|
||||
const pipeline = [
|
||||
{ $match: match },
|
||||
{
|
||||
|
||||
@@ -391,7 +391,7 @@ export class MonitorService implements IMonitorService {
|
||||
field?: string;
|
||||
order?: "asc" | "desc";
|
||||
}): Promise<MonitorsWithChecksByTeamIdResult> => {
|
||||
const summary = await this.monitorsRepository.findMonitorsSummaryByTeamId(teamId, { type });
|
||||
const summary = await this.monitorsRepository.findMonitorsSummaryByTeamId(teamId, { type, tags });
|
||||
const count = await this.monitorsRepository.findMonitorCountByTeamIdAndType(teamId, { type, tags, filter });
|
||||
const monitors = await this.monitorsRepository.findByTeamId(teamId, {
|
||||
limit,
|
||||
|
||||
Reference in new issue
Block a user