-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(meditrakApp): RN-1361: User type question #5820
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
6c5a826
Add User and Task question types
alexd-bes 961d633
Add question config types
alexd-bes 59c4333
Update types
alexd-bes a44321b
Update types
alexd-bes 5a7e102
Fix surveyCode type
alexd-bes 4d407da
WIP
alexd-bes 6d3bcab
Merge branch 'epic-tasks' into rn-1381-import-task-user-question-configs
alexd-bes 34eabb4
Ability to import config
alexd-bes f2740e4
WIP
alexd-bes 07c8dce
User permission group validation
alexd-bes 3c4bbcf
Add comment
alexd-bes 195660d
Handle exporting of questions
alexd-bes 9fae75d
Hide the task question always
alexd-bes a56b506
Handle BES admin users
alexd-bes ee81c44
Handle multiple task questions
alexd-bes b4a1a86
rename entityCode to entityId
alexd-bes 9d6c786
Generate types
alexd-bes 729f770
Add sync configs
alexd-bes d9062b8
Update permissions based sync queue for user entity permissions
alexd-bes 07777ab
Merge branch 'epic-tasks' into rn-1361-user-app-question
alexd-bes f21f031
Add user entity permissions to sync queue
alexd-bes ba8c85a
Sync user accounts
alexd-bes 88bfc26
User account syncing
alexd-bes ef1cd42
Make realm explorer scroll
alexd-bes f16abed
Fix permissions based sync queue for user entity permissions
alexd-bes 0cadc24
Add database type for user entity permission
alexd-bes f2f3965
Make separate user account model
alexd-bes 84e5347
Working question
alexd-bes ee19e7d
Fix user model usage
alexd-bes 6ffed1b
Working question with permission groups
alexd-bes e507024
Update schema.jsx
alexd-bes 93b1ea5
add comments
alexd-bes f03c8cd
Handle filtering and pagination
alexd-bes 434d655
Merge branch 'epic-tasks' into rn-1361-user-app-question
alexd-bes b826125
Use permission group id instead of name
alexd-bes 02e867b
Update filtering
alexd-bes c5febd8
PR fixes
alexd-bes 7643ecb
Add internal field to users
alexd-bes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
52 changes: 52 additions & 0 deletions
52
...tabase/src/migrations/20240730032928-AddUserEntityPermissionsToSyncQueue-modifies-data.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,52 @@ | ||
'use strict'; | ||
|
||
import { getSyncQueueChangeTime } from '@tupaia/tsutils'; | ||
import { generateId } from '../utilities/generateId'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
// Get the IDs of all user entity permissions that are not already in the sync queue | ||
const getAllUserEntityPermissionIds = async db => { | ||
const result = await db.runSql(` | ||
SELECT user_entity_permission.id FROM user_entity_permission | ||
LEFT JOIN meditrak_sync_queue on meditrak_sync_queue.record_id = user_entity_permission.id | ||
WHERE meditrak_sync_queue.id IS NULL | ||
`); | ||
return result.rows.map(row => row.id); | ||
}; | ||
|
||
exports.up = async function (db) { | ||
const userEntityPermissionIds = await getAllUserEntityPermissionIds(db); | ||
await db.runSql(` | ||
INSERT INTO meditrak_sync_queue (id, type, record_type, record_id, change_time) | ||
VALUES ${userEntityPermissionIds | ||
.map( | ||
(id, i) => | ||
// the timestamp is incremented by i to ensure that each record has a unique timestamp | ||
`('${generateId()}', 'update', 'user_entity_permission', '${id}', ${getSyncQueueChangeTime( | ||
i, | ||
)})`, | ||
) | ||
.join(',\n')}; | ||
`); | ||
}; | ||
|
||
exports.down = function (db) { | ||
return null; | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
49 changes: 49 additions & 0 deletions
49
packages/database/src/migrations/20240730033844-AddUsersToSyncQueue-modifies-data.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,49 @@ | ||
'use strict'; | ||
|
||
import { getSyncQueueChangeTime } from '@tupaia/tsutils'; | ||
import { generateId } from '../utilities/generateId'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
const getAllUserIds = async db => { | ||
const result = await db.runSql(` | ||
SELECT user_account.id FROM user_account | ||
LEFT JOIN meditrak_sync_queue ON meditrak_sync_queue.record_id = user_account.id | ||
WHERE meditrak_sync_queue.id IS NULL | ||
`); | ||
return result.rows.map(row => row.id); | ||
}; | ||
|
||
exports.up = async function (db) { | ||
const userIds = await getAllUserIds(db); | ||
await db.runSql(` | ||
INSERT INTO meditrak_sync_queue (id, type, record_type, record_id, change_time) | ||
VALUES ${userIds | ||
.map( | ||
(id, i) => | ||
// the timestamp is incremented by i to ensure that each record has a unique timestamp | ||
`('${generateId()}', 'update', 'user_account', '${id}', ${getSyncQueueChangeTime(i)})`, | ||
) | ||
.join(',\n')}; | ||
`); | ||
}; | ||
|
||
exports.down = function (db) { | ||
return null; | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is because we can get the correct model more accurately this way (e.g. for
user_account
database record type that i actually theUser
model)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good change! Tho tbh it always bothers me when our model names don't match the underlying database tables, the worst one is Facility/clinic! Tho now that we mention it, I'm surprised that table was working here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, because in the meditrak sync queue I was calling these records
user_account
, what it was doing was looking for a model calledUserAccount
which doesn't exist