You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.1 KiB

import { AnalyticUnitId } from './analytic_unit_model';
import { Collection, makeDBQ } from '../services/data_service';
6 years ago
6 years ago
let db = makeDBQ(Collection.SEGMENTS);
6 years ago
type SegmentId = string;
6 years ago
6 years ago
export class Segment {
constructor(
public from: number,
public to: number,
public labeled: boolean,
public id?: SegmentId
) {
if(from === undefined) {
throw new Error('from is undefined');
}
if(to === undefined) {
throw new Error('to is undefined');
}
if(labeled === undefined) {
throw new Error('labeled is undefined');
}
}
public toObject() {
return {
_id: this.id,
from: this.from,
to: this.to,
labeled: this.labeled
};
}
static fromObject(obj: any): Segment {
if(obj === undefined) {
throw new Error('obj is undefined');
}
return new Segment(
obj.from, obj.to,
obj.labeled, obj.id || obj._id
);
}
6 years ago
}
6 years ago
export function getLabeled(id: AnalyticUnitId) {
//return db.
6 years ago
}
6 years ago
export function getPredicted(id: AnalyticUnitId) {
6 years ago
}
6 years ago
export async function create(segments: Segment[]) {
6 years ago
}
6 years ago
export function remove(idsToRemove: SegmentId[]) {
6 years ago
}