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

[ENG-6625] Add report date to Institutional Dashboard Summary and Users tab #2418

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions app/institutions/dashboard/index/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@
}
}
}

.updated-at {
align-self: flex-end;
margin-right: 12px;
margin-bottom: 12px;
}
10 changes: 9 additions & 1 deletion app/institutions/dashboard/index/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<Institutions::Dashboard::-Components::InstitutionalDashboardWrapper
<Institutions::Dashboard::-Components::InstitutionalDashboardWrapper
@institution={{this.model.institution}} as |wrapper|
>
<wrapper.main local-class='main-container {{if (is-mobile) 'mobile'}}'>
{{#if this.model.summaryMetrics.reportYearmonth}}
<div
data-test-summary-report-year-month
local-class='updated-at'
>
{{t 'institutions.dashboard.updated' date=this.model.summaryMetrics.reportYearmonth}}
</div>
{{/if}}
<div local-class='kpi-container'>
<Institutions::Dashboard::-Components::TotalCountKpiWrapper
@model={{this.model}}
Expand Down
5 changes: 3 additions & 2 deletions app/institutions/dashboard/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ export default class InstitutionsDashboardRoute extends Route {
const summaryMetrics = await institution.summaryMetrics;
const userMetricInfo: QueryHasManyResult<never> = await institution.queryHasMany(
'userMetrics',
{ size: 0 },
{ size: 1 },
);
const userMetric = userMetricInfo.toArray()[0];

return {
institution,
departmentMetrics,
summaryMetrics,
totalUsers: userMetricInfo.meta.total,
userMetric,
};
} catch (error) {
captureException(error);
Expand Down
5 changes: 5 additions & 0 deletions app/institutions/dashboard/users/styles.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.panel-wrapper {
margin-top: 12px;
}

.updated-at {
float: right;
margin: 12px 12px 0 0;
}
8 changes: 8 additions & 0 deletions app/institutions/dashboard/users/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<Institutions::Dashboard::-Components::InstitutionalDashboardWrapper @institution={{this.model.institution}} as |wrapper|>
<wrapper.main>
{{#if this.model.userMetric.reportYearmonth}}
<div
data-test-user-report-year-month
local-class='updated-at'
>
{{t 'institutions.dashboard.updated' date=this.model.userMetric.reportYearmonth}}
</div>
{{/if}}
<div local-class='panel-wrapper' data-analytics-scope='Users tab'>
<Institutions::Dashboard::-Components::InstitutionalUsersList
@institution={{this.model.institution}}
Expand Down
2 changes: 1 addition & 1 deletion app/models/institution-summary-metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class InstitutionSummaryMetricModel extends OsfModel {
@attr('number') publicFileCount!: number;
@attr('number') monthlyLoggedInUserCount!: number;
@attr('number') monthlyActiveUserCount!: number;

@attr('string') reportYearmonth!: string;

get convertedStorageCount(): string {
return humanFileSize(parseFloat(this.storageByteCount.toFixed(1)));
Expand Down
1 change: 1 addition & 0 deletions app/models/institution-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class InstitutionUserModel extends OsfModel {
@attr('string') monthLastLogin!: string; // YYYY-MM
@attr('string') monthLastActive!: string; // YYYY-MM
@attr('string') accountCreationDate!: string; // YYYY-MM
@attr('string') reportYearmonth!: string;
@attr('fixstring') orcidId?: string;

@belongsTo('user', { async: true })
Expand Down
3 changes: 3 additions & 0 deletions mirage/factories/institution-summary-metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export default Factory.extend<InstitutionSummaryMetricModel>({
monthlyLoggedInUserCount() {
return faker.random.number({ min: 10, max: 100 * 100 });
},
reportYearmonth() {
return faker.date.past(1).toISOString().slice(0, 7);
},
});

declare module 'ember-cli-mirage/types/registries/schema' {
Expand Down
3 changes: 3 additions & 0 deletions mirage/factories/institution-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default Factory.extend<InstitutionUser>({
orcidId() {
return faker.random.uuid(); // Simulate an ORCID ID
},
reportYearmonth() {
return faker.date.past(1).toISOString().slice(0, 7);
},
afterCreate(institutionUser, server) {
if (!institutionUser.userName && !institutionUser.userGuid) {
const user = server.create('user');
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/institutions/dashboard-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ module(moduleName, hooks => {
// Summary tab
await percySnapshot(`${moduleName} - summary`);
assert.dom('[data-test-page-tab="summary"]').hasClass('active', 'Summary tab is active by default');
assert.dom('[data-test-summary-report-year-month]').exists('Report year month exists');

// Users tab
await click('[data-test-page-tab="users"]');
await percySnapshot(`${moduleName} - users`);
assert.dom('[data-test-page-tab="users"]').hasClass('active', 'Users tab is active');
assert.dom('[data-test-link-to-reports-archive]').exists('Link to download prior reports exists');
assert.dom('[data-test-download-dropdown]').exists('Link to download file formats');
assert.dom('[data-test-user-report-year-month]').exists('User report year month exists');

// Projects tab
await click('[data-test-page-tab="projects"]');
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ institutions:
preprints: preprints
content-placeholder: Content coming soon # Delete this eventually pls
title: '{institutionName} Dashboard'
updated: 'Updated {date}'
download_past_reports_label: 'Previous reports'
download_dropdown_label: 'Download data'
download_csv: 'Download CSV'
Expand Down
Loading