Skip to content

Commit 4d1d36f

Browse files
authored
Merge pull request #162 from adhocteam/js-145-activity-report-display-id
Add displayId virtual field to activity reports
2 parents 6f2a3f4 + aa27c05 commit 4d1d36f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docs/openapi/index.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ components:
2424
properties:
2525
id:
2626
type: number
27+
displayId:
28+
type: string
29+
description: >
30+
A human readable report ID, of the form `R[Region]-AR-[ID]`. A report with
31+
the ID of 20 in region 8 would have a displayId of `R08-AR-20`
2732
userId:
2833
type: number
2934
description: The id of the author of the report

src/models/activityReport.js

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export default (sequelize, DataTypes) => {
3838
}
3939
}
4040
ActivityReport.init({
41+
displayId: {
42+
type: DataTypes.VIRTUAL,
43+
get() {
44+
return `R${this.regionId.toString().padStart(2, '0')}-AR-${this.id}`;
45+
},
46+
},
4147
userId: {
4248
type: DataTypes.INTEGER,
4349
},

0 commit comments

Comments
 (0)