Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • backoffice
  • feat/bump-mongodb-driver
  • feat/bump-mongodb-to-8
  • feat/deploy-pkg
  • feat/domain-events
  • feat/domain-events-mqtt-pre
  • feat/mig-fastapi
  • feat/mqtt-event-driven
  • feat/optimized-import
  • json-patch-route
  • master
  • metabase-schema-sync
  • pages
  • remove-sapper
  • v0.1.1
  • v0.1.10
  • v0.1.11
  • v0.1.12
  • v0.1.13
  • v0.1.14
  • v0.1.15
  • v0.1.16
  • v0.1.17
  • v0.1.18
  • v0.1.19
  • v0.1.2
  • v0.1.20
  • v0.1.21
  • v0.1.3
  • v0.1.4
  • v0.1.5
  • v0.1.6
  • v0.1.7
  • v0.1.8
  • v0.1.9
  • v0.10.0
  • v0.10.1
  • v0.10.10
  • v0.10.11
  • v0.10.12
  • v0.10.13
  • v0.10.2
  • v0.10.3
  • v0.10.4
  • v0.10.5
  • v0.10.6
  • v0.10.7
  • v0.10.8
  • v0.10.9
  • v0.11.0
  • v0.11.1
  • v0.12.0
  • v0.12.1
  • v0.12.2
  • v0.12.3
  • v0.12.4
  • v0.13.0
  • v0.13.1
  • v0.13.2
  • v0.14.0
  • v0.14.1
  • v0.15.0
  • v0.16.0
  • v0.17.0
  • v0.18.0
  • v0.19.0
  • v0.2.1
  • v0.2.10
  • v0.2.11
  • v0.2.12
  • v0.2.13
  • v0.2.14
  • v0.2.15
  • v0.2.16
  • v0.2.17
  • v0.2.18
  • v0.2.19
  • v0.2.2
  • v0.2.20
  • v0.2.21
  • v0.2.22
  • v0.2.23
  • v0.2.24
  • v0.2.25
  • v0.2.26
  • v0.2.27
  • v0.2.28
  • v0.2.29
  • v0.2.3
  • v0.2.30
  • v0.2.31
  • v0.2.32
  • v0.2.4
  • v0.2.5
  • v0.2.6
  • v0.2.7
  • v0.2.8
  • v0.2.9
  • v0.20.0
  • v0.20.1
  • v0.20.2
  • v0.21.0
  • v0.21.1
  • v0.21.2
  • v0.21.3
  • v0.22.0
  • v0.23.0
  • v0.23.1
  • v0.23.2
  • v0.24.0
  • v0.24.1
  • v0.24.2
  • v0.24.3
  • v0.25.0
114 results

Target

Select target project
  • getanthill/datastore
  • jeremylvln/datastore
2 results
Select Git revision
Show changes
Commits on Source (2)
## [0.85.1](https://gitlab.com/getanthill/datastore/compare/v0.85.0...v0.85.1) (2024-05-30)
### Bug Fixes
* **walk:** order equals in time events ad entities by version ([cce0718](https://gitlab.com/getanthill/datastore/commit/cce0718a08f2b9b84d8fea1841c8360457eb7175))
# [0.85.0](https://gitlab.com/getanthill/datastore/compare/v0.84.0...v0.85.0) (2024-05-29)
......
{
"name": "@getanthill/datastore",
"version": "0.85.0",
"version": "0.85.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@getanthill/datastore",
"version": "0.85.0",
"version": "0.85.1",
"license": "MIT",
"dependencies": {
"@getanthill/api-validators": "1.3.0",
{
"name": "@getanthill/datastore",
"description": "Event-Sourced Datastore",
"version": "0.85.0",
"version": "0.85.1",
"main": "dist/sdk/index.js",
"bin": {
"datastore": "scripts/cli.js",
......
......@@ -366,6 +366,77 @@ describe('utils', () => {
),
).toEqual(-1);
});
it('returns 0 if b created is the same than a created and versions are the sames', () => {
expect(
utils.defaultWalkMultiSortHandler(
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
),
).toEqual(0);
});
it('returns 0 if b created is the same than a created and versions are both undefined', () => {
expect(
utils.defaultWalkMultiSortHandler(
{
created_at: '2020-01-01T00:00:00.000Z',
},
{
created_at: '2020-01-01T00:00:00.000Z',
},
),
).toEqual(0);
});
it('returns -1 if b created is the same than a created and a version is undefined', () => {
expect(
utils.defaultWalkMultiSortHandler(
{
created_at: '2020-01-01T00:00:00.000Z',
},
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
),
).toEqual(-1);
});
it('returns 1 if b created is the same than a created and b version is undefined', () => {
expect(
utils.defaultWalkMultiSortHandler(
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
{
created_at: '2020-01-01T00:00:00.000Z',
},
),
).toEqual(1);
});
it('returns -1 if b created is the same than a created and b version is greater than a version', () => {
expect(
utils.defaultWalkMultiSortHandler(
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
{
created_at: '2020-01-01T00:00:00.000Z',
version: 2,
},
),
).toEqual(-1);
});
});
describe('#sortResults', () => {
......@@ -389,7 +460,31 @@ describe('utils', () => {
]);
});
it('sorts entities with a defined sort handleer', () => {
it('sorts entities on the same instant by version', () => {
expect(
utils.sortResults([
{
created_at: '2020-01-01T00:00:00.000Z',
version: 2,
},
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
]),
).toEqual([
{
created_at: '2020-01-01T00:00:00.000Z',
version: 1,
},
{
created_at: '2020-01-01T00:00:00.000Z',
version: 2,
},
]);
});
it('sorts entities with a defined sort handler', () => {
expect(
utils.sortResults(
[
......
......@@ -89,9 +89,14 @@ export function objToJsonSchema(obj: Any): JSONSchemaType<Any> {
}
export function defaultWalkMultiSortHandler(a: any, b: any) {
return (a.updated_at ?? a.created_at).localeCompare(
b.updated_at ?? b.created_at,
);
const aComparisonDate = a.updated_at ?? a.created_at;
const bComparisonDate = b.updated_at ?? b.created_at;
const dateComparisonValue = aComparisonDate.localeCompare(bComparisonDate);
return dateComparisonValue === 0
? (a.version ?? 0).toFixed(0).localeCompare((b.version ?? 0).toFixed(0))
: dateComparisonValue;
}
export function sortResults(
......