huridocs/uwazi

View on GitHub
app/api/services/informationextraction/ixmodels.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { Suggestions } from 'api/suggestions/suggestions';
import { ModelStatus } from 'shared/types/IXModelSchema';
import { IXModelType } from 'shared/types/IXModelType';
import { IXModelsModel as model } from './IXModelsModel';

export default {
  get: model.get.bind(model),
  delete: model.delete.bind(model),
  save: async (ixmodel: IXModelType) => {
    const saved = await model.save(ixmodel);
    if (ixmodel.status === ModelStatus.ready) {
      await Suggestions.setObsolete({ extractorId: saved.extractorId });
      await Suggestions.markSuggestionsWithoutSegmentation({ extractorId: saved.extractorId });
    }
    return saved;
  },
};