server-ts: Port services/search/expressions/ancestor

This commit is contained in:
Elian Doran 2024-02-18 00:40:15 +02:00
parent ce60fc0c3a
commit 414515bc87
No known key found for this signature in database
3 changed files with 15 additions and 14 deletions

View File

@ -1,12 +1,19 @@
"use strict";
const Expression = require('./expression');
const NoteSet = require('../note_set');
const log = require('../../log');
const becca = require('../../../becca/becca');
import Expression = require('./expression');
import NoteSet = require('../note_set');
import log = require('../../log');
import becca = require('../../../becca/becca');
import SearchContext = require('../search_context');
class AncestorExp extends Expression {
constructor(ancestorNoteId, ancestorDepth) {
private ancestorNoteId: string;
private ancestorDepthComparator;
ancestorDepth: string;
constructor(ancestorNoteId: string, ancestorDepth: string) {
super();
this.ancestorNoteId = ancestorNoteId;
@ -14,7 +21,7 @@ class AncestorExp extends Expression {
this.ancestorDepthComparator = this.getComparator(ancestorDepth);
}
execute(inputNoteSet, executionContext, searchContext) {
execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) {
const ancestorNote = becca.notes[this.ancestorNoteId];
if (!ancestorNote) {
@ -44,7 +51,7 @@ class AncestorExp extends Expression {
return depthConformingNoteSet;
}
getComparator(depthCondition) {
getComparator(depthCondition: string): ((depth: number) => boolean) | null {
if (!depthCondition) {
return null;
}

View File

@ -10,12 +10,6 @@ abstract class Expression {
this.name = this.constructor.name; // for DEBUG mode to have expression name as part of dumped JSON
}
/**
* @param {NoteSet} inputNoteSet
* @param {object} executionContext
* @param {SearchContext} searchContext
* @returns {NoteSet}
*/
abstract execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext): NoteSet;
}

View File

@ -14,7 +14,7 @@ const LabelComparisonExp = require('../expressions/label_comparison.js');
const NoteFlatTextExp = require('../expressions/note_flat_text.js');
const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');
const OrderByAndLimitExp = require('../expressions/order_by_and_limit.js');
const AncestorExp = require('../expressions/ancestor.js');
const AncestorExp = require('../expressions/ancestor');
const buildComparator = require('./build_comparator.js');
const ValueExtractor = require('../value_extractor');
const utils = require('../../utils');