Skip to content
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

migrate app usage survey data to v3 #162

Open
wants to merge 107 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
1324a47
migrate app usage survey data to v3
anzioka Feb 16, 2022
1b51a55
remove unused imports
anzioka Feb 16, 2022
0357f19
rename
anzioka Feb 16, 2022
6c99baa
use chronicle super user principals for data query
anzioka Feb 16, 2022
d458003
create table if not exists
anzioka Feb 21, 2022
d451961
remove user ids
anzioka Feb 21, 2022
83637c5
fix gradle/aws
anzioka Feb 21, 2022
d4eecf0
super user ids
anzioka Feb 21, 2022
ebbc76a
Merge branch 'develop' into task/LATTICE-3024-migrate-app-usage-survey
anzioka Feb 21, 2022
8ff714d
use principalService
anzioka Feb 21, 2022
720ccbf
fix user id
anzioka Feb 21, 2022
687cd35
fix gradle
anzioka Feb 21, 2022
59bd08d
undo
anzioka Feb 21, 2022
27f5cca
filter out nulls
anzioka Feb 21, 2022
e90c741
check authorization
anzioka Feb 21, 2022
b9b50e0
handle case where there multiple ol.title values
anzioka Feb 22, 2022
09838eb
write to chronicle
anzioka Feb 22, 2022
bb04632
mechanic job to export participant stats
anzioka Feb 23, 2022
dcbb677
search serviceuse principals with admin role
anzioka Feb 24, 2022
2b64e5c
guard against nulls
anzioka Feb 24, 2022
6f83c87
fix NPE
anzioka Feb 24, 2022
2613d7c
check for duplicates
anzioka Feb 24, 2022
e7fb2c5
assert
anzioka Feb 24, 2022
506200b
remove unneeded
anzioka Feb 24, 2022
689ff03
format
anzioka Feb 24, 2022
2ace5e0
assert
anzioka Feb 24, 2022
13fa484
fix stuff
anzioka Feb 24, 2022
ee4efd5
check for duplicates
anzioka Feb 24, 2022
0c2dd18
use set
anzioka Feb 24, 2022
9d9fdf2
change col name
anzioka Feb 24, 2022
bf8f630
log stuff
anzioka Feb 24, 2022
1a261b7
permission stuff
anzioka Feb 24, 2022
bad2f0e
resolve duplicates
anzioka Feb 24, 2022
32caaca
super user
anzioka Feb 24, 2022
33d5aa2
unnecessary filtering
anzioka Feb 24, 2022
8d545aa
super user principal
anzioka Feb 24, 2022
21c3830
migrate org settings to studies
anzioka Feb 25, 2022
1db1937
use chronicle datasource
anzioka Feb 25, 2022
ee3ef19
remove unused
anzioka Feb 25, 2022
196364c
remove unnecessary
anzioka Feb 27, 2022
2e65736
use principal type user
anzioka Feb 27, 2022
f8967e6
optional might not exist
anzioka Feb 27, 2022
0c23f65
clean up stuff
anzioka Feb 27, 2022
4f63aef
fix sql
anzioka Feb 27, 2022
6810be1
fix sql
anzioka Feb 27, 2022
17b59e3
study id might be null
anzioka Feb 27, 2022
5b169f5
store legacy study id
anzioka Feb 27, 2022
6d22998
write study ekid
anzioka Feb 27, 2022
aa0074b
fix create table sql
anzioka Feb 27, 2022
83cf4ff
change data type
anzioka Feb 28, 2022
1f6209a
rename
anzioka Feb 28, 2022
d3dd320
fix insert
anzioka Feb 28, 2022
7cd62de
fix table definition
anzioka Feb 28, 2022
6147bc1
migrate time use diary submisssions
anzioka Feb 27, 2022
95865df
add bean to pod
anzioka Mar 2, 2022
d4e5828
fix
anzioka Mar 2, 2022
6f3ec4b
add time use diary component
anzioka Mar 4, 2022
de04d28
duzz
anzioka Mar 4, 2022
d694fcc
Merge branch 'develop' into task/migrate-tud-submissions-v2
anzioka Mar 4, 2022
1aa8dc4
export summarized time use diary data
anzioka Mar 4, 2022
010962a
add to pod
anzioka Mar 4, 2022
ab14af5
add logging
anzioka Mar 4, 2022
7d79cc5
fix
anzioka Mar 4, 2022
e057a62
log dates
anzioka Mar 4, 2022
a48e61f
missing fqn from association entity
anzioka Mar 4, 2022
2e5431f
check for nulls
anzioka Mar 4, 2022
b9445bd
fix filtered search
anzioka Mar 4, 2022
4abdb82
fix sql
anzioka Mar 4, 2022
f39d4cf
import preprocessed data
anzioka Mar 5, 2022
5ec9461
fix sql
anzioka Mar 6, 2022
fba0e09
fix
anzioka Mar 6, 2022
a4cfe94
type double
anzioka Mar 6, 2022
c688aa2
nullable
anzioka Mar 6, 2022
ee58cf1
clean up
anzioka Mar 6, 2022
9e27d88
whattt
anzioka Mar 6, 2022
14efcff
more npe
anzioka Mar 6, 2022
9c6d73b
fix
anzioka Mar 6, 2022
d58694a
filter out nulls
anzioka Mar 6, 2022
8bd24b7
Merge branch 'develop' into task/LATTICE-3024-migrate-app-usage-survey
anzioka Mar 9, 2022
0c4f398
Merge branch 'task/migrate-tud-summarized-data' into task/LATTICE-302…
anzioka Mar 9, 2022
f194a4e
Merge branch 'task/LATTICE-3061-export-org-settings-to-v3_studies' in…
anzioka Mar 9, 2022
a1c4d4e
rename
anzioka Mar 9, 2022
5540987
Merge branch 'task/LATTICE-3072-migrate-participant-stats' into task/…
anzioka Mar 9, 2022
677cee8
Merge branch 'task/migrate-tud-submissions-v2' into task/LATTICE-3024…
anzioka Mar 9, 2022
c41e97a
fix conflicts
anzioka Mar 9, 2022
89998ee
rename
anzioka Mar 9, 2022
fbba417
rename tables
anzioka Mar 9, 2022
da96e63
table DNE
anzioka Mar 9, 2022
62a4c20
write users to chronicle
anzioka Mar 10, 2022
2f90771
chronicle super user principal
anzioka Mar 10, 2022
1f2fa8d
conflict
anzioka Mar 10, 2022
3ad03cf
batch processing
anzioka Mar 10, 2022
a8e618a
log
anzioka Mar 10, 2022
5964fa0
batch size
anzioka Mar 10, 2022
33fbd31
log
anzioka Mar 10, 2022
c4f9bd8
log
anzioka Mar 10, 2022
535ffbd
filter out invalid configs
anzioka Mar 10, 2022
7c96721
invalid stuff
anzioka Mar 10, 2022
e9dd402
log
anzioka Mar 10, 2022
5bafeb6
dont hold stuff in memory
anzioka Mar 10, 2022
d81dc8a
add batch
anzioka Mar 10, 2022
43a15a6
close connection
anzioka Mar 10, 2022
b7a66a6
pass hds
anzioka Mar 10, 2022
4f63272
Merge branch 'task/migrate-preprocessed-data' into task/LATTICE-3024-…
anzioka Mar 10, 2022
dffe874
select all participants
anzioka Mar 12, 2022
ccc0f97
filter out null stuff
anzioka Mar 12, 2022
c282d7c
fix
anzioka Mar 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ import com.openlattice.linking.PostgresLinkingFeedbackService
import com.openlattice.linking.graph.PostgresLinkingQueryService
import com.openlattice.mechanic.MechanicCli.Companion.UPGRADE
import com.openlattice.mechanic.Toolbox
import com.openlattice.mechanic.upgrades.DeleteOrgMetadataEntitySets
import com.openlattice.mechanic.upgrades.ExportOrganizationMembers
import com.openlattice.mechanic.upgrades.MigrateChronicleSystemApps
import com.openlattice.mechanic.upgrades.V3StudyMigrationUpgrade
import com.openlattice.mechanic.upgrades.*
import com.openlattice.organizations.roles.HazelcastPrincipalService
import com.openlattice.organizations.roles.SecurePrincipalsManager
import com.openlattice.postgres.PostgresTable
Expand Down Expand Up @@ -373,9 +370,10 @@ class MechanicUpgradePod {

@Bean
fun exportOrganizationMembers(): ExportOrganizationMembers {
return ExportOrganizationMembers(toolbox, hikariDataSource, principalService(), hazelcastInstance)
return ExportOrganizationMembers(toolbox, hikariDataSource, principalService(), hazelcastInstance, rhizomeConfiguration)
}

@Bean
fun migrateChronicleSystemApps(): MigrateChronicleSystemApps {
return MigrateChronicleSystemApps(
toolbox,
Expand All @@ -385,6 +383,78 @@ class MechanicUpgradePod {
)
}

@Bean
fun migrateAppUsageSurveyData(): MigrateAppUsageSurveyData {
return MigrateAppUsageSurveyData(
toolbox,
rhizomeConfiguration,
authorizationService(),
principalService(),
searchService(),
dataQueryService(),
entitySetService()
)
}

@Bean
fun migrateTimeUseDiarySummarizedData(): MigrateTimeUseDiarySummarizedData {
return MigrateTimeUseDiarySummarizedData(
toolbox,
rhizomeConfiguration,
principalService(),
searchService(),
dataQueryService(),
entitySetService()
)
}

@Bean
fun migrateOrgSettingsToStudies(): MigrateOrgSettingsToStudies {
return MigrateOrgSettingsToStudies(
toolbox,
entitySetService(),
rhizomeConfiguration,
dataQueryService()
)
}

@Bean
fun migrateChronicleParticipantStats(): MigrateChronicleParticipantStats {
return MigrateChronicleParticipantStats(
toolbox,
searchService(),
principalService(),
entitySetService(),
dataQueryService(),
rhizomeConfiguration,
authorizationService()
)
}

@Bean
fun migrateTudSubmissions(): MigrateTimeUseDiarySubmissions {
return MigrateTimeUseDiarySubmissions(
toolbox,
rhizomeConfiguration,
dataQueryService(),
entitySetService(),
searchService(),
principalService()
)
}

@Bean
fun migratePreprocessedData() : MigratePreprocessedData {
return MigratePreprocessedData(
toolbox,
rhizomeConfiguration,
dataQueryService(),
entitySetService(),
searchService(),
principalService()
)
}

@PostConstruct
fun post() {
Principals.init(principalService(), hazelcastInstance)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.openlattice.mechanic.upgrades

import com.geekbeast.rhizome.configuration.RhizomeConfiguration
import com.hazelcast.core.HazelcastInstance
import com.openlattice.hazelcast.HazelcastMap
import com.openlattice.mechanic.Toolbox
import com.openlattice.organizations.roles.SecurePrincipalsManager
import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
import org.slf4j.LoggerFactory

Expand All @@ -15,12 +17,13 @@ class ExportOrganizationMembers(
private val toolbox: Toolbox,
private val hds: HikariDataSource,
private val principalService: SecurePrincipalsManager,
hazelcast :HazelcastInstance
hazelcast :HazelcastInstance,
private val rhizomeConfiguration: RhizomeConfiguration
) : Upgrade {
companion object {
private const val USERS_EXPORT_TABLE_NAME = "users_export"
const val USERS_EXPORT_TABLE = """
CREATE TABLE $USERS_EXPORT_TABLE_NAME (
CREATE TABLE IF NOT EXISTS $USERS_EXPORT_TABLE_NAME (
organization_id uuid,
principal_id text NOT NULL,
principal_email text,
Expand All @@ -36,11 +39,16 @@ class ExportOrganizationMembers(
private val organizations = HazelcastMap.ORGANIZATIONS.getMap(hazelcast)
private val users = HazelcastMap.USERS.getMap(hazelcast)

private fun getDatasource(): HikariDataSource {
val (hikariConfiguration) = rhizomeConfiguration.datasourceConfigurations["chronicle"]!!
val hc = HikariConfig(hikariConfiguration)
return HikariDataSource(hc)
}
override fun upgrade(): Boolean {
val organizationsIds = organizations.keys.toMutableSet()
val members = principalService.getOrganizationMembers(organizationsIds)

hds.connection.use { connection ->
getDatasource().connection.use { connection ->
connection.createStatement().use { stmt -> stmt.execute(USERS_EXPORT_TABLE) }
connection.prepareStatement(INSERT_USER_SQL).use { ps ->
members.forEach { (orgId, orgMembers) ->
Expand Down
Loading