Skip to content

Commit

Permalink
* (Bluefox/Apollon77) Add option to add comment and user info to results
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Jul 22, 2022
1 parent a2d06e4 commit 9881f05
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ This adapter saves state history in a two-staged process.
-->

## Changelog

### __WORK IN PROGRESS__
* (Apollon77) make sure getHistory works for all cases
* (Bluefox/Apollon77) Add option to add comment and user info to results

### 2.1.7 (2022-06-27)
* (Apollon77) Allow to remove a configuration value for "round" in config again

Expand Down
2 changes: 2 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Possible options:
- **from** - if *from* field should be included in answer
- **ack** - if *ack* field should be included in answer
- **q** - if *q* field should be included in answer
- **user** - if *user* field should be included in answer
- **comment** - if *c* field should be included in answer
- **addId** - if *id* field should be included in answer
- **limit** - do not return more entries than limit
- **round** - round result to number of digits after decimal point
Expand Down
9 changes: 9 additions & 0 deletions lib/getHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ function getFileData(options) {
if (options.ack) {
fileData[ii].ack = !!fileData[ii].ack;
}
if (!options.q && fileData[ii].q !== undefined) {
delete fileData[ii].q;
}
if (!options.user && fileData[ii].user !== undefined) {
delete fileData[ii].user;
}
if (!options.comment && fileData[ii].c !== undefined) {
delete fileData[ii].c;
}
if (addId) {
fileData[ii].id = options.id;
}
Expand Down
12 changes: 12 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,12 @@ function update(id, state) {
if (state.ack !== undefined) {
res[i].ack = state.ack;
}
if (state.user !== undefined) {
res[i].user = state.user;
}
if (state.c !== undefined) {
res[i].c = state.c;
}
found = true;
break;
}
Expand Down Expand Up @@ -1524,6 +1530,12 @@ function update(id, state) {
if (state.ack !== undefined) {
res[i].ack = state.ack;
}
if (state.user !== undefined) {
res[i].user = state.user;
}
if (state.c !== undefined) {
res[i].c = state.c;
}
found = true;
break;
}
Expand Down

0 comments on commit 9881f05

Please sign in to comment.