fix: evaluate document creation timestamps per instance

This commit is contained in:
tdurieux
2026-09-06 09:19:33 +02:00
parent f312105ec3
commit b070d7e281
7 changed files with 17 additions and 6 deletions
@@ -37,7 +37,7 @@ const AnonymizedGistSchema = new Schema({
}, },
dateOfEntry: { dateOfEntry: {
type: Date, type: Date,
default: new Date(), default: Date.now,
}, },
gist: { gist: {
description: String, description: String,
@@ -38,7 +38,7 @@ const AnonymizedPullRequestSchema = new Schema({
}, },
dateOfEntry: { dateOfEntry: {
type: Date, type: Date,
default: new Date(), default: Date.now,
}, },
pullRequest: { pullRequest: {
diff: String, diff: String,
@@ -59,7 +59,7 @@ const AnonymizedRepositorySchema = new Schema({
}, },
dateOfEntry: { dateOfEntry: {
type: Date, type: Date,
default: new Date(), default: Date.now,
}, },
size: { size: {
storage: { storage: {
@@ -32,7 +32,7 @@ const RepositorySchema = new Schema({
}, },
dateOfEntry: { dateOfEntry: {
type: Date, type: Date,
default: new Date(), default: Date.now,
}, },
plan: { plan: {
planID: String, planID: String,
@@ -34,7 +34,7 @@ const RepositorySchema = new Schema({
}, },
dateOfEntry: { dateOfEntry: {
type: Date, type: Date,
default: new Date(), default: Date.now,
}, },
}); });
+1 -1
View File
@@ -54,7 +54,7 @@ const UserSchema = new Schema({
}, },
dateOfEntry: { dateOfEntry: {
type: Date, type: Date,
default: new Date(), default: Date.now,
}, },
}); });
+11
View File
@@ -286,6 +286,17 @@ describe("production regressions", function () {
catch (error) { expect(error.message).to.equal("storage failed"); } catch (error) { expect(error.message).to.equal("storage failed"); }
expect(model.status).to.equal("ready"); expect(model.status).to.equal("ready");
}); });
it("creates fresh entry dates for each document", async function () {
const models = [
["users", "users"], ["repositories", "repositories"], ["conference", "conferences"],
["anonymizedRepositories", "anonymizedRepositories"], ["anonymizedGists", "anonymizedGists"],
["anonymizedPullRequests", "anonymizedPullRequests"],
].map(([folder, name]) => require(`../src/core/model/${folder}/${name}.model`).default);
const first = models.map(Model => new Model().dateOfEntry);
await new Promise(resolve => setTimeout(resolve, 15));
models.forEach((Model, i) => expect(new Model().dateOfEntry.getTime()).to.be.greaterThan(first[i].getTime()));
});
it("omits an upstream length when later text is rewritten", async function () { it("omits an upstream length when later text is rewritten", async function () {
const File = require("../src/core/AnonymizedFile").default; const File = require("../src/core/AnonymizedFile").default;
stub(config, "STREAMER_ENTRYPOINT", ""); stub(config, "STREAMER_ENTRYPOINT", "");