Skip to content

Commit

Permalink
Release 1.31.1 (#814)
Browse files Browse the repository at this point in the history
- Prevent admin portal from updating `lastAccessedAt` for tiles
  • Loading branch information
pregnantboy authored Dec 11, 2024
2 parents 16551e1 + 00875d6 commit 2d07c0d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@
"tsconfig-paths": "^4.2.0",
"type-fest": "4.10.3"
},
"version": "1.31.0"
"version": "1.31.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,43 @@ describe('get all rows query', () => {
),
).rejects.toThrow('Table not found')
})

describe('last accessed at', () => {
it('should update last accessed at for current user', async () => {
const oldLastAccessedAt = new Date().toISOString()
await TableCollaborator.query()
.patch({
lastAccessedAt: oldLastAccessedAt,
})
.where('table_id', dummyTable.id)
.andWhere('user_id', context.currentUser.id)
await getAllRows(null, { tableId: dummyTable.id }, context)
const { lastAccessedAt } = await TableCollaborator.query().findOne({
table_id: dummyTable.id,
user_id: context.currentUser.id,
})
expect(new Date(lastAccessedAt).getTime()).toBeGreaterThan(
new Date(oldLastAccessedAt).getTime(),
)
})

it('should not update last accessed at for admin operations', async () => {
context.isAdminOperation = true
const oldLastAccessedAt = new Date().toISOString()
await TableCollaborator.query()
.patch({
lastAccessedAt: oldLastAccessedAt,
})
.where('table_id', dummyTable.id)
.andWhere('user_id', context.currentUser.id)
await getAllRows(null, { tableId: dummyTable.id }, context)
const { lastAccessedAt } = await TableCollaborator.query().findOne({
table_id: dummyTable.id,
user_id: context.currentUser.id,
})
expect(new Date(lastAccessedAt).getTime()).toEqual(
new Date(oldLastAccessedAt).getTime(),
)
})
})
})
2 changes: 1 addition & 1 deletion packages/backend/src/graphql/queries/tiles/get-all-rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getAllRows: QueryResolvers['getAllRows'] = async (
.throwIfNotFound()

// update last accessed at for collaborator/table
if (!context.tilesViewKey) {
if (!context.tilesViewKey && !context.isAdminOperation) {
await table.$relatedQuery('collaborators').patch({
lastAccessedAt: new Date().toISOString(),
})
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.31.0",
"version": "1.31.1",
"scripts": {
"dev": "wait-on tcp:3000 && vite --host --force",
"build": "tsc && vite build --mode=${VITE_MODE:-prod}",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "@plumber/types",
"description": "Shared types for plumber",
"types": "./index.d.ts",
"version": "1.31.0"
"version": "1.31.1"
}

0 comments on commit 2d07c0d

Please sign in to comment.