Skip to content

Commit

Permalink
Fixed two issues #2053 and #2202 (#2203)
Browse files Browse the repository at this point in the history
* Fixed two issues #2053 and #2202

* Updated changelog, updated versions

* Updated core version
  • Loading branch information
bsekachev authored Sep 21, 2020
1 parent 8330015 commit a93b460
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Data is not getting cleared, even after deleting the Task from Django Admin App(<https://github.com/openvinotoolkit/cvat/issues/1925>)
- Fixed blinking message: "Some tasks have not been showed because they do not have any data" (<https://github.com/openvinotoolkit/cvat/pull/2200>)
- Fixed case when a task with 0 jobs is shown as "Completed" in UI (<https://github.com/openvinotoolkit/cvat/pull/2200>)
- Fixed use case when UI throws exception: Cannot read property 'objectType' of undefined #2053 (<https://github.com/openvinotoolkit/cvat/pull/2203>)
- Fixed use case when logs could be saved twice or more times #2202 (<https://github.com/openvinotoolkit/cvat/pull/2203>)

### Security
-
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/package-lock.json

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

2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "3.7.0",
"version": "3.7.1",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class LogWithExceptionInfo extends Log {

dump() {
let body = super.dump();
const payload = body.payload;
const { payload } = body;
const client = detect();
body = {
...body,
Expand Down
29 changes: 22 additions & 7 deletions cvat-core/src/logger-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const { LogType } = require('./enums');

const WORKING_TIME_THRESHOLD = 100000; // ms, 1.66 min

function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

class LoggerStorage {
constructor() {
this.clientID = Date.now().toString().substr(-6);
Expand All @@ -22,6 +28,7 @@ class LoggerStorage {
this.collection = [];
this.ignoreRules = {}; // by event
this.isActiveChecker = null;
this.saving = false;

this.ignoreRules[LogType.zoomImage] = {
lastLog: null,
Expand Down Expand Up @@ -146,6 +153,10 @@ LoggerStorage.prototype.log.implementation = function (logType, payload, wait) {
};

LoggerStorage.prototype.save.implementation = async function () {
while (this.saving) {
await sleep(100);
}

const collectionToSend = [...this.collection];
const lastLog = this.collection[this.collection.length - 1];

Expand All @@ -164,14 +175,18 @@ LoggerStorage.prototype.save.implementation = async function () {
const userActivityLog = logFactory(LogType.sendUserActivity, logPayload);
collectionToSend.push(userActivityLog);

await serverProxy.logs.save(collectionToSend.map((log) => log.dump()));

for (const rule of Object.values(this.ignoreRules)) {
rule.lastLog = null;
try {
this.saving = true;
await serverProxy.logs.save(collectionToSend.map((log) => log.dump()));
for (const rule of Object.values(this.ignoreRules)) {
rule.lastLog = null;
}
this.collection = [];
this.workingTime = 0;
this.lastLogTime = Date.now();
} finally {
this.saving = false;
}
this.collection = [];
this.workingTime = 0;
this.lastLogTime = Date.now();
};

module.exports = new LoggerStorage();
9 changes: 5 additions & 4 deletions cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ export function getJobAsync(
export function saveAnnotationsAsync(sessionInstance: any):
ThunkAction {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
const { filters, frame, showAllInterpolationTracks } = receiveAnnotationsParameters();
const { filters, showAllInterpolationTracks } = receiveAnnotationsParameters();

dispatch({
type: AnnotationActionTypes.SAVE_ANNOTATIONS,
Expand All @@ -1021,16 +1021,17 @@ ThunkAction {
},
});
});

const states = await sessionInstance
.annotations.get(frame, showAllInterpolationTracks, filters);
await saveJobEvent.close();
await sessionInstance.logger.log(
LogType.sendTaskInfo,
await jobInfoGenerator(sessionInstance),
);
dispatch(saveLogsAsync());

const { frame } = receiveAnnotationsParameters();
const states = await sessionInstance
.annotations.get(frame, showAllInterpolationTracks, filters);

dispatch({
type: AnnotationActionTypes.SAVE_ANNOTATIONS_SUCCESS,
payload: {
Expand Down

0 comments on commit a93b460

Please sign in to comment.