Browse Source

concat deleted segments

pull/1/head
amper43 6 years ago
parent
commit
4234a97475
  1. 5
      server/src/controllers/analytics_controller.ts
  2. 8
      server/src/models/segment_model.ts

5
server/src/controllers/analytics_controller.ts

@ -120,6 +120,11 @@ export async function runLearning(id: AnalyticUnit.AnalyticUnitId) {
} else {
await AnalyticUnitCache.create(id);
}
let deletedSegments = await Segment.findMany(id, { deleted: true });
let deletedSegmentsObjs = deletedSegments.map(s => s.toObject());
segmentObjs = _.concat(segmentObjs, deletedSegmentsObjs);
let task = new AnalyticsTask(
id, AnalyticsTaskType.LEARN, { pattern, segments: segmentObjs, data, cache: oldCache }
);

8
server/src/models/segment_model.ts

@ -62,7 +62,8 @@ export type FindManyQuery = {
timeFromGTE?: number,
timeToLTE?: number,
intexGT?: number,
labeled?: boolean
labeled?: boolean,
deleted?: boolean
}
export async function findMany(id: AnalyticUnitId, query: FindManyQuery): Promise<Segment[]> {
@ -76,6 +77,9 @@ export async function findMany(id: AnalyticUnitId, query: FindManyQuery): Promis
if(query.labeled !== undefined) {
dbQuery.labeled = query.labeled;
}
if(query.deleted !== undefined) {
dbQuery.deleted = query.deleted;
}
let segs = await db.findMany(dbQuery);
if(segs === null) {
return [];
@ -113,7 +117,7 @@ export async function insertSegments(segments: Segment[]) {
}
export async function setSegmentsDeleted(ids: SegmentId[]) {
return db.updateMany(ids, { deleted: true });
return db.updateMany(ids, { deleted: true, labeled: false });
}
export function removeSegments(idsToRemove: SegmentId[]) {

Loading…
Cancel
Save