-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a68134
commit c840bb2
Showing
23 changed files
with
428 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {AppodealApp} from 'core/appdeal-api/interfaces/appodeal-app.interface'; | ||
import {Sync} from 'core/sync-apps/sync'; | ||
import {SyncRunner} from 'core/sync-apps/sync.service'; | ||
|
||
|
||
export type AppInfo = Pick<AppodealApp, 'id'> & Pick<AppodealApp, 'name'>; | ||
|
||
|
||
export interface SyncInfo { | ||
readonly id: string; | ||
readonly startTs: number | ||
readonly endTs: number; | ||
readonly terminated: boolean; | ||
readonly hasErrors: boolean; | ||
// if only some apps where synced | ||
readonly partialSync: boolean; | ||
affectedApps: { | ||
created: AppInfo[]; | ||
updated: AppInfo[]; | ||
deleted: AppInfo[]; | ||
withErrors: AppInfo[]; | ||
}, | ||
runner: SyncRunner; | ||
logSubmitted?: boolean; | ||
} | ||
|
||
export class SyncStats { | ||
|
||
public readonly affectedApps = { | ||
created: [], | ||
updated: [], | ||
deleted: [], | ||
withErrors: [] | ||
}; | ||
|
||
public id: string; | ||
|
||
constructor (private sync: Sync) {} | ||
|
||
public startTs: number; | ||
public endTs: number; | ||
|
||
public terminated = false; | ||
public partialSync = false; | ||
|
||
start () { | ||
this.startTs = Date.now(); | ||
} | ||
|
||
end () { | ||
this.endTs = Date.now(); | ||
} | ||
|
||
appCreated (app: AppodealApp) { | ||
this.affectedApps.created.push(app); | ||
} | ||
|
||
appUpdated (app: AppodealApp) { | ||
if (this.affectedApps.created.some(v => v.id === app.id)) { | ||
return; | ||
} | ||
this.affectedApps.updated = this.affectedApps.updated.filter(v => v.id !== app.id); | ||
} | ||
|
||
appDeleted (app: AppodealApp) { | ||
this.affectedApps.deleted.push(app); | ||
} | ||
|
||
errorWhileSync (app: AppodealApp) { | ||
this.affectedApps.withErrors.push(app); | ||
} | ||
|
||
toPlainObject (): SyncInfo { | ||
return { | ||
id: this.sync.id, | ||
runner: this.sync.runner, | ||
hasErrors: this.sync.hasErrors, | ||
affectedApps: this.affectedApps, | ||
startTs: this.startTs, | ||
endTs: this.endTs, | ||
terminated: this.terminated, | ||
partialSync: this.partialSync | ||
|
||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.