Skip to content

Commit

Permalink
feat: add "timestamp" field to redux storage
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Jul 19, 2024
1 parent a195efc commit d975022
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
10 changes: 7 additions & 3 deletions lib/report-builder/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export interface GuiReportBuilderResult {
tree: Tree;
skips: SkipItem[];
config: ConfigForStaticFile & {customGui: ReporterConfig['customGui']};
date: string;
timestamp: number;
apiValues?: HtmlReporterValues;
date: string;
}

export class GuiReportBuilder extends StaticReportBuilder {
Expand Down Expand Up @@ -62,13 +63,16 @@ export class GuiReportBuilder extends StaticReportBuilder {
const config = {...getConfigForStaticFile(this._reporterConfig), customGui};

this._testsTree.sortTree();
const timestamp = Date.now();

return {
tree: this._testsTree.tree,
skips: this._skips,
config,
date: new Date().toString(),
apiValues: this._apiValues
apiValues: this._apiValues,
timestamp,
// TODO: remove in next major (should use timestamp instead)
date: new Date(timestamp).toString()
};
}

Expand Down
7 changes: 6 additions & 1 deletion lib/server-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,20 @@ export interface DataForStaticFile {
skips: object[];
config: ConfigForStaticFile;
apiValues: HtmlReporter['values'];
timestamp: number;
date: string;
}

export function getDataForStaticFile(htmlReporter: HtmlReporter, pluginConfig: ReporterConfig): DataForStaticFile {
const timestamp = Date.now();

return {
skips: [],
config: getConfigForStaticFile(pluginConfig),
apiValues: htmlReporter.values,
date: new Date().toString()
timestamp,
// TODO: remove in next major (should use timestamp instead)
date: new Date(timestamp).toString()
};
}

Expand Down
6 changes: 3 additions & 3 deletions lib/static/components/controls/report-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Label } from '@gravity-ui/uikit';

class ReportInfo extends Component {
render() {
const {gui, date} = this.props;
const {gui, timestamp} = this.props;

return (
<div className="report-info">
Expand All @@ -15,13 +15,13 @@ class ReportInfo extends Component {
</Label>
{!gui && <Label qa='created-at-label' size='m' className='label'>
Created at
<div className='detail'>{date}</div>
<div className='detail'>{new Date(timestamp).toString()}</div>
</Label>}
</div>
);
}
}

export default connect(
({gui, date}) => ({gui, date})
({gui, timestamp}) => ({gui, timestamp})
)(ReportInfo);
1 change: 1 addition & 0 deletions lib/static/modules/reducers/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import actionNames from '../action-names';
import {dateToLocaleString} from '../utils';

// TODO: remove in next major (should use timestamp instead)
export default (state, action) => {
switch (action.type) {
case actionNames.INIT_GUI_REPORT:
Expand Down
4 changes: 3 additions & 1 deletion lib/static/modules/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import running from './running';
import processing from './processing';
import loading from './loading';
import gui from './gui';
import timestamp from './timestamp';
import date from './date';
import autoRun from './auto-run';
import apiValues from './api-values';
Expand Down Expand Up @@ -37,7 +38,8 @@ export default reduceReducers(
stopping,
loading,
gui,
date,
timestamp,
date, // TODO: remove in next major (should use timestamp instead)
autoRun,
apiValues,
modals,
Expand Down
17 changes: 17 additions & 0 deletions lib/static/modules/reducers/timestamp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import actionNames from '../action-names';

export default (state, action) => {
switch (action.type) {
case actionNames.INIT_GUI_REPORT:
case actionNames.INIT_STATIC_REPORT: {
const {timestamp} = action.payload;

console.log('timestamp:', timestamp);

return {...state, timestamp};
}

default:
return state;
}
};

0 comments on commit d975022

Please sign in to comment.