Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-09-04 09:24:31 +02:00
parent 4912292503
commit 814feeed73
19 changed files with 75 additions and 38 deletions
@@ -74,13 +74,13 @@ const secondSchema = {
}),
};
const now = DateTime.now().toISO();
const now = DateTime.now().toISO()!;
const shortlyInTheFuture = DateTime.now()
.plus(Duration.fromMillis(555))
.toISO();
.toISO()!;
const farInTheFuture = DateTime.now()
.plus(Duration.fromMillis(555666777))
.toISO();
.toISO()!;
const facts = [
{
@@ -127,13 +127,13 @@ const sameFactsDiffDateSchema = {
}),
};
const sameFactsDiffDateNow = DateTime.now().toISO();
const sameFactsDiffDateNow = DateTime.now().toISO()!;
const sameFactsDiffDateNearFuture = DateTime.now()
.plus(Duration.fromMillis(555))
.toISO();
.toISO()!;
const sameFactsDiffDateFuture = DateTime.now()
.plus(Duration.fromMillis(1000))
.toISO();
.toISO()!;
const multipleSameFacts = [
{
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Knex } from 'knex';
import {
FactLifecycle,
@@ -105,12 +106,13 @@ export class TechInsightsDatabase implements TechInsightsStore {
if (facts.length === 0) return;
const currentSchema = await this.getLatestSchema(id);
const factRows = facts.map(it => {
const ts = it.timestamp?.toISO();
return {
id,
version: currentSchema.version,
entity: stringifyEntityRef(it.entity),
facts: JSON.stringify(it.facts),
...(it.timestamp && { timestamp: it.timestamp.toISO() }),
...(ts && { timestamp: ts }),
};
});