Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f987f3
commit 5fadb08
Showing
9 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import BaseModel from '../base/BaseModel' | ||
import types from '../fieldTypes' | ||
import tableNames from '../tables' | ||
import { USER_SEARCH_LOG } from '../constants' | ||
import { permissionAuthorizers } from '../../utils/authorization-helpers' | ||
|
||
/* | ||
* @extends BaseModel | ||
*/ | ||
class UserSearchLog extends BaseModel { | ||
static get name() { | ||
return USER_SEARCH_LOG | ||
} | ||
|
||
static get hashKey() { | ||
return 'userId' | ||
} | ||
|
||
static get rangeKey() { | ||
return 'timestamp' | ||
} | ||
|
||
static get tableName() { | ||
return tableNames.userSearchLog | ||
} | ||
|
||
static get schema() { | ||
return { | ||
userId: types.string().required(), | ||
timestamp: types | ||
.string() | ||
.isoDate() | ||
.required(), | ||
source: types.string(), | ||
} | ||
} | ||
|
||
static get permissions() { | ||
return { | ||
create: permissionAuthorizers.userIdMatchesHashKey, | ||
} | ||
} | ||
} | ||
|
||
UserSearchLog.register() | ||
|
||
export default UserSearchLog |
39 changes: 39 additions & 0 deletions
39
graphql/database/users/__tests__/UserSearchLogModel.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-env jest */ | ||
|
||
import tableNames from '../../tables' | ||
import UserSearchLogModel from '../UserSearchLogModel' | ||
import { permissionAuthorizers } from '../../../utils/authorization-helpers' | ||
|
||
jest.mock('../../databaseClient') | ||
|
||
describe('UserSearchLogModel', () => { | ||
it('implements the name property', () => { | ||
expect(UserSearchLogModel.name).toBe('UserSearchLog') | ||
}) | ||
|
||
it('implements the hashKey property', () => { | ||
expect(UserSearchLogModel.hashKey).toBe('userId') | ||
}) | ||
|
||
it('implements the tableName property', () => { | ||
expect(UserSearchLogModel.tableName).toBe(tableNames.userSearchLog) | ||
}) | ||
|
||
it('has the correct get permission', () => { | ||
expect(UserSearchLogModel.permissions.get).toBeUndefined() | ||
}) | ||
|
||
it('has the correct getAll permission', () => { | ||
expect(UserSearchLogModel.permissions.getAll).toBeUndefined() | ||
}) | ||
|
||
it('has the correct update permission', () => { | ||
expect(UserSearchLogModel.permissions.update).toBeUndefined() | ||
}) | ||
|
||
it('has the correct create permission', () => { | ||
expect(UserSearchLogModel.permissions.create).toBe( | ||
permissionAuthorizers.userIdMatchesHashKey | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters