Skip to content

Commit

Permalink
Merge pull request #1581 from serlo/fix-order-unrevised
Browse files Browse the repository at this point in the history
fix(unrevised): be sure new revisions come first
  • Loading branch information
hugotiburtino authored Jun 14, 2024
2 parents ea6b2de + 9d0ff75 commit 77af71c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion __tests__/schema/entity/checkout-revision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('checks out a revision', async () => {
.withVariables({ id: 26334 })
.shouldReturnData({
uuid: {
unrevisedEntities: { nodes: [{ id: 34907 }, { id: 35247 }] },
unrevisedEntities: { nodes: [{ id: 35247 }, { id: 34907 }] },
},
})

Expand Down
2 changes: 1 addition & 1 deletion __tests__/schema/entity/reject-revision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('checks out a revision', async () => {
.withVariables({ id: 26334 })
.shouldReturnData({
uuid: {
unrevisedEntities: { nodes: [{ id: 34907 }, { id: 35247 }] },
unrevisedEntities: { nodes: [{ id: 35247 }, { id: 34907 }] },
},
})

Expand Down
19 changes: 10 additions & 9 deletions __tests__/schema/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const subjects = [
{
unrevisedEntities: {
nodes: [
{ __typename: 'Article', id: 34907 },
{ __typename: 'Article', id: 35247 },
{ __typename: 'Article', id: 34907 },
],
},
},
Expand Down Expand Up @@ -93,17 +93,18 @@ test('`Subject.unrevisedEntities` shows new revisions first', async () => {
})
.execute()
const subjectsChangedOrder = [...subjects]
;(subjectsChangedOrder[4] = {
subjectsChangedOrder[4] = {
unrevisedEntities: {
nodes: [
{ __typename: 'Article', id: 35247 },
{ __typename: 'Article', id: 34907 },
{ __typename: 'Article', id: 35247 },
],
},
}),
await query.shouldReturnData({
subject: {
subjects: subjectsChangedOrder,
},
})
}

await query.shouldReturnData({
subject: {
subjects: subjectsChangedOrder,
},
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export async function resolveUnrevisedEntityIds(
entity_uuid.trashed = 0
and (entity.current_revision_id is null or
entity.current_revision_id < revision.max_revision_id)
order by max_revision_id
order by max_revision_id desc
`,
[userId, userId],
)
Expand Down

0 comments on commit 77af71c

Please sign in to comment.