Models for effort/calories in q247 plugin
``bash`
$ npm install q247-models-core
`js
const {ShanonEntropyScoreModelV2} = require("q247-my-custom-models")
const q247Event = {
gitlog: "commit 5fc617ef5ede5d7ff6ffef0ba3205afe3e2a337e\nAuthor: xxxxx xxxxx
oper: "commit",
remote: "/Users/xxxxx/Documents/Projekty/gitspace/private/grm-microservices/process",
diff: "commit 5fc617ef5ede5d7ff6ffef0ba3205afe3e2a337e\nAuthor: xxxxx xxxxx
account: "a_somecompany",
user: "xxxxx.xxxxx@somecompany.pl",
project: "4r3t7x7fj6",
id: "xj8d6c840o",
ct: 1718393469569,
decoded: {
ticket: "PWR-01",
ticketPrefix: "PWR",
commit: "commit 5fc617ef5ede5d7ff6ffef0ba3205afe3e2a337e",
author: {
name: "xxxxx xxxxx",
email: "xxxxx.xxxxx@somecompany.pl",
},
date: "Date: Sat Jun 8 18:44:46 2024 +0200",
message: "PWR-01 cleaning",
changes: [
" index.js | 5 +----",
],
changeSummary: {
raw: " 1 file changed, 1 insertion(+), 4 deletions(-)",
files: 1,
inserts: 1,
deletions: 4,
},
}
}
const model = new ShanonEntropyScoreModelV2();
const score = await model.score(q247Event);
`
Calculates effort scoring for provided gitEvent. Returns a Promise that resolves to a Score object.
| Parameter | Type | Description |
| --- | --- | --- |
| gitEvent | object | Git event object from q247 plugin |
Result of score calculation.
`js`
export interface ScoreModelCard {
name: string;
version: string;
}
export interface Score {
id: string; // score unique id
model: ScoreModelCard;
event: Event; // source event that was scored
}
export interface ScalarScore extends Score{
score: number
}
| Name | Description | Example |
| --- | --- | --- |
| "id" | Unique score id | a8sjk800js71ja |"name"
| | Name of the model used to calculate this score | ShanonEntropyScoreModelV2 |"version"
| | Version number of the model used to calculate score | w$Tsu4G |"event"
| | Source git event for which score was calculated | See Usage section for event example |"score"
| | Estimated effort required to produce source git event | 1.23 |
class/interface
`js
import { ScalarScore, ScoreModel, Event } from "q247-models-core";export class ShanonEntropyScoreModelV1 implements ScoreModel {
name = "ShanonEntropyScoreModel";
version = "1.0";
score(event: Event): Promise {
/ here goes your custom model implementation /
}
}
``