Skip to content

Commit

Permalink
chore: handle feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvercr committed Sep 27, 2024
1 parent e037f92 commit 83bede9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 42 deletions.
14 changes: 9 additions & 5 deletions lib/condition/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export class Range {
);
if (between) {
this.min = between.min;
this.max = between.max;
this.eqMin = true;
this.max = between.max;
this.eqMax = false;
}
return;
Expand Down Expand Up @@ -161,10 +161,14 @@ export class Range {
this.defaultTimezone,
);
if (between) {
this.min = between.min;
this.eqMin = true;
this.max = between.max;
this.eqMax = false;
if (this.min === undefined || between.min < this.min) {
this.min = between.min;
this.eqMin = true;
}
if (this.max === undefined || between.max < this.max) {
this.max = between.max;
this.eqMax = false;
}
}
return;
}
Expand Down
18 changes: 0 additions & 18 deletions lib/strategy/ordered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,13 @@ export class OrderedStrategy {
if (x.termType === "Literal") {
dataType = x.datatype.value;
}
console.log(
"Found inbetween relation",
x.value,
undefined,
"Z",
);
const between = parseInBetweenRelation(x.value, dataType, "Z");
console.log("result", between);
if (between) {
return [between];
}
return [];
});

console.log("betweens", betweens);

if (this.ordered === "ascending") {
value = betweens
.map((x) => <undefined | number | Date>x.min)
Expand Down Expand Up @@ -359,8 +350,6 @@ export class OrderedStrategy {
}, value);
}

console.log("value from inbetweens", value);

if (this.ordered === "ascending") {
value = rel.relations
.filter((x) => GTRs.some((gr) => x.type.value === gr.value))
Expand Down Expand Up @@ -444,13 +433,6 @@ export class OrderedStrategy {
}

// Actually emit some members in order
console.log(
"marker",
head.source,
head.target,
marker.important,
marker.value,
);
if (marker.important) {
found.closed = true;
let member = this.members.pop();
Expand Down
23 changes: 4 additions & 19 deletions lib/utils/inBetween.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,27 @@ export function parseInBetweenRelation(
dataType: string | undefined,
defaultTimezone: string,
): Between | undefined {
let thisMin: Date | undefined;
let thisMax: Date | undefined;

const updateResult = (min: Date, max: Date) => {
if (thisMin === undefined || min <= thisMin) {
thisMin = min;
}
if (thisMax === undefined || max > thisMax) {
thisMax = max;
}
};

if (dataType === XSD.custom("gYear")) {
const result = gYearToMinMax(value, defaultTimezone);
if (!result) return;
const [min, max] = result;
updateResult(min, max);
return { min, max };
} else if (dataType === XSD.custom("gYearMonth")) {
const result = gYearMonthToMinMax(value, defaultTimezone);
if (!result) return;
const [min, max] = result;
updateResult(min, max);
return { min, max };
} else if (dataType === XSD.custom("date")) {
const result = dateToMinMax(value, defaultTimezone);
if (!result) return;
const [min, max] = result;
updateResult(min, max);
return { min, max };
} else {
// Check if it is a partial dateTime
const result = partialDateTimeToMinMax(value, defaultTimezone);
if (!result) return;
const [min, max] = result;
updateResult(min, max);
}
if (thisMin !== undefined && thisMax !== undefined) {
return { min: thisMin, max: thisMax };
return { min, max };
}
}

Expand Down

0 comments on commit 83bede9

Please sign in to comment.