Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8dac4c6
Update survey titles and labels for clarity: reflect focus on Copilot…
MattG57 Nov 30, 2024
06fbc6e
added scrolling reasons from colleagues
MattG57 Nov 30, 2024
71497fd
Tweaks
MattG57 Nov 30, 2024
9fbfe6b
Merge branch 'main' into Nomenclature-for-Developer-Estimates-plus-Fo…
austenstone Dec 3, 2024
2e8b1c9
Add recent surveys retrieval with good reasons and kudos feature
MattG57 Dec 3, 2024
3085220
Add GitHub survey update functionality and new survey route
austenstone Dec 3, 2024
04408a3
Add kudos field to Survey model
austenstone Dec 3, 2024
8dc6e25
Refactor backend entry point, update Docker and compose configuration…
MattG57 Dec 3, 2024
1611030
Merge branch 'Nomenclature-for-Developer-Estimates-plus-Form-behavior…
MattG57 Dec 3, 2024
3d5a946
Implement member retrieval by login, enhance recent surveys query, an…
MattG57 Dec 4, 2024
5cbd8cd
Refactor chart labels and settings form, implement thousand separator…
MattG57 Dec 4, 2024
e8a2522
Remove VSCode settings, update logging level in database configuratio…
austenstone Dec 5, 2024
dfdc06e
Add Value Modeling component, update & routing change
MattG57 Dec 5, 2024
338b2f5
Refactor survey component headers, update layout styles, and enhance …
austenstone Dec 6, 2024
4b6d442
Merge branch 'Nomenclature-for-Developer-Estimates-plus-Form-behavior…
austenstone Dec 6, 2024
50fc071
Remove ThousandSeparatorPipe and SharedModule; update settings compon…
austenstone Dec 6, 2024
4e4b5d3
Fix type assertion in survey controller and service for improved type…
austenstone Dec 6, 2024
00e92ca
Refactor type assertions in survey controller and service to use Wher…
austenstone Dec 6, 2024
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
41 changes: 37 additions & 4 deletions backend/src/controllers/survey.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Survey } from '../models/survey.model.js';
import logger from '../services/logger.js';
import surveyService from '../services/survey.service.js';
import app from '../index.js';
import { Op, Sequelize } from 'sequelize';

