From bfed22b7aef12b57c5b75ac80d502f98d0cbf8b8 Mon Sep 17 00:00:00 2001 From: Stanislav Rassokhin Date: Wed, 25 Oct 2023 22:13:32 +0400 Subject: [PATCH] delete is_manual and is_positive from annotations re #444 --- ...31025000001-delete-annotation-is-manual.js | 24 +++++++++++++++ core/_cli/seeds/30-annotations.sql | 29 +++++++++---------- core/_cli/seeds/51-detections-reviews.sql | 5 ---- core/_docs/requestBodies.json | 12 -------- core/_models/annotations/annotation.js | 10 ------- core/annotations/clustered.js | 8 ++--- core/annotations/dao/index.js | 29 ++++--------------- core/annotations/index.js | 14 +-------- core/annotations/stream.js | 22 ++------------ 9 files changed, 49 insertions(+), 104 deletions(-) create mode 100644 core/_cli/migrations/20231025000001-delete-annotation-is-manual.js delete mode 100644 core/_cli/seeds/51-detections-reviews.sql diff --git a/core/_cli/migrations/20231025000001-delete-annotation-is-manual.js b/core/_cli/migrations/20231025000001-delete-annotation-is-manual.js new file mode 100644 index 000000000..ac1c5698f --- /dev/null +++ b/core/_cli/migrations/20231025000001-delete-annotation-is-manual.js @@ -0,0 +1,24 @@ +'use strict' +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction(async transaction => { + await queryInterface.sequelize.query('DELETE FROM annotations WHERE is_manual IS TRUE;', { transaction }) + await queryInterface.removeColumn('annotations', 'is_manual', { transaction }) + await queryInterface.removeColumn('annotations', 'is_positive', { transaction }) + }) + }, + down: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction(async transaction => { + await queryInterface.addColumn('annotations', 'is_manual', { + type: Sequelize.BOOLEAN, + allowNull: false, + defaultValue: true + }, { transaction }) + await queryInterface.addColumn('annotations', 'is_positive', { + type: Sequelize.BOOLEAN, + allowNull: false, + defaultValue: true + }, { transaction }) + }) + } +} diff --git a/core/_cli/seeds/30-annotations.sql b/core/_cli/seeds/30-annotations.sql index f2c7130eb..0274389b0 100644 --- a/core/_cli/seeds/30-annotations.sql +++ b/core/_cli/seeds/30-annotations.sql @@ -21,19 +21,18 @@ with open("./50-detections.sql", "r") as f: created_at = (datetime.datetime.strptime(end, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M:%S') updated_by_id = created_by_id updated_at = created_at - is_positive = random.choice(['true', 'false']) - print(f"""INSERT INTO public.annotations (id, start, "end", frequency_min, frequency_max, classification_id, stream_id, created_by_id, created_at, updated_by_id, updated_at, is_manual, is_positive) VALUES ('{id}', '{start}', '{end}', {frequency_min}, {frequency_max}, {classification_id}, '{stream_id}', {created_by_id}, '{created_at}', {updated_by_id}, '{updated_at}', true, {is_positive});""") + print(f"""INSERT INTO public.annotations (id, start, "end", frequency_min, frequency_max, classification_id, stream_id, created_by_id, created_at, updated_by_id, updated_at) VALUES ('{id}', '{start}', '{end}', {frequency_min}, {frequency_max}, {classification_id}, '{stream_id}', {created_by_id}, '{created_at}', {updated_by_id}, '{updated_at}');""") */ -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('89098e06-d59f-455f-a90c-c0b373208d32', 'lgndfyp1enmu', 303, '2020-05-24 15:34:05.500', '2020-05-24 15:34:09.000', 2000, 7800, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('5bf7dd68-ef61-452d-bc42-e28ae1de230d', 'lgndfyp1enmu', 303, '2020-05-24 15:38:45.000', '2020-05-24 15:39:09.000', 2600, 6800, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('e309c97c-01ed-4db3-a3f2-946904c62a02', 'lgndfyp1enmu', 303, '2020-05-24 15:39:22.500', '2020-05-24 15:39:25.500', 2900, 8900, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('eda9c5c7-de13-4d5b-96bd-03ecd9158490', 'lgndfyp1enmu', 303, '2020-05-24 15:35:03.000', '2020-05-24 15:35:29.000', 1800, 8100, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('331d3d7b-1788-4ee9-8e7c-77516a280be4', 'lgndfyp1enmu', 303, '2020-05-24 19:10:53.500', '2020-05-24 19:12:05.500', 2000, 9200, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('3e426fa1-7f51-42d2-8361-b69e145f5169', 'lgndfyp1enmu', 303, '2020-05-24 19:29:00.000', '2020-05-24 19:29:16.750', 1800, 7400, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('df51db27-bf11-4b1a-9493-d7ebb572c181', 'lgndfyp1enmu', 345, '2020-05-24 15:30:45.000', '2020-05-24 15:30:59.500', 7700, 12000, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('bbcb7e6c-d09c-4845-9245-2328662eaad9', 'lgndfyp1enmu', 345, '2020-05-24 15:35:33.500', '2020-05-24 15:35:51.500', 9000, 13500, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('768d27ef-ea77-4c1e-9841-78dd5525dba8', 'ev69cht895gc', 268, '2020-05-24 12:25:05.500', '2020-05-24 12:25:14.000', 1300, 5220, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('2301646d-0654-4467-affd-9b6709be5358', 'ev69cht895gc', 268, '2020-05-24 12:28:45.000', '2020-05-24 12:28:49.000', 600, 5800, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('2301646d-0654-4467-affd-9b6709be5123', 'ev69cht895gc', 268, '2020-05-25 12:00:21.750', '2020-05-25 12:01:25.500', 900, 5900, 8, 8, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('2301646d-0654-4467-affd-9b6709be5124', 'ev69cht895gc', 353, '2020-05-25 12:15:00.000', '2020-05-25 12:15:05.000', 300, 10000, 1, 1, true, true, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); -INSERT INTO public.annotations (id, start, "end", frequency_min, frequency_max, classification_id, stream_id, created_by_id, created_at, updated_by_id, updated_at, is_manual, is_positive) VALUES ('ed8e2907-4e02-47b6-9b70-0aa75b1b1c51', '2020-10-16 04:02:25', '2020-10-16 04:02:27', 9600, 10420, 303, 'LilSjZJkRK06', 8, '2020-10-16 04:04:25', 8, '2020-10-16 04:04:25', true, true); \ No newline at end of file +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('89098e06-d59f-455f-a90c-c0b373208d32', 'lgndfyp1enmu', 303, '2020-05-24 15:34:05.500', '2020-05-24 15:34:09.000', 2000, 7800, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('5bf7dd68-ef61-452d-bc42-e28ae1de230d', 'lgndfyp1enmu', 303, '2020-05-24 15:38:45.000', '2020-05-24 15:39:09.000', 2600, 6800, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('e309c97c-01ed-4db3-a3f2-946904c62a02', 'lgndfyp1enmu', 303, '2020-05-24 15:39:22.500', '2020-05-24 15:39:25.500', 2900, 8900, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('eda9c5c7-de13-4d5b-96bd-03ecd9158490', 'lgndfyp1enmu', 303, '2020-05-24 15:35:03.000', '2020-05-24 15:35:29.000', 1800, 8100, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('331d3d7b-1788-4ee9-8e7c-77516a280be4', 'lgndfyp1enmu', 303, '2020-05-24 19:10:53.500', '2020-05-24 19:12:05.500', 2000, 9200, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('3e426fa1-7f51-42d2-8361-b69e145f5169', 'lgndfyp1enmu', 303, '2020-05-24 19:29:00.000', '2020-05-24 19:29:16.750', 1800, 7400, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('df51db27-bf11-4b1a-9493-d7ebb572c181', 'lgndfyp1enmu', 345, '2020-05-24 15:30:45.000', '2020-05-24 15:30:59.500', 7700, 12000, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('bbcb7e6c-d09c-4845-9245-2328662eaad9', 'lgndfyp1enmu', 345, '2020-05-24 15:35:33.500', '2020-05-24 15:35:51.500', 9000, 13500, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('768d27ef-ea77-4c1e-9841-78dd5525dba8', 'ev69cht895gc', 268, '2020-05-24 12:25:05.500', '2020-05-24 12:25:14.000', 1300, 5220, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('2301646d-0654-4467-affd-9b6709be5358', 'ev69cht895gc', 268, '2020-05-24 12:28:45.000', '2020-05-24 12:28:49.000', 600, 5800, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('2301646d-0654-4467-affd-9b6709be5123', 'ev69cht895gc', 268, '2020-05-25 12:00:21.750', '2020-05-25 12:01:25.500', 900, 5900, 8, 8, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, created_at, updated_at) VALUES ('2301646d-0654-4467-affd-9b6709be5124', 'ev69cht895gc', 353, '2020-05-25 12:15:00.000', '2020-05-25 12:15:05.000', 300, 10000, 1, 1, '2020-05-29 11:30:00.000', '2020-05-29 11:30:00.000'); +INSERT INTO public.annotations (id, start, "end", frequency_min, frequency_max, classification_id, stream_id, created_by_id, created_at, updated_by_id, updated_at) VALUES ('ed8e2907-4e02-47b6-9b70-0aa75b1b1c51', '2020-10-16 04:02:25', '2020-10-16 04:02:27', 9600, 10420, 303, 'LilSjZJkRK06', 8, '2020-10-16 04:04:25', 8, '2020-10-16 04:04:25'); \ No newline at end of file diff --git a/core/_cli/seeds/51-detections-reviews.sql b/core/_cli/seeds/51-detections-reviews.sql deleted file mode 100644 index 80455a0cd..000000000 --- a/core/_cli/seeds/51-detections-reviews.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('b27e9774-1df7-413f-b223-e9a20586c5fe', 'lgndfyp1enmu', 303, '2020-05-30 14:54:31', '2020-05-30 14:54:33', null, null, 13, 13, false, true, '2021-01-30 00:30:00', '2021-01-30 00:30:00'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('b27e9774-1df7-413f-b223-e9a20586c5f1', 'lgndfyp1enmu', 303, '2020-05-30 14:54:31', '2020-05-30 14:54:33', null, null, 8, 8, false, false, '2021-01-30 00:30:00', '2021-01-30 00:30:00'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('32052a89-05f0-42e0-b884-e2b0b1b1b192', 'lgndfyp1enmu', 303, '2020-05-24 18:14:05', '2020-05-24 18:14:07', null, null, 13, 13, false, false, '2021-01-30 00:30:00', '2021-01-30 00:30:00'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('32052a89-05f0-42e0-b884-e2b0b1b1b193', 'lgndfyp1enmu', 303, '2020-05-24 18:14:05', '2020-05-24 18:14:07', null, null, 8, 8, false, false, '2021-01-30 00:30:00', '2021-01-30 00:30:00'); -INSERT INTO public."annotations" (id, stream_id, classification_id, start, "end", frequency_min, frequency_max, created_by_id, updated_by_id, is_manual, is_positive, created_at, updated_at) VALUES ('32052a89-05f0-42e0-b884-e2b0b1b1b194', 'lgndfyp1enmu', 303, '2020-05-24 18:14:05', '2020-05-24 18:14:07', null, null, 1, 1, false, false, '2021-01-30 00:30:00', '2021-01-30 00:30:00'); diff --git a/core/_docs/requestBodies.json b/core/_docs/requestBodies.json index 477d38383..20feb2c4d 100644 --- a/core/_docs/requestBodies.json +++ b/core/_docs/requestBodies.json @@ -17,23 +17,11 @@ }, "frequency_min": { "type": "integer", - "description": "Required if is_manual is not provided or set to false", "example": 1530 }, "frequency_max": { "type": "integer", - "description": "Required if is_manual is not provided or set to false", "example": 4010 - }, - "is_manual": { - "type": "boolean", - "description": "An annotation which was suggested to user by a system (e.g. detection review)", - "example": true - }, - "is_positive": { - "type": "boolean", - "description": "Whether this annotation represents absence of specified classification", - "example": true } }, "required": [ diff --git a/core/_models/annotations/annotation.js b/core/_models/annotations/annotation.js index 9ff6021a4..6affd4059 100644 --- a/core/_models/annotations/annotation.js +++ b/core/_models/annotations/annotation.js @@ -31,16 +31,6 @@ module.exports = (sequelize, DataTypes) => { classification_id: { type: DataTypes.INTEGER }, - is_manual: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: true - }, - is_positive: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: true - }, created_by_id: { type: DataTypes.INTEGER, allowNull: false diff --git a/core/annotations/clustered.js b/core/annotations/clustered.js index fe35f38bf..a29eedc9f 100644 --- a/core/annotations/clustered.js +++ b/core/annotations/clustered.js @@ -102,8 +102,6 @@ router.get('/', (req, res) => { params.convert('interval').default('1d').toTimeInterval() params.convert('aggregate').default('count').toAggregateFunction() params.convert('field').default('id').isEqualToAny(models.Annotation.attributes.full) - params.convert('is_manual').optional().toBoolean() - params.convert('is_positive').optional().toBoolean() params.convert('descending').default(false).toBoolean() params.convert('limit').default(100).toInt() params.convert('offset').default(0).toInt() @@ -118,16 +116,14 @@ router.get('/', (req, res) => { throw new ForbiddenError('You do not have permission to access this stream.') } } - const { start, end, interval, aggregate, field, is_manual, is_positive, descending, limit, offset } = convertedParams // eslint-disable-line camelcase + const { start, end, interval, aggregate, field, descending, limit, offset } = convertedParams // eslint-disable-line camelcase const streamsOnlyPublic = convertedParams.streams_public const annotation = { start, end, streamId, user, - createdBy, - isManual: is_manual, - isPositive: is_positive + createdBy } return dao.timeAggregatedQuery( annotation, diff --git a/core/annotations/dao/index.js b/core/annotations/dao/index.js index fe32c4f74..b2f8ceeda 100644 --- a/core/annotations/dao/index.js +++ b/core/annotations/dao/index.js @@ -11,8 +11,6 @@ const { getAccessibleObjectsIDs, STREAM } = require('../../roles/dao') * @param {string} filters.streamId * @param {string} filters.start * @param {string} filters.end - * @param {boolean} filters.isManual Whether annotation was drawn or created as detection review - * @param {boolean} filters.isPositive Whether annotation represents absence of specified classification * @param {boolean} filters.streamsOnlyPublic * @param {object} filters.user * @param {string[]} filters.classifications @@ -26,9 +24,7 @@ async function defaultQueryOptions (filters, options = {}) { start: { [models.Sequelize.Op.gte]: moment.utc(filters.start).valueOf(), [models.Sequelize.Op.lt]: moment.utc(filters.end).valueOf() - }, - is_manual: !!filters.isManual, - ...filters.isPositive !== undefined && { is_positive: filters.isPositive } + } } if (filters.streamId !== undefined) { condition.stream_id = filters.streamId @@ -76,8 +72,6 @@ function formatFull (annotation) { * @param {string} filters.streamId * @param {string} filters.start * @param {string} filters.end - * @param {boolean} filters.isManual Whether annotation was drawn or created as detection review - * @param {boolean} filters.isPositive Whether annotation represents absence of specified classification * @param {boolean} filters.streamsOnlyPublic * @param {object} filters.user * @param {string | number} filters.streamsOnlyCreatedBy @@ -89,14 +83,6 @@ function formatFull (annotation) { */ async function query (filters, options = {}) { const queryOptions = await defaultQueryOptions(filters, options) - if (filters.isManual === false) { - queryOptions.include.push({ - as: 'created_by', - model: models.User, - attributes: models.User.attributes.lite - }) - queryOptions.attributes.push('is_positive') - } return models.Annotation.findAll(queryOptions) } @@ -106,8 +92,6 @@ async function query (filters, options = {}) { * @param {string} filters.streamId * @param {string} filters.start * @param {string} filters.end - * @param {boolean} filters.isManual Whether annotation was drawn or created as detection review - * @param {boolean} filters.isPositive Whether annotation represents absence of specified classification * @param {boolean} filters.streamsOnlyPublic * @param {object} filters.user * @param {number} filters.createdBy @@ -137,21 +121,19 @@ async function timeAggregatedQuery (filters, options = {}) { } function create (annotation) { - const { streamId, start, end, classificationId, frequencyMin, frequencyMax, userId, isManual, isPositive } = annotation + const { streamId, start, end, classificationId, frequencyMin, frequencyMax, userId } = annotation const where = { start, end, stream_id: streamId, classification_id: classificationId, - created_by_id: userId, - is_manual: isManual + created_by_id: userId } const defaults = { ...where, frequency_min: frequencyMin, frequency_max: frequencyMax, - updated_by_id: userId, - is_positive: isPositive + updated_by_id: userId } return models.Annotation.findOrCreate({ where, defaults }).spread((annotation, created) => formatFull(annotation)) } @@ -194,8 +176,7 @@ function update (annotationId, start, end, classificationId, frequencyMin, frequ frequency_min: frequencyMin, frequency_max: frequencyMax, updated_by_id: userId, - updated_at: new Date(), - ...isPositive !== undefined && { is_positive: isPositive } + updated_at: new Date() }, { transaction, silent: true }) }) }) diff --git a/core/annotations/index.js b/core/annotations/index.js index 4278c0694..0a33f1780 100644 --- a/core/annotations/index.js +++ b/core/annotations/index.js @@ -40,14 +40,6 @@ function isUuid (str) { * description: Limit results to a selected stream * in: query * type: string - * - name: is_manual - * description: Limit results to manual annotation - * in: query - * type: boolean - * - name: is_positive - * description: Limit results to a type of annotation ( true for true positive or false for false positive) - * in: query - * type: boolean * - name: limit * description: Maximum number of results to return * in: query @@ -78,16 +70,12 @@ router.get('/', (req, res) => { params.convert('end').toMomentUtc() params.convert('stream_id').optional().toString() params.convert('classifications').optional().toArray() - params.convert('is_manual').optional().toBoolean() - params.convert('is_positive').optional().toBoolean() params.convert('limit').optional().toInt() params.convert('offset').optional().toInt() return params.validate() .then(async () => { const streamId = convertedParams.stream_id - const isManual = convertedParams.is_manual - const isPositive = convertedParams.is_positive if (streamId) { const allowed = await rolesService.hasPermission(rolesService.READ, user, streamId, rolesService.STREAM) if (!allowed) { @@ -95,7 +83,7 @@ router.get('/', (req, res) => { } } const { start, end, classifications, limit, offset } = convertedParams - return dao.query({ start, end, streamId, classifications, isManual, isPositive, user }, { limit, offset }) + return dao.query({ start, end, streamId, classifications, user }, { limit, offset }) }) .then(annotations => res.json(annotations)) .catch(httpErrorHandler(req, res, 'Failed getting annotations')) diff --git a/core/annotations/stream.js b/core/annotations/stream.js index c689bd12b..1cf29c678 100644 --- a/core/annotations/stream.js +++ b/core/annotations/stream.js @@ -33,14 +33,6 @@ const { hasStreamPermission } = require('../../common/middleware/authorization/r * description: List of clasification identifiers * in: query * type: array - * - name: is_manual - * description: Limit results to manual annotation - * in: query - * type: boolean - * - name: is_positive - * description: Limit results to a type of annotation ( true for true positive or false for false positive) - * in: query - * type: boolean * - name: limit * description: Maximum number of results to return * in: query @@ -73,17 +65,13 @@ router.get('/:id/annotations', hasStreamPermission('R'), function (req, res) { params.convert('start').toMomentUtc() params.convert('end').toMomentUtc() params.convert('classifications').optional().toArray() - params.convert('is_manual').optional().toBoolean() - params.convert('is_positive').optional().toBoolean() params.convert('limit').optional().toInt() params.convert('offset').optional().toInt() return params.validate() .then(() => { - const isManual = convertedParams.is_manual - const isPositive = convertedParams.is_positive const { start, end, classifications, limit, offset } = convertedParams - return dao.query({ start, end, classifications, streamId, isManual, isPositive, user }, { limit, offset }) + return dao.query({ start, end, classifications, streamId, user }, { limit, offset }) }) .then((annotations) => res.json(annotations)) .catch(httpErrorHandler(req, res, 'Failed getting annotations')) @@ -135,13 +123,11 @@ router.post('/:id/annotations', hasStreamPermission('U'), function (req, res) { params.convert('classification').toString() params.convert('frequency_min').optional().toInt() params.convert('frequency_max').optional().toInt() - params.convert('is_manual').toBoolean().default(true) - params.convert('is_positive').toBoolean().default(true) return params.validate() .then(() => classificationService.getId(convertedParams.classification)) .then(classificationId => { - const { start, end, frequency_min, frequency_max, is_manual, is_positive } = convertedParams // eslint-disable-line camelcase + const { start, end, frequency_min, frequency_max } = convertedParams // eslint-disable-line camelcase const annotation = { streamId, classificationId, @@ -149,9 +135,7 @@ router.post('/:id/annotations', hasStreamPermission('U'), function (req, res) { start, end, frequencyMin: frequency_min, - frequencyMax: frequency_max, - isManual: is_manual, - isPositive: is_positive + frequencyMax: frequency_max } return dao.create(annotation) })