Skip to content

Commit

Permalink
fix: Renames Curatr to Stream (#1476 - [LL-217](https://learningpool.…
Browse files Browse the repository at this point in the history
  • Loading branch information
cbishopvelti authored Mar 9, 2020
1 parent ebd9561 commit 5db0c98
Show file tree
Hide file tree
Showing 63 changed files with 345 additions and 198 deletions.
38 changes: 38 additions & 0 deletions cli/src/commands/migrateCuratrDashboardsToStream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import logger from 'lib/logger';
import Dashboard from 'lib/models/dashboard';

export const renameCuratrDashboardsToStream = async () => {
try {
const dashboards = await Dashboard.find(
{
title: { $regex: 'Curatr', $options: 'g' }
}
);

for (const dashboard of dashboards) {
dashboard.title = dashboard.title.replace('Curatr', 'Stream');

await dashboard.save();
}
} catch (error) {
logger.error(error);
}
};

export const renameStreamDashboardsToCuratr = async () => {
try {
const dashboards = await Dashboard.find(
{
title: { $regex: 'Stream', $options: 'g' }
}
);

for (const dashboard of dashboards) {
dashboard.title = dashboard.title.replace('Stream', 'Curatr');

await dashboard.save();
}
} catch (error) {
logger.error(error);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { invert } from 'lodash';

import Visualisation from 'lib/models/visualisation';
import logger from 'lib/logger';

// Old name constants
const TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT = 'TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT';
const TEMPLATE_CURATR_COMMENT_COUNT = 'TEMPLATE_CURATR_COMMENT_COUNT';
const TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB = 'TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB';
const TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD = 'TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD';
const TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS = 'TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS';
const TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS = 'TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS';

// New name constants
const TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT = 'TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT';
const TEMPLATE_STREAM_COMMENT_COUNT = 'TEMPLATE_STREAM_COMMENT_COUNT';
const TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB = 'TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB';
const TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD = 'TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD';
const TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS = 'TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS';
const TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS = 'TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS';

const oldToNewRenameMap = {
[TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT]: TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT,
[TEMPLATE_CURATR_COMMENT_COUNT]: TEMPLATE_STREAM_COMMENT_COUNT,
[TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB]: TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB,
[TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD]: TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD,
[TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS]: TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS,
[TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS]: TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS
};

const newToOldRenameMap = invert(oldToNewRenameMap);

export const renameCuratrTemplateTypesToStream = async () => {
try {
const visualisations = await Visualisation.find(
{
type: { $in: Object.keys(oldToNewRenameMap) }
}
);

for (const visualisation of visualisations) {
visualisation.type = oldToNewRenameMap[visualisation.type];

await visualisation.save();
}
} catch (error) {
logger.error(error);
}
};

export const renameStreamTemplateTypesToCuratr = async () => {
try {
const visualisations = await Visualisation.find(
{
type: { $in: Object.keys(newToOldRenameMap) }
}
);

for (const visualisation of visualisations) {
visualisation.type = newToOldRenameMap[visualisation.type];

await visualisation.save();
}
} catch (error) {
logger.error(error);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
renameCuratrTemplateTypesToStream,
renameStreamTemplateTypesToCuratr
} from 'cli/commands/migrateCuratrVisualisationTemplateTypesToStream';

const up = async () => {
await renameCuratrTemplateTypesToStream();
};

const down = async () => {
await renameStreamTemplateTypesToCuratr();
};

export default { up, down };
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
renameCuratrDashboardsToStream,
renameStreamDashboardsToCuratr
} from 'cli/commands/migrateCuratrDashboardsToStream';


const up = async () => {
await renameCuratrDashboardsToStream();
};

const down = async () => {
await renameStreamDashboardsToCuratr();
};

export default { up, down };
7 changes: 6 additions & 1 deletion cli/src/commands/v2-migrations/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OrderedMap } from 'immutable';

import commonIndexesMigration from './20171122100800_common_indexes';
import updateRefs from './20171121153300_update_refs';
import expiration from './20180212_expiration';
Expand All @@ -13,6 +14,8 @@ import migrateResetTokens from './20190509000000_migrate_null_resetTokens';
import fixTypoLast1Years from './20190627000000_fix_typo_last_1_years';
import personaImports from './20190711090000_persona_imports';
import migrateVizTypesOfTemplates from './20190719000000_migrate_viz_types_of_templates';
import renameCuratrVisTplTypesToStream from './20200227000000_rename_curatr_vis_tpl_types_to_stream';
import renameCuratrDashboardsToStream from './20200228000000_rename_curatr_dashboards_to_stream';

export default new OrderedMap()
.set('20171122100800_common_indexes', commonIndexesMigration)
Expand All @@ -28,4 +31,6 @@ export default new OrderedMap()
.set('20190509000000_migrate_null_resetTokens', migrateResetTokens)
.set('20190711090000_persona_imports', personaImports)
.set('20190627000000_fix_typo_last_1_years', fixTypoLast1Years)
.set('20190719000000_migrate_viz_types_of_templates', migrateVizTypesOfTemplates);
.set('20190719000000_migrate_viz_types_of_templates', migrateVizTypesOfTemplates)
.set('20200227000000_rename_curatr_vis_tpl_types_to_stream', renameCuratrVisTplTypesToStream)
.set('20200228000000_rename_curatr_dashboards_to_stream', renameCuratrDashboardsToStream);
13 changes: 7 additions & 6 deletions lib/constants/visualise.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export const TEMPLATE_MOST_ACTIVE_PEOPLE = 'TEMPLATE_MOST_ACTIVE_PEOPLE';
export const TEMPLATE_MOST_POPULAR_ACTIVITIES = 'TEMPLATE_MOST_POPULAR_ACTIVITIES';
export const TEMPLATE_MOST_POPULAR_VERBS = 'TEMPLATE_MOST_POPULAR_VERBS';
export const TEMPLATE_WEEKDAYS_ACTIVITY = 'TEMPLATE_WEEKDAYS_ACTIVITY';
export const TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT = 'TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT';
export const TEMPLATE_CURATR_COMMENT_COUNT = 'TEMPLATE_CURATR_COMMENT_COUNT';
export const TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB = 'TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB';
export const TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD = 'TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD';
export const TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS = 'TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS';
export const TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS = 'TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS';
export const TEMPLATE_LEARNING_EXPERIENCE_TYPE = 'TEMPLATE_LEARNING_EXPERIENCE_TYPE';

export const TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT = 'TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT';
export const TEMPLATE_STREAM_COMMENT_COUNT = 'TEMPLATE_STREAM_COMMENT_COUNT';
export const TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB = 'TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB';
export const TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD = 'TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD';
export const TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS = 'TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS';
export const TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS = 'TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS';
24 changes: 12 additions & 12 deletions ui/src/components/VisualiseIcon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {
TEMPLATE_MOST_POPULAR_ACTIVITIES,
TEMPLATE_MOST_POPULAR_VERBS,
TEMPLATE_WEEKDAYS_ACTIVITY,
TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT,
TEMPLATE_CURATR_COMMENT_COUNT,
TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB,
TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD,
TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS,
TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS,
TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT,
TEMPLATE_STREAM_COMMENT_COUNT,
TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB,
TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD,
TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS,
TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS,
TEMPLATE_LEARNING_EXPERIENCE_TYPE,
} from 'lib/constants/visualise';
import {
Expand Down Expand Up @@ -84,19 +84,19 @@ const getImageSrc = (type, sourceView) => {
case TEMPLATE_MOST_ACTIVE_PEOPLE:
case TEMPLATE_MOST_POPULAR_ACTIVITIES:
case TEMPLATE_MOST_POPULAR_VERBS:
case TEMPLATE_CURATR_USER_ENGAGEMENT_LEADERBOARD:
case TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS:
case TEMPLATE_STREAM_USER_ENGAGEMENT_LEADERBOARD:
case TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS:
return LEADERBOARD_GREY_IMAGE;
case TEMPLATE_LEARNING_EXPERIENCE_TYPE:
return LEADERBOARD_GREY_IMAGE;
case XVSY:
return XVSY_IMAGE;
case TEMPLATE_CURATR_INTERACTIONS_VS_ENGAGEMENT:
case TEMPLATE_STREAM_INTERACTIONS_VS_ENGAGEMENT:
return XVSY_GREY_IMAGE;
case STATEMENTS:
return STATEMENTS_IMAGE;
case TEMPLATE_WEEKDAYS_ACTIVITY:
case TEMPLATE_CURATR_LEARNER_INTERACTIONS_BY_DATE_AND_VERB:
case TEMPLATE_STREAM_LEARNER_INTERACTIONS_BY_DATE_AND_VERB:
return STATEMENTS_GREY_IMAGE;
case FREQUENCY:
return FREQUENCY_IMAGE;
Expand All @@ -105,11 +105,11 @@ const getImageSrc = (type, sourceView) => {
case COUNTER:
return COUNTER_IMAGE;
case TEMPLATE_LAST_7_DAYS_STATEMENTS:
case TEMPLATE_CURATR_COMMENT_COUNT:
case TEMPLATE_STREAM_COMMENT_COUNT:
return COUNTER_GREY_IMAGE;
case PIE:
return PIE_IMAGE;
case TEMPLATE_CURATR_PROPORTION_OF_SOCIAL_INTERACTIONS:
case TEMPLATE_STREAM_PROPORTION_OF_SOCIAL_INTERACTIONS:
return PIE_GREY_IMAGE;
default:
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { connect } from 'react-redux';
import { withProps, compose, withHandlers } from 'recompose';
import { loggedInUserId } from 'ui/redux/modules/auth';
import { activeOrgIdSelector } from 'ui/redux/modules/router';
import { CREATE_CURATR_STARTER } from 'ui/redux/modules/dashboard/curatrStarter';
import iconImage from './assets/curatr-starter.png';
import { CREATE_STREAM_STARTER } from 'ui/redux/modules/dashboard/streamStarter';
import iconImage from './assets/stream-starter.png';
import TemplateCard from './TemplateCard';

const enhance = compose(
withProps({
title: 'Curatr Starter',
title: 'Stream Starter',
image: iconImage,
}),
connect(
Expand All @@ -17,21 +17,21 @@ const enhance = compose(
organisationId: activeOrgIdSelector(state)
}),
dispatch => ({
createCuratrStarter: ({ userId, organisationId }) => dispatch({
createStreamStarter: ({ userId, organisationId }) => dispatch({
dispatch,
type: CREATE_CURATR_STARTER,
type: CREATE_STREAM_STARTER,
userId,
organisationId,
})
})
),
withHandlers({
onSelect: ({ userId, organisationId, createCuratrStarter }) => () => {
createCuratrStarter({ userId, organisationId });
onSelect: ({ userId, organisationId, createStreamStarter }) => () => {
createStreamStarter({ userId, organisationId });
}
}),
);

const CuratrStarter = enhance(TemplateCard);
const StreamStarter = enhance(TemplateCard);

export default CuratrStarter;
export default StreamStarter;
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ui/src/containers/DashboardTemplates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import BlankDashboard from './BlankDashboard';
import CuratrStarter from './CuratrStarter';
import StreamStarter from './StreamStarter';
import GettingStarted from './GettingStarted';
import styles from './styles.css';

Expand All @@ -19,7 +19,7 @@ const DashboardTemplates = () => (

<BlankDashboard />
<GettingStarted />
<CuratrStarter />
<StreamStarter />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Map, fromJS } from 'immutable';
import { TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS } from 'lib/constants/visualise';
import { TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS } from 'lib/constants/visualise';
import { LAST_7_DAYS } from 'ui/utils/constants';
import { description } from './constants';

Expand All @@ -18,7 +18,8 @@ const filter = fromJS({
$comment: '{"criterionLabel":"B","criteriaPath":["statement","context","platform"]}',
'statement.context.platform': {
$in: [
'Curatr',
'Stream',
'Curatr'
],
},
},
Expand All @@ -32,7 +33,7 @@ const filter = fromJS({
*/
const buildModel = model =>
model
.set('type', TEMPLATE_CURATR_ACTIVITIES_WITH_MOST_COMMENTS)
.set('type', TEMPLATE_STREAM_ACTIVITIES_WITH_MOST_COMMENTS)
.set('description', description)
.set('filters', [filter])
.set('axesgroup', new Map({ optionKey: 'activities', searchString: 'Activity' }))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LEADERBOARD_GREY_IMAGE } from 'ui/components/VisualiseIcon/assets';

export const title = 'Curatr activities with most comments (last 7 days)';
export const title = 'Stream activities with most comments (last 7 days)';
export const description = 'Activities with Most Comments - Last 7 Days';
export const image = LEADERBOARD_GREY_IMAGE;
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import Editor from './Editor';
* @param {immutable.Map} props.model - visualisation model
* @param {string} props.orgTimezone
*/
const TemplateCuratrActivitiesWithMostComments = compose(
const TemplateStreamActivitiesWithMostComments = compose(
connect(
() => ({}),
{ updateModel, setInMetadata },
),
)(Editor);

TemplateCuratrActivitiesWithMostComments.propTypes = {
TemplateStreamActivitiesWithMostComments.propTypes = {
model: PropTypes.instanceOf(Map).isRequired,
orgTimezone: PropTypes.string.isRequired,
};

export default TemplateCuratrActivitiesWithMostComments;
export default TemplateStreamActivitiesWithMostComments;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Map, fromJS } from 'immutable';
import { TEMPLATE_CURATR_COMMENT_COUNT } from 'lib/constants/visualise';
import { TEMPLATE_STREAM_COMMENT_COUNT } from 'lib/constants/visualise';
import { LAST_7_DAYS } from 'ui/utils/constants';
import { description } from './constants';

Expand All @@ -18,7 +18,8 @@ const filter = fromJS({
$comment: '{"criterionLabel":"B","criteriaPath":["statement","context","platform"]}',
'statement.context.platform': {
$in: [
'Curatr',
'Stream',
'Curatr'
],
},
},
Expand All @@ -32,7 +33,7 @@ const filter = fromJS({
*/
const buildModel = model =>
model
.set('type', TEMPLATE_CURATR_COMMENT_COUNT)
.set('type', TEMPLATE_STREAM_COMMENT_COUNT)
.set('description', description)
.set('filters', [filter])
.set('axesoperator', 'uniqueCount')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { COUNTER_GREY_IMAGE } from 'ui/components/VisualiseIcon/assets';

export const title = 'Curatr comment count (last 7 days)';
export const title = 'Stream comment count (last 7 days)';
export const description = 'Comment Count - Last 7 vs Previous 7';
export const image = COUNTER_GREY_IMAGE;
Loading

0 comments on commit 5db0c98

Please sign in to comment.