class SurveyController {
async createSurvey(req: Request, res: Response): Promise<void> {
async updateSurveyGitHub(req: Request, res: Response): Promise<void> {
let survey: Survey;
try {
const _survey = await surveyService.updateSurvey({
Expand Down Expand Up @@ -49,14 +50,47 @@ class SurveyController {
}
}

async createSurvey(req: Request, res: Response): Promise<void> {
try {
const survey = await surveyService.createSurvey({
...req.body,
status: 'completed'
})
res.status(201).json(survey);
} catch (error) {
console.log(error);
res.status(500).json(error);
return;
}
}

async getAllSurveys(req: Request, res: Response): Promise<void> {
try {
const { org, reasonLength } = req.query;
const minReasonLength = parseInt(reasonLength as string);
const surveys = await Survey.findAll({
order: [['updatedAt', 'DESC']],
where: {
...req.query.org ? { userId: req.query.org as string } : {}
...org ? { org: org as string } : {},
...reasonLength ? {
reason: {
[Op.and]: [
Sequelize.where(Sequelize.fn('LENGTH', Sequelize.col('reason')), {
[Op.gte]: minReasonLength
})
]
}
} : {}
}
});
console.log('test', JSON.stringify({
reason: {
[Op.and]: [
{ [Op.ne]: '' },
{ [Op.gte]: minReasonLength }
]
}
}));
res.status(200).json(surveys);
} catch (error) {
res.status(500).json(error);
Expand All @@ -81,8 +115,7 @@ class SurveyController {
try {
const { id } = req.params;
// implement the other fields... possibly
const { userId, usedCopilot, percentTimeSaved, timeUsedFor } = req.body;
const [updated] = await Survey.update({ userId, usedCopilot, percentTimeSaved, timeUsedFor }, {
const [updated] = await Survey.update(req.body, {
where: { id }
});
if (updated) {
Expand Down
18 changes: 18 additions & 0 deletions backend/src/controllers/teams.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ class TeamsController {
res.status(500).json(error);
}
}

async getMemberByLogin(req: Request, res: Response): Promise<void> {
try {
const { login } = req.params;
const member = await Member.findOne({
where: { login },
attributes: ['login', 'name', 'url', 'avatar_url']
});

if (member) {
res.json(member);
} else {
res.status(404).json({ message: 'User not found' });
}
} catch (error) {
res.status(500).json(error);
}
}
}

export default new TeamsController();
6 changes: 6 additions & 0 deletions backend/src/models/survey.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type SurveyType = {
percentTimeSaved: number;
timeUsedFor: string;
reason: string;
kudos?: number;
createdAt?: Date;
updatedAt?: Date;
}
Expand All @@ -28,6 +29,7 @@ class Survey extends Model<SurveyType> {
declare percentTimeSaved: number;
declare timeUsedFor: string;
declare reason: string;
declare kudos: number;
declare createdAt: CreationOptional<Date>;
declare updatedAt: CreationOptional<Date>;

Expand Down Expand Up @@ -81,6 +83,10 @@ class Survey extends Model<SurveyType> {
type: DataTypes.INTEGER,
allowNull: true,
},
kudos: {
type: DataTypes.INTEGER,
allowNull: true
},
createdAt: DataTypes.DATE,
updatedAt: DataTypes.DATE
}, {
Expand Down
4 changes: 3 additions & 1 deletion backend/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ router.get('/', (req: Request, res: Response) => {
router.get('/survey', surveyController.getAllSurveys);
router.post('/survey', surveyController.createSurvey);
router.get('/survey/:id', surveyController.getSurveyById);
router.put('/survey/:id', surveyController.updateSurvey);
router.put('/survey/:id', surveyController.updateSurvey); // put github survey logic here
router.delete('/survey/:id', surveyController.deleteSurvey);
router.put('/survey/:id/github', surveyController.updateSurveyGitHub);

router.get('/usage', usageController.getUsage);

Expand All @@ -32,6 +33,7 @@ router.get('/seats/:id', SeatsController.getSeat);

router.get('/teams', teamsController.getAllTeams);
router.get('/members', teamsController.getAllMembers);
router.get('/members/:login', teamsController.getMemberByLogin);

router.get('/settings', settingsController.getAllSettings);
router.post('/settings', settingsController.createSettings);
Expand Down
18 changes: 18 additions & 0 deletions backend/src/services/survey.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Survey, SurveyType } from "../models/survey.model.js";
import { Op } from 'sequelize';

class SurveyService {
async createSurvey(survey: SurveyType) {
Expand All @@ -11,6 +12,23 @@ class SurveyService {
});
return await Survey.findByPk(survey.id);
}


async getRecentSurveysWithGoodReasons(minReasonLength: number): Promise<Survey[]> {
return Survey.findAll({
where: {
reason: {
[Op.and]: [
{ [Op.ne]: null },
{ [Op.ne]: '' },
{ [Op.gte]: minReasonLength }
]
}
},
order: [['updatedAt', 'DESC']],
limit: 20
});
}
}

export default new SurveyService();
44 changes: 44 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
"@angular/router": "^18.2.12",
"@octokit/types": "^13.6.1",
"canvas-confetti": "^1.9.3",
"chart.js": "^4.4.7",
"cronstrue": "^2.51.0",
"dayjs": "^1.11.13",
"highcharts": "^11.4.8",
"highcharts-angular": "^4.0.1",
"ng2-charts": "^7.0.0",
"rxjs": "~7.8.0"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { CopilotSurveyComponent } from './main/copilot/copilot-surveys/copilot-s
import { CopilotSeatComponent } from './main/copilot/copilot-seats/copilot-seat/copilot-seat.component';
import { PredictiveModelingComponent } from './main/copilot/predictive-modeling/predictive-modeling.component';
import { DatabaseComponent } from './database/database.component';
import { ValueModelingComponent } from './main/copilot/value-modeling/value-modeling.component';

export const routes: Routes = [
{ path: 'setup', component: InstallComponent },
Expand All @@ -31,9 +32,10 @@ export const routes: Routes = [
{ path: 'copilot/seats', component: CopilotSeatsComponent, title: 'Seats' },
{ path: 'copilot/seats/:id', component: CopilotSeatComponent, title: 'Seat' },
{ path: 'copilot/surveys', component: CopilotSurveysComponent, title: 'Surveys' },
{ path: 'copilot/surveys/new', component: NewCopilotSurveyComponent, title: 'New Survey' },
{ path: 'copilot/surveys/new/:id', component: NewCopilotSurveyComponent, title: 'New Survey' },
{ path: 'copilot/surveys/:id', component: CopilotSurveyComponent, title: 'Survey' },
{ path: 'copilot/predictive-modeling', component: PredictiveModelingComponent, title: 'Predictive Modeling' },
{ path: 'copilot/value-modeling', component: ValueModelingComponent, title: 'Value Modeling' },
{ path: 'settings', component: SettingsComponent, title: 'Settings' },
{ path: '', redirectTo: 'copilot', pathMatch: 'full' }
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="page-container" *ngIf="survey">
<div class="page-header">
<h1>Survey #{{ survey.id }}</h1>
<h1>Estimate of Copilot Impact #{{ survey.id }}</h1>
</div>
<mat-card appearance="outlined">
<mat-card-header>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="page-container">
<div class="page-header">
<h1>Surveys</h1>
<h1>Estimates</h1>
<span class="spacer"></span>
<!-- <p>
<p>
<a mat-flat-button color="primary" routerLink="/copilot/surveys/new">New Survey</a>
</p> -->
</p>
</div>
<app-table [data]="surveys!" [columns]="surveysColumns" [defaultSort]="{id: 'dateTime', start: 'desc', disableClear: false}" (rowClick)="onSurveyClick($event)"></app-table>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class CopilotSurveysComponent implements OnInit {
this.installationsService.currentInstallation.pipe(
takeUntil(this.installationsService.destroy$)
).subscribe(installation => {
this.copilotSurveyService.getAllSurveys(installation?.account?.login).subscribe((surveys) => {
this.copilotSurveyService.getAllSurveys({
org: installation?.account?.login
}).subscribe((surveys) => {
this.surveys = surveys;
});
});
Expand Down
Loading
Loading