Skip to content

Commit

Permalink
replicator for community_meetups (#7050)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmmrssa authored Jan 7, 2022
1 parent c10e6e0 commit acfa7ce
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions couchdb-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ DBS=(
"messages"
"course_activities"
"search_activities"
"community_meetups"
)

insert_dbs $DBS
Expand Down
13 changes: 13 additions & 0 deletions design/security-update/security-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,18 @@
"roles": ["learner"]
}
}
},
{
"dbName": "community_meetups",
"json": {
"admins": {
"names": [],
"roles": ["manager"]
},
"members": {
"names": [],
"roles": []
}
}
}
]
14 changes: 9 additions & 5 deletions src/app/configuration/configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,23 @@ export class ConfigurationService {
selector: { 'sendOnAccept': true }
};
const userReplicator = {
dbSource: '_users',
db: 'tablet_users',
dbSource: '_users', db: 'tablet_users',
selector: { 'isUserAdmin': false, 'requestId': { '$exists': false } },
continuous: true,
type: 'internal'
continuous: true, type: 'internal'
};
const meetupReplicator = {
dbSource: 'meetups', db: 'community_meetups',
selector: { 'link': { 'teams': { '$eq': `${configuration.code}@${configuration.parentCode}` } } },
continuous: true, type: 'internal'
};
return forkJoin([
// create replicator for pulling from parent at first as we do not have session
this.syncService.sync({ ...replicatorObj, db: 'courses' }, credentials),
this.syncService.sync({ ...replicatorObj, db: 'resources' }, credentials),
this.syncService.sync({ ...replicatorObj, db: 'exams' }, credentials),
this.syncService.sync({ ...replicatorObj, db: 'tags' }, credentials),
this.syncService.sync(userReplicator, credentials)
this.syncService.sync(userReplicator, credentials),
this.syncService.sync(meetupReplicator, credentials)
]);
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/manager-dashboard/sync.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class SyncDirective {
const pushList = [ ...this.pushList(), ...bothList ];
const pullList = [ ...this.pullList(), ...bothList ];
const internalList = [
{ dbSource: '_users', db: 'tablet_users', selector: { 'isUserAdmin': false, 'requestId': { '$exists': false } }, continuous: true }
{ dbSource: '_users', db: 'tablet_users', selector: { 'isUserAdmin': false, 'requestId': { '$exists': false } }, continuous: true },
{ dbSource: 'meetups', db: 'community_meetups', selector: { 'link': { 'teams': { '$eq': `${this.planetConfiguration.code}@${this.planetConfiguration.parentCode}` } } }, continuous: true }
];
return pushList.map(mapFunc('push')).concat(pullList.map(mapFunc('pull'))).concat(internalList.map(mapFunc('internal')));
}
Expand Down

0 comments on commit acfa7ce

Please sign in to comment.