Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee9b9ac095 | |||
| 2d5b5a81a5 | |||
| bb21e58582 | |||
| 8eeca803ba | |||
| 5ad715a2a6 | |||
| 8d31ba4924 | |||
| b2792207a5 | |||
| b4236b2eb7 | |||
| 4ff3d76dac | |||
| 0a6fcc8940 | |||
| b4087527a1 | |||
| 5233131f49 | |||
| 6451cca01a | |||
| dbfa941474 | |||
| 0f262eb440 | |||
| dcdb32ae9c | |||
| a1373e6fe4 | |||
| bb73e4b02b | |||
| 765e70a0e0 | |||
| 62591f9039 | |||
| 29c3cb6af0 | |||
| 9ad0b9590c | |||
| d6b17671c4 | |||
| 7795d96aad | |||
| a220885f56 | |||
| ff882328d8 | |||
| 6e98a7749a | |||
| 9c016dceb0 | |||
| ec02f84381 | |||
| 24d7138888 | |||
| c4163f1ce5 | |||
| d1e7d02a3c | |||
| 81bb8e7b98 | |||
| b822215c04 | |||
| 74e6565c27 | |||
| 0b6b551921 | |||
| ace749b742 | |||
| 75cb542795 |
@@ -1,9 +1,11 @@
|
||||
import RecordingDataMeta from '../../models/file/recording_data_meta'
|
||||
import RecordingDataRaw from '../../models/file/recording_data_raw'
|
||||
import childProcess from 'child_process'
|
||||
import path from 'path'
|
||||
import { homedir } from 'os'
|
||||
|
||||
const recordingDataMeta = new RecordingDataMeta()
|
||||
const recordingDataRaw = new RecordingDataRaw()
|
||||
|
||||
export const spikeDetect = async (ctx, next) => {
|
||||
const request = ctx.request.body
|
||||
@@ -21,9 +23,18 @@ export const spikeDetect = async (ctx, next) => {
|
||||
const result = await recordingDataMeta.getByID(metaId)
|
||||
|
||||
const channels = JSON.parse(result[0].channels)
|
||||
const sampleRate = 8e5 / result[0].parameter_set.ADC_CLOCK / channels.length
|
||||
const sampleRate = result[0].parameter_set.SAMPLE_RATE / channels.length
|
||||
const timeDuration = result[0].time_duration / 1e6
|
||||
const rawData = JSON.stringify(result[0].raw_data[channel])
|
||||
let rawData = '[]'
|
||||
if (dataType === 'filter_data') {
|
||||
rawData = JSON.stringify(result[0].raw_data[channel])
|
||||
} else if (dataType === 'filter_data_sd') {
|
||||
const uuid = result[0].uuid
|
||||
const ret = await recordingDataRaw.getSdDataAllTimeslotByUUID(uuid, channel)
|
||||
console.log(uuid)
|
||||
rawData = JSON.stringify(ret.map(r => r.id))
|
||||
}
|
||||
console.log(rawData)
|
||||
|
||||
function getPromise () {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -39,7 +50,7 @@ export const spikeDetect = async (ctx, next) => {
|
||||
'sample_rate=' + sampleRate,
|
||||
'time_duration=' + timeDuration,
|
||||
'data_type=' + dataType,
|
||||
'raw_data=' + rawData
|
||||
'raw_data=' + rawData,
|
||||
])
|
||||
|
||||
let totalString = ''
|
||||
@@ -50,11 +61,13 @@ export const spikeDetect = async (ctx, next) => {
|
||||
})
|
||||
|
||||
subprocess.stderr.on('data', (error) => {
|
||||
reject(error)
|
||||
console.error(`Error ${error}`)
|
||||
resolve(error)
|
||||
return
|
||||
})
|
||||
|
||||
subprocess.on('close', (code) => {
|
||||
console.log(totalString)
|
||||
resolve(totalString)
|
||||
console.log(`spike detect analysis process exited with code ${code}`)
|
||||
})
|
||||
@@ -63,6 +76,15 @@ export const spikeDetect = async (ctx, next) => {
|
||||
|
||||
const ret = await getPromise()
|
||||
ctx.body = ret
|
||||
const msg = ret.toString()
|
||||
const msgList = msg.split('\n')
|
||||
if (msg.startsWith('Traceback')) {
|
||||
if (msgList[msgList.length - 2].startsWith('ValueError')) {
|
||||
ctx.status = 400
|
||||
} else {
|
||||
ctx.status = 500
|
||||
}
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import RecordingDataMeta from '../../models/file/recording_data_meta'
|
||||
import * as auth from '../../controllers/auth'
|
||||
import RecordingMeta from '../../models/file/bps_recording_meta'
|
||||
|
||||
const recordingDataMeta = new RecordingDataMeta()
|
||||
const recordingMeta = new RecordingMeta() // control system 3.0
|
||||
|
||||
export const create = async (ctx, next) => {
|
||||
const data = ctx.request.body
|
||||
@@ -120,3 +122,19 @@ export const getAll = async (ctx, next) => {
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
// control system 3.0
|
||||
export const getMetaByUUID = async (ctx, next) => {
|
||||
const uuid = ctx.params.uuid
|
||||
const result = await recordingMeta.getMetaByUUID(uuid)
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export const getMetaAll = async (ctx, next) => {
|
||||
const result = await recordingMeta.getMetaAll()
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
}
|
||||
@@ -80,10 +80,21 @@ export const getDataByID = async (ctx, next) => {
|
||||
next()
|
||||
}
|
||||
|
||||
export const getSdDataByID = async (ctx, next) => {
|
||||
const index = ctx.params.channel
|
||||
const id = ctx.params.id
|
||||
const result = await recordingDataRaw.getSdDataByID(id, index)
|
||||
export const getSdDataByUUID = async (ctx, next) => {
|
||||
const uuid = ctx.params.uuid
|
||||
const channel = ctx.params.channel
|
||||
const startTime = ctx.params.startTime
|
||||
const endTime = ctx.params.endTime
|
||||
const result = await recordingDataRaw.getSdDataByUUID(uuid, channel, startTime, endTime)
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export const getSdDataAllTimeslotByUUID = async (ctx, next) => {
|
||||
const uuid = ctx.params.uuid
|
||||
const channel = ctx.params.channel
|
||||
const result = await recordingDataRaw.getSdDataAllTimeslotByUUID(uuid, channel)
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import RecordingDataMeta from '../../../models/file/recording_data_meta'
|
||||
import RecordingDataRaw from '../../../models/file/recording_data_raw'
|
||||
import Controller from '../../../models/product/controller'
|
||||
import childProcess from 'child_process'
|
||||
import path from 'path'
|
||||
import { homedir } from 'os'
|
||||
|
||||
const recordingDataMeta = new RecordingDataMeta()
|
||||
const recordingDataRaw = new RecordingDataRaw()
|
||||
const controller = new Controller()
|
||||
|
||||
const sdPath = [homedir(), 'bioproanalysis', 'sdcard']
|
||||
@@ -61,13 +63,11 @@ const getUuidPathStringPromise = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
function uploadPromise (uuidPath, uuid, ampGain) {
|
||||
function uploadPromise (uuid) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const subprocess = childProcess.spawn('python3', [
|
||||
path.join(...sdUploadPath),
|
||||
uuidPath,
|
||||
uuid,
|
||||
ampGain
|
||||
])
|
||||
|
||||
let dataString = ''
|
||||
@@ -130,8 +130,6 @@ export const uploadThenDelete = async (ctx, next) => {
|
||||
const controllerID = request.controllerID
|
||||
const metaID = request.metaID
|
||||
const uuid = request.uuid
|
||||
const uuidPath = await getPath(uuid)
|
||||
const ampGain = await getParameter(metaID, 'AMP_GAIN')
|
||||
|
||||
// timeout defualt 120s to no-limit
|
||||
ctx.req.setTimeout(0)
|
||||
@@ -141,14 +139,21 @@ export const uploadThenDelete = async (ctx, next) => {
|
||||
sd_uploading: true
|
||||
}, controllerID)
|
||||
|
||||
const uploadResult = await uploadPromise(uuidPath, uuid, ampGain)
|
||||
|
||||
let uploadResult = await uploadPromise(uuid)
|
||||
if (uploadResult === 'true') {
|
||||
// meta sd_card_uploaded true
|
||||
await recordingDataMeta.update({
|
||||
sd_data_uploaded: true
|
||||
}, metaID)
|
||||
await deletePromise(uuidPath)
|
||||
// [Region] then doubly check if sd raw data table actually has data
|
||||
const meta = await recordingDataMeta.getByUUID(uuid)
|
||||
const channel = JSON.parse(meta[0].channels)[0]
|
||||
const sdDataRes = await recordingDataRaw.getSdDataAllTimeslotByUUID(uuid, channel)
|
||||
if (sdDataRes.length > 0) {
|
||||
// [EndRegion]
|
||||
await recordingDataMeta.update({
|
||||
sd_data_uploaded: true
|
||||
}, metaID)
|
||||
// await deletePromise(uuidPath)
|
||||
} else {
|
||||
uploadResult = 'false'
|
||||
}
|
||||
}
|
||||
|
||||
// controller column sd_uploading close
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import SDRawNeulive from '../../models/file/sd_raw_neulive'
|
||||
import * as auth from '../auth'
|
||||
|
||||
const sdRawNeulive = new SDRawNeulive()
|
||||
|
||||
export const create = async (ctx, next) => {
|
||||
const data = ctx.request.body
|
||||
const result = await sdRawNeulive.create(data)
|
||||
ctx.body = result
|
||||
next()
|
||||
}
|
||||
|
||||
export const getByParentUUID = async (ctx, next) => {
|
||||
const parent_uuid = ctx.params.parent_uuid
|
||||
const result = await sdRawNeulive.getByParentUUID(parent_uuid)
|
||||
ctx.body = result
|
||||
next()
|
||||
}
|
||||
|
||||
export const clearDeleted = async (ctx, next) => {
|
||||
const parent_uuid = ctx.params.parent_uuid
|
||||
const result = await sdRawNeulive.clearDeleted(parent_uuid)
|
||||
ctx.body = result
|
||||
next()
|
||||
}
|
||||
@@ -1,27 +1,10 @@
|
||||
import RecordingMeta from '../../../models/file/bps_recording_meta'
|
||||
import TriggerRaw from '../../../models/file/bps_trigger_raw'
|
||||
import RawTrigger from '../../../models/file/bps_raw_trigger'
|
||||
|
||||
const recordingMeta = new RecordingMeta()
|
||||
const triggerRaw = new TriggerRaw()
|
||||
const rawTrigger = new RawTrigger()
|
||||
|
||||
export const getMetaByUUID = async (ctx, next) => {
|
||||
const uuid = ctx.params.uuid
|
||||
const result = await recordingMeta.getMetaByUUID(uuid)
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export const getMetaAll = async (ctx, next) => {
|
||||
const result = await recordingMeta.getMetaAll()
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export const getTriggerRawByUUID = async (ctx, next) => {
|
||||
export const getRawTriggerByUUID = async (ctx, next) => {
|
||||
const parent_uuid = ctx.params.parent_uuid
|
||||
const result = await triggerRaw.getDataByUUID(parent_uuid)
|
||||
const result = await rawTrigger.getDataByUUID(parent_uuid)
|
||||
ctx.body = result
|
||||
|
||||
next()
|
||||
|
||||
+3
-1
@@ -41,7 +41,9 @@ for (let i = 256; i < 288; i++) {
|
||||
db[i + '_recording_data_minis'] = require('./schema/recording_data_mini.model')(sequelize, Sequelize, i)
|
||||
}
|
||||
db.recording_meta = require('./schema/bps_recording_meta.model')(sequelize, Sequelize)
|
||||
db.trigger_raw = require('./schema/bps_trigger_raw.model')(sequelize, Sequelize)
|
||||
db.raw_trigger = require('./schema/bps_raw_trigger.model')(sequelize, Sequelize)
|
||||
|
||||
db.sd_raw_neulive = require('./schema/sd_raw_neulive.model')(sequelize, Sequelize)
|
||||
|
||||
db.sequelize.sync()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = (sequelize, Sequelize) => {
|
||||
const TriigerDataRaw = sequelize.define('bps_trigger_raw', {
|
||||
const TriggerDataRaw = sequelize.define('bps_raw_trigger', {
|
||||
channel: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: -1
|
||||
@@ -12,6 +12,10 @@ module.exports = (sequelize, Sequelize) => {
|
||||
type: Sequelize.TEXT,
|
||||
defaultValue: ''
|
||||
},
|
||||
timestamp: {
|
||||
type: Sequelize.TEXT,
|
||||
defaultValue: ''
|
||||
},
|
||||
start_time: {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: '-1'
|
||||
@@ -26,5 +30,5 @@ module.exports = (sequelize, Sequelize) => {
|
||||
}
|
||||
)
|
||||
|
||||
return TriigerDataRaw
|
||||
return TriggerDataRaw
|
||||
}
|
||||
@@ -9,6 +9,9 @@ module.exports = (sequelize, Sequelize) => {
|
||||
name: {
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
series: {
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
folder_id: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: -1
|
||||
@@ -29,17 +32,21 @@ module.exports = (sequelize, Sequelize) => {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: -1
|
||||
},
|
||||
time_duration: {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: '0'
|
||||
sd_size: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: -1
|
||||
},
|
||||
start_time: {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: '-1'
|
||||
time_duration_sec: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
end_time: {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: '-1'
|
||||
time_duration_micro: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
sample_rate: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: -1
|
||||
},
|
||||
deleted: {
|
||||
type: Sequelize.BOOLEAN,
|
||||
@@ -50,13 +57,17 @@ module.exports = (sequelize, Sequelize) => {
|
||||
defaultValue: '-1'
|
||||
},
|
||||
parameter_set: {
|
||||
type: Sequelize.JSONB,
|
||||
defaultValue: {}
|
||||
type: Sequelize.ARRAY(Sequelize.JSONB),
|
||||
defaultValue: []
|
||||
},
|
||||
create_date: {
|
||||
type: Sequelize.DATE,
|
||||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
|
||||
},
|
||||
channel: {
|
||||
type: Sequelize.ARRAY(Sequelize.INTEGER),
|
||||
defaultValue: []
|
||||
}
|
||||
},
|
||||
{
|
||||
timestamps: false
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
module.exports = (sequelize, Sequelize, i) => {
|
||||
const RecordingDataRaw = sequelize.define('bps_sd_raw_neulive', {
|
||||
channel: {
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
parent_uuid: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
data: {
|
||||
type: Sequelize.TEXT,
|
||||
defaultValue: ''
|
||||
},
|
||||
data_time: {
|
||||
type: Sequelize.TEXT,
|
||||
defaultValue: ''
|
||||
},
|
||||
start_time_sec: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
end_time_sec: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
start_time_micro: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0
|
||||
},
|
||||
end_time_micro: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
freezeTableName: true,
|
||||
timestamps: false
|
||||
}
|
||||
)
|
||||
|
||||
return RecordingDataRaw
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
const db = require('../../db/database')
|
||||
const { Transform } = require("stream")
|
||||
|
||||
class TriggerRaw {
|
||||
class RawTrigger {
|
||||
async getDataByUUID (parent_uuid) {
|
||||
const ret = await db.trigger_raw.findAllWithStream(
|
||||
const ret = await db.raw_trigger.findAllWithStream(
|
||||
{
|
||||
where: {
|
||||
parent_uuid: parent_uuid
|
||||
@@ -24,7 +24,12 @@ class TriggerRaw {
|
||||
let transformData = ''
|
||||
for (let startPos = 0; startPos < transformDataArr.length; startPos += step) {
|
||||
// array chunking algo. comparison: https://www.better.dev/javascript-algorithms-array-chunking
|
||||
transformData += transformDataArr.slice(startPos, startPos + step).join() + '\n' // join: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/join
|
||||
let temp = transformDataArr.slice(startPos, startPos + step)
|
||||
const date = new Date(parseInt(temp[0]))
|
||||
temp[0] = date
|
||||
temp[1] = parseInt(temp[1]) + 1
|
||||
temp.splice(1, 0, [date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()].join(':'))
|
||||
transformData += (temp.join() + '\n') // join: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/join
|
||||
}
|
||||
callback(null, transformData)
|
||||
},
|
||||
@@ -34,4 +39,4 @@ class TriggerRaw {
|
||||
}
|
||||
}
|
||||
|
||||
export default TriggerRaw
|
||||
export default RawTrigger
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
const db = require('../../db/database')
|
||||
|
||||
const Op = db.Sequelize.Op
|
||||
|
||||
class RecordingMeta {
|
||||
async getMetaByUUID (uuid) {
|
||||
const ret = await db.recording_meta.findAll(
|
||||
@@ -18,11 +16,22 @@ class RecordingMeta {
|
||||
async getMetaAll () {
|
||||
const ret = await db.recording_meta.findAll({
|
||||
order: [
|
||||
['start_time', 'DESC']
|
||||
['create_date', 'DESC']
|
||||
]
|
||||
})
|
||||
return ret
|
||||
}
|
||||
|
||||
async clearDeleted (uuid) {
|
||||
const ret = await db.recording_meta.destroy(
|
||||
{
|
||||
where: {
|
||||
uuid: uuid
|
||||
}
|
||||
}
|
||||
)
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
export default RecordingMeta
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import RecordingDataRaw from './recording_data_raw'
|
||||
import RecordingDataMini from './recording_data_mini'
|
||||
import SDRawNeulive from './sd_raw_neulive'
|
||||
import RecordingMeta from '../../models/file/bps_recording_meta'
|
||||
|
||||
const db = require('../../db/database')
|
||||
// const RecordingDataMini = require('./recording_data_mini')
|
||||
|
||||
const recordingDataRaw = new RecordingDataRaw()
|
||||
const recordingDataMini = new RecordingDataMini()
|
||||
const sdRawNeulive = new SDRawNeulive()
|
||||
const recordingMeta = new RecordingMeta() // control system 3.0
|
||||
|
||||
const Op = db.Sequelize.Op
|
||||
|
||||
@@ -47,7 +52,8 @@ class RecordingDataMeta {
|
||||
attributes: [
|
||||
'id',
|
||||
'raw_data',
|
||||
'mini_data'
|
||||
'mini_data',
|
||||
'uuid'
|
||||
],
|
||||
where: {
|
||||
deleted: true
|
||||
@@ -68,6 +74,8 @@ class RecordingDataMeta {
|
||||
recordingDataMini.clearDeleted(channel)
|
||||
}
|
||||
}
|
||||
recordingMeta.clearDeleted(meta.uuid) // control system 3.0
|
||||
sdRawNeulive.clearDeleted(meta.uuid)
|
||||
}
|
||||
ret = await db.recording_data_metas.destroy(
|
||||
{
|
||||
@@ -175,7 +183,8 @@ class RecordingDataMeta {
|
||||
{
|
||||
where: {
|
||||
uuid: uuid
|
||||
}
|
||||
},
|
||||
raw: true
|
||||
}
|
||||
)
|
||||
return ret
|
||||
|
||||
@@ -103,21 +103,66 @@ class RecordingDataRaw {
|
||||
return ret
|
||||
}
|
||||
|
||||
async getSdDataByID (id, index) {
|
||||
const ret = await db[index + '_recording_data_raws'].findAllWithStream(
|
||||
// ref: https://stackoverflow.com/questions/47498083/find-the-closest-smaller-value-of-an-array
|
||||
findClosestSmalllerValIndex (arr, val) {
|
||||
const targetVal = arr.slice().reverse().find(e => e <= val) // why additionally use slice: see https://stackoverflow.com/questions/30610523/reverse-array-in-javascript-without-mutating-original-array
|
||||
if (targetVal !== undefined) {
|
||||
return arr.findIndex(e => e === targetVal)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
async getSdDataByUUID (uuid, channel, startTime, endTime) {
|
||||
const timeSlots = await this.getSdDataAllTimeslotByUUID(uuid, channel)
|
||||
const startTimeArr = timeSlots.map(x => parseInt(x.start_time_sec) * 1e6 + parseInt(x.start_time_micro))
|
||||
const endTimeArr = timeSlots.map(x => parseInt(x.end_time_sec) * 1e6 + parseInt(x.end_time_micro))
|
||||
|
||||
const startIndex = this.findClosestSmalllerValIndex(startTimeArr, parseInt(startTime))
|
||||
let endIndex
|
||||
const findEndIndex = endTimeArr.findIndex(el => el >= parseInt(endTime))
|
||||
findEndIndex !== -1 ? endIndex = findEndIndex : endIndex = timeSlots.length - 1
|
||||
|
||||
const idList = timeSlots.slice(startIndex, endIndex + 1).map(x => x.id)
|
||||
|
||||
const ret = await db['sd_raw_neulive'].findAll(
|
||||
{
|
||||
batchSize: 1000,
|
||||
where: {
|
||||
id: id
|
||||
id: idList
|
||||
},
|
||||
attributes: [
|
||||
'sd_data'
|
||||
]
|
||||
order: [
|
||||
['start_time_sec', 'ASC'],
|
||||
['start_time_micro', 'ASC']
|
||||
],
|
||||
raw: true,
|
||||
}
|
||||
)
|
||||
return ret
|
||||
}
|
||||
|
||||
async getSdDataAllTimeslotByUUID (uuid, channel) {
|
||||
const ret = await db['sd_raw_neulive'].findAll(
|
||||
{
|
||||
where: {
|
||||
parent_uuid: uuid,
|
||||
channel: channel,
|
||||
},
|
||||
attributes: [
|
||||
'id',
|
||||
'start_time_sec',
|
||||
'end_time_sec',
|
||||
'start_time_micro',
|
||||
'end_time_micro',
|
||||
],
|
||||
order: [
|
||||
['start_time_sec', 'ASC'],
|
||||
['start_time_micro', 'ASC']
|
||||
],
|
||||
raw: true,
|
||||
}
|
||||
)
|
||||
return ret
|
||||
}
|
||||
|
||||
async getByAttrID (id, attr, index) {
|
||||
const attrList = attr.split('-')
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
const db = require('../../db/database')
|
||||
|
||||
class SDRawNeulive {
|
||||
async create (req) {
|
||||
return db['sd_raw_neulive'].create(
|
||||
req
|
||||
)
|
||||
}
|
||||
|
||||
async getByParentUUID (parent_uuid) {
|
||||
const ret = await db['sd_raw_neulive'].findAllWithStream(
|
||||
{
|
||||
batchSize: 1000,
|
||||
where: {
|
||||
parent_uuid: parent_uuid
|
||||
},
|
||||
order: [
|
||||
['id', 'ASC']
|
||||
],
|
||||
attributes: [
|
||||
'data',
|
||||
'start_time',
|
||||
'end_time'
|
||||
]
|
||||
}
|
||||
)
|
||||
return ret
|
||||
}
|
||||
|
||||
async clearDeleted (parent_uuid) {
|
||||
const ret = await db['sd_raw_neulive'].destroy(
|
||||
{
|
||||
where: {
|
||||
parent_uuid: parent_uuid
|
||||
}
|
||||
}
|
||||
)
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
export default SDRawNeulive
|
||||
@@ -17,6 +17,9 @@ export default function (_prefix) {
|
||||
['GET', prefix + '/get_by_parent_with_limit/:type/:parent/:limit/:offset/:order', controllers.recordingDataMeta.getByParentWithLimit],
|
||||
['GET', prefix + '/get_by_attr_parent_with_limit/:type/:parent/:limit/:offset/:order/:attr', controllers.recordingDataMeta.getByAttrsParentWithLimit],
|
||||
['GET', prefix + '/get_or_create_by_path/:path', controllers.recordingDataMeta.getOrCreateByPath],
|
||||
['GET', prefix + '/get/all', controllers.recordingDataMeta.getAll]
|
||||
['GET', prefix + '/get/all', controllers.recordingDataMeta.getAll],
|
||||
// control system 3.0
|
||||
['GET', prefix + '/get_meta_by_uuid/:uuid', controllers.recordingDataMeta.getMetaByUUID],
|
||||
['GET', prefix + '/get_meta_all', controllers.recordingDataMeta.getMetaAll],
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ export default function (_prefix) {
|
||||
['GET', prefix + '/get_by_id/:channel/:id', controllers.recordingDataRaw.getByID],
|
||||
['GET', prefix + '/get_by_ids/:channel/:id', controllers.recordingDataRaw.getByIDs],
|
||||
['GET', prefix + '/get_data_by_id/:channel/:id', controllers.recordingDataRaw.getDataByID],
|
||||
['GET', prefix + '/get_sd_data_by_id/:channel/:id', controllers.recordingDataRaw.getSdDataByID],
|
||||
['GET', prefix + '/get_sd_data_by_uuid/:uuid/:channel/:startTime/:endTime', controllers.recordingDataRaw.getSdDataByUUID],
|
||||
['GET', prefix + '/get_sd_data_all_timeslot_by_uuid/:uuid/:channel', controllers.recordingDataRaw.getSdDataAllTimeslotByUUID],
|
||||
['GET', prefix + '/get_by_parent/:channel/:parent', controllers.recordingDataRaw.getByParent],
|
||||
['GET', prefix + '/get_attr_by_id/:channel/:id/:attr', controllers.recordingDataRaw.getAttrByID],
|
||||
['GET', prefix + '/get_attr_by_ids/:channel/:id/:attr', controllers.recordingDataRaw.getAttrByIDs],
|
||||
|
||||
@@ -5,8 +5,6 @@ import controllers from '../../../controllers'
|
||||
export default function (_prefix) {
|
||||
const prefix = _prefix + '/trigger'
|
||||
return [
|
||||
['GET', prefix + '/get_meta_by_uuid/:uuid', controllers.trigger.getMetaByUUID],
|
||||
['GET', prefix + '/get/all', controllers.trigger.getMetaAll],
|
||||
['GET', prefix + '/get_raw_by_uuid/:parent_uuid', controllers.trigger.getTriggerRawByUUID],
|
||||
['GET', prefix + '/get_raw_by_uuid/:parent_uuid', controllers.trigger.getRawTriggerByUUID],
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user