diff --git a/src/core/model/anonymizedGists/anonymizedGists.schema.ts b/src/core/model/anonymizedGists/anonymizedGists.schema.ts index edbde52..4ee6292 100644 --- a/src/core/model/anonymizedGists/anonymizedGists.schema.ts +++ b/src/core/model/anonymizedGists/anonymizedGists.schema.ts @@ -37,7 +37,7 @@ const AnonymizedGistSchema = new Schema({ }, dateOfEntry: { type: Date, - default: new Date(), + default: Date.now, }, gist: { description: String, diff --git a/src/core/model/anonymizedPullRequests/anonymizedPullRequests.schema.ts b/src/core/model/anonymizedPullRequests/anonymizedPullRequests.schema.ts index 20cf546..964c1e4 100644 --- a/src/core/model/anonymizedPullRequests/anonymizedPullRequests.schema.ts +++ b/src/core/model/anonymizedPullRequests/anonymizedPullRequests.schema.ts @@ -38,7 +38,7 @@ const AnonymizedPullRequestSchema = new Schema({ }, dateOfEntry: { type: Date, - default: new Date(), + default: Date.now, }, pullRequest: { diff: String, diff --git a/src/core/model/anonymizedRepositories/anonymizedRepositories.schema.ts b/src/core/model/anonymizedRepositories/anonymizedRepositories.schema.ts index 6383b18..ccbcbf3 100644 --- a/src/core/model/anonymizedRepositories/anonymizedRepositories.schema.ts +++ b/src/core/model/anonymizedRepositories/anonymizedRepositories.schema.ts @@ -59,7 +59,7 @@ const AnonymizedRepositorySchema = new Schema({ }, dateOfEntry: { type: Date, - default: new Date(), + default: Date.now, }, size: { storage: { diff --git a/src/core/model/conference/conferences.schema.ts b/src/core/model/conference/conferences.schema.ts index a0bad4c..0d6c3c1 100644 --- a/src/core/model/conference/conferences.schema.ts +++ b/src/core/model/conference/conferences.schema.ts @@ -32,7 +32,7 @@ const RepositorySchema = new Schema({ }, dateOfEntry: { type: Date, - default: new Date(), + default: Date.now, }, plan: { planID: String, diff --git a/src/core/model/repositories/repositories.schema.ts b/src/core/model/repositories/repositories.schema.ts index 359526f..837a48a 100644 --- a/src/core/model/repositories/repositories.schema.ts +++ b/src/core/model/repositories/repositories.schema.ts @@ -34,7 +34,7 @@ const RepositorySchema = new Schema({ }, dateOfEntry: { type: Date, - default: new Date(), + default: Date.now, }, }); diff --git a/src/core/model/users/users.schema.ts b/src/core/model/users/users.schema.ts index 59b5889..6572ef7 100644 --- a/src/core/model/users/users.schema.ts +++ b/src/core/model/users/users.schema.ts @@ -54,7 +54,7 @@ const UserSchema = new Schema({ }, dateOfEntry: { type: Date, - default: new Date(), + default: Date.now, }, }); diff --git a/test/production-regressions.test.js b/test/production-regressions.test.js index 1132f76..beb9e98 100644 --- a/test/production-regressions.test.js +++ b/test/production-regressions.test.js @@ -286,6 +286,17 @@ describe("production regressions", function () { catch (error) { expect(error.message).to.equal("storage failed"); } 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 () { const File = require("../src/core/AnonymizedFile").default; stub(config, "STREAMER_ENTRYPOINT", "");