diff --git a/backend/src/controllers/survey.controller.ts b/backend/src/controllers/survey.controller.ts index 8b289c7..4911e64 100644 --- a/backend/src/controllers/survey.controller.ts +++ b/backend/src/controllers/survey.controller.ts @@ -2,6 +2,7 @@ import { Request, Response } from 'express'; import { Survey } from '../models/survey.model.js'; import setup from '../services/setup.js'; import logger from '../services/logger.js'; +import settingsService from 'services/settings.service.js'; class SurveyController { async createSurvey(req: Request, res: Response): Promise { @@ -9,6 +10,7 @@ class SurveyController { const survey = await Survey.create(req.body); res.status(201).json(survey); try { + const surveyUrl = new URL(`copilot/surveys/${survey.id}`, settingsService.baseUrl); const octokit = await setup.getOctokit(); const comments = await octokit.rest.issues.listComments({ owner: survey.owner, @@ -25,7 +27,7 @@ class SurveyController { owner: survey.owner, repo: survey.repo, comment_id: comment.id, - body: `Thanks for filling out the copilot survey @${survey.userId}!` + body: `Thanks for filling out the [copilot survey](${surveyUrl.toString()}) @${survey.userId}!` }); } else { logger.info(`No comment found for survey from ${setup.installation?.slug}`) diff --git a/frontend/src/app/app.routes.ts b/frontend/src/app/app.routes.ts index 87317e7..c1b7e0b 100644 --- a/frontend/src/app/app.routes.ts +++ b/frontend/src/app/app.routes.ts @@ -30,8 +30,8 @@ export const routes: Routes = [ { path: 'copilot/seats/:id', component: CopilotSeatComponent, title: 'Seat' }, { path: 'copilot/calculator', component: CopilotCalculatorComponent, title: 'Calculator' }, { path: 'copilot/surveys', component: CopilotSurveysComponent, title: 'Surveys' }, - { path: 'copilot/surveys/:id', component: CopilotSurveyComponent, title: 'Survey' }, { path: 'copilot/surveys/new', component: NewCopilotSurveyComponent, title: 'New Survey' }, + { path: 'copilot/surveys/:id', component: CopilotSurveyComponent, title: 'Survey' }, { path: 'settings', component: SettingsComponent, title: 'Settings' }, { path: '', redirectTo: 'copilot', pathMatch: 'full' } ] diff --git a/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.html b/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.html index c2d6d93..2f753a3 100644 --- a/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.html +++ b/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.html @@ -13,7 +13,7 @@

Last Active: {{ seat.last_activity_at | date: 'medium' }}

Editor: {{ seat.last_activity_editor }}

Site Admin: {{ seat.assignee.site_admin ? 'Yes' : 'No' }}

-

Copilot Usage: {{ hoursSpent }}

+

Copilot Usage: {{ timeSpent }}

diff --git a/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.ts b/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.ts index 768d7c2..e13a76f 100644 --- a/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.ts +++ b/frontend/src/app/main/copilot/copilot-seats/copilot-seat/copilot-seat.component.ts @@ -58,7 +58,7 @@ export class CopilotSeatComponent implements OnInit { id?: number; seat?: Seat; seatActivity?: Seat[]; - hoursSpent?: string; + timeSpent?: string; constructor( private copilotSeatService: SeatService, @@ -81,13 +81,10 @@ export class CopilotSeatComponent implements OnInit { ...this.chartOptions, ...this._chartOptions }; - const totalTime = (this.chartOptions.series as Highcharts.SeriesGanttOptions[])?.reduce((acc, series) => { - return acc += series.data?.reduce((acc: number, data) => { - return acc += (data.end || 0) - (data.start || 0); - }, 0) || 0; - }, 0); - this.hoursSpent = dayjs.duration({ - milliseconds: totalTime + this.timeSpent = dayjs.duration({ + milliseconds: (this.chartOptions.series as Highcharts.SeriesGanttOptions[])?.reduce((total, series) => { + return total += series.data?.reduce((dataTotal, data) => dataTotal += (data.end || 0) - (data.start || 0), 0) || 0; + }, 0) }).humanize(); this.updateFlag = true; this.cdr.detectChanges();