1 import { NSFWQuery } from '../../../../shared/models/search'
3 export class AdvancedSearch {
4 startDate: string // ISO 8601
5 endDate: string // ISO 8601
18 durationMin: number // seconds
19 durationMax: number // seconds
21 constructor (options?: {
25 categoryOneOf?: string
27 languageOneOf?: string
35 this.startDate = options.startDate
36 this.endDate = options.endDate
37 this.nsfw = options.nsfw
38 this.categoryOneOf = options.categoryOneOf
39 this.licenceOneOf = options.licenceOneOf
40 this.languageOneOf = options.languageOneOf
41 this.tagsOneOf = options.tagsOneOf
42 this.tagsAllOf = options.tagsAllOf
43 this.durationMin = parseInt(options.durationMin, 10)
44 this.durationMax = parseInt(options.durationMax, 10)
46 if (isNaN(this.durationMin)) this.durationMin = undefined
47 if (isNaN(this.durationMax)) this.durationMax = undefined
51 const obj = this.toUrlObject()
52 for (const k of Object.keys(obj)) {
53 if (obj[k] !== undefined) return true
60 this.startDate = undefined
61 this.endDate = undefined
63 this.categoryOneOf = undefined
64 this.licenceOneOf = undefined
65 this.languageOneOf = undefined
66 this.tagsOneOf = undefined
67 this.tagsAllOf = undefined
68 this.durationMin = undefined
69 this.durationMax = undefined
74 startDate: this.startDate,
75 endDate: this.endDate,
77 categoryOneOf: this.categoryOneOf,
78 licenceOneOf: this.licenceOneOf,
79 languageOneOf: this.languageOneOf,
80 tagsOneOf: this.tagsOneOf,
81 tagsAllOf: this.tagsAllOf,
82 durationMin: this.durationMin,
83 durationMax: this.durationMax
89 startDate: this.startDate,
90 endDate: this.endDate,
92 categoryOneOf: this.categoryOneOf ? this.categoryOneOf.split(',') : undefined,
93 licenceOneOf: this.licenceOneOf ? this.licenceOneOf.split(',') : undefined,
94 languageOneOf: this.languageOneOf ? this.languageOneOf.split(',') : undefined,
95 tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined,
96 tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined,
97 durationMin: this.durationMin,
98 durationMax: this.durationMax