Couchbase: How to remove channel access for a document through Sync function - couchbase

I'm new to couchbase. I want to update channels for some of the documents through sync functions. But right now, it is not updating but adding an extra channel to the document's meta but not removing the existing channel. Can anyone suggest how I can remove the existing channel in the document?
Sync Function:
function(doc, oldDoc) {
//....
if (doc.docType === "differentType") {
channel("differentChannel");
expiry(2332800);
return;
}
//.......
}
Document:
{
"channels": [
"abcd"
],
"docType": "differentType",
"_id" : "asjnc"
}
Metadata:
{
"meta": {
"id": "asjnc",
"rev": "64-1b500000000",
"expiration": 1650383285,
"flags": 0,
"type": "json"
},
"xattrs": {
"_sync": {
"rev": "1-db30e607872",
"sequence": 777,
"recent_sequences": [
777
],
"history": {
"revs": [
"1-db30e607872"
],
"parents": [
-1
],
"channels": [
[
"differentChannel"
]
]
},
"channels": {
"differentChannel": null
}
}
}
}
Expectation of the document with the same metadata:
{
"channels": [ ], // <--- no channels
"docType": "differentType",
"_id" : "asjnc"
}
With this sync function, for the document of type differentType, the channel differentChannel is set in the xattrs section in the metadata. But the channel that was added earlier from the couchbaseLite is not getting removed. Can anyone help?

I answered this in the Couchbase Forums: https://forums.couchbase.com/t/remove-channels-from-a-document/33212
The "channels" property in a document is counter-intuitively not describing what channels the document is currently in - it's just a user-definable field that happens to be the default routing for channels if you don't specify a sync function. It's up to the writer of the document what it should contain.
If you have another means of channel assignments (like "docType" in your case), then you don't need to specify "channels" in the document. The sync metadata shows that the document is in "differentChannel" at revision 1-db30e607872 but the contents of the document can be arbitrary.

Related

Serilog doesn't parse file name templae

I'm using serilog with this configuration:
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "./logs/performance-{Date}.log",
"rollingInterval": "Day",
"fileSizeLimitBytes": 1000,
"rollOnFileSizeLimit": true,
"retainedFileCountLimit": null,
"shared": true
}
}
]
}
}
Output file should look like 20210613-performance.log But output file looks like {Date}-performance20210613.log.
What i'm doing wrong?
The {Date} placeholder is not a feature of the Serilog.Sinks.File sink that you're using. You're probably confusing with the (deprecated) Serilog.Sinks.RollingFile sink which has this feature.
With Serilog.Sinks.File, at this time, you cannot define where the date will appear. It's always appended to the end of the file name you choose (and before the sequence number if you also are rolling by file size).
There have been attempts to implement this feature, but as of this writing it's not yet there.

Can you clip (or trim) an mp3 using AWS Mediaconvert?

I have mediaconvert jobs encoding mp3 uploads into various formats. I'd like to also create a 30 second "preview" of an mp3 file by trimming the file to start at 10 seconds and end at 40 seconds.
I have tried setting "input clippings" by adding timecode references as below, but it seems to get ignored completely and encodes the whole file. Perhaps this is because mp3 files don't strictly have Timecode? These settings are in my Input json (PHP SDK):
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Offset": 0,
"DefaultSelection": "DEFAULT",
"SelectorType": "TRACK",
"ProgramSelection": 1
}
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"TimecodeSource": "EMBEDDED",
"FileInput": "'$file'",
"InputClippings": [
{
"EndTimecode": "00:00:45:00",
"StartTimecode": "00:00:20:00"
}
]
}
]
I have also tried adding the inputclipping in this format :
"inputs": [
{
"inputClippings": [
{
"endTimecode": "00:00:40:00",
"startTimecode": "00:00:10:00"
}
],
"audioSelectors": {
},
I think this parameter is case sensitive. I do input clipping in MediaConvert occasionally and it works for me. Maybe try this:
"Inputs": [
{
"InputClippings": [
{
"EndTimecode": "00:00:40:00",
"StartTimecode": "00:00:10:00"
}
],
"AudioSelectors": {
"Audio Selector 1": {
"DefaultSelection": "DEFAULT",
"ProgramSelection": 1
}
},
"FileInput": "s3://my-bucket/abc.mp4"
}
]
The InputClippings feature is not currently supported for audio-only inputs. MediaConvert silently ignores this parameter rather than returning a warning or error for audio-only inputs.
Resource: https://docs.aws.amazon.com/mediaconvert/latest/ug/feature-limitations-for-audio-only.html

On watson conversation panel how to set the intent right on the respond json?

i am building a conversation on the watson conversaton, and in a point, togeter with my "response" json, i woul also link to set a new intent for the user, i tried to add this to the json, but with no result.
There is a way to do this?
As you can see in the Official documentation, you can use context variables for save values.
A context variable is a variable that you define in a node, and
optionally specify a default value for. Other nodes or application
logic can subsequently set or change the value of the context
variable.
So, in this case, you'll create in your JSON advance (like your example) something like:
{
"context": {
"intent": "fgts",
"confidence": 1
},
"output": {
"text": {
"values": [
"Your text here"
],
"selection_policy": "sequential"
}
}
}
And in your back-end application, you can access the value in the response JSON object from your POST /message, with something like: response.context.intent and response.context.confidence
Obs.: By default, Watson Conversation service will return the name of the intent that Watson recognizes and the confidence level.
If really after these instructions you want to use your method. You can see my example below:
{
"output": {
"text": {
"values": [
"text here"
],
"selection_policy": "sequential"
},
"intents": "test"
}
}
And your app return:
{ intents: [ { intent: 'helpBot', confidence: 0.5930036529133407 } ],
entities: [],
input: { text: 'ajuda' },
output:
{ text: [ 'text here' ],
nodes_visited: [ 'node_16_1511443279233' ],
intents: 'test',
log_messages: [] },
context:
{ conversation_id: '83d88b05-7c76-457d-bd5f-7820be455a3e',
system:
{ dialog_stack: [Object],
dialog_turn_counter: 2,
dialog_request_counter: 2,
_node_output_map: [Object],
branch_exited: true,
branch_exited_reason: 'fallback' } } }
See more about accessing values using Conversation Service.

Fiware STH: row data API not exposing metadata

I am using Cygnus with Mongo and sth sink to retrieve historical data.
In the current implementation of cygnus mongo sink the attribute metadata is not stored in the data base. So I updated cygnus to be able to store the attribute metadata.
But when I use the STH-comet to retrieve the history, the API appreantly does not support retrieveing the attribute metadata.
Am I missing some kind of configuration or the API is not supporting the attribute metadata since the response that I am getting from STH-comet is:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "humidity",
"values": [
{
"recvTime": "2017-03-08T08:06:11.463Z",
"attrType": "Number",
"attrValue": "999"
},
{
"recvTime": "2017-03-08T08:10:54.199Z",
"attrType": "Number",
"attrValue": "3.06"
}
]
}
],
"id": "Room1",
"isPattern": false,
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
In the mongoDB data base I have this content:
{ "_id" : ObjectId("58bfbb7c973c5c22d258cffc"), "recvTime" : ISODate("2017-03-08T08:06:11.463Z"), "attrName" : "humidity", "attrType" : "Number", "attrValue" : "999", "attrMetadata" : [ ] }
{ "_id" : ObjectId("58bfbc93973c5c22d258cffd"), "recvTime" : ISODate("2017-03-08T08:10:54.199Z"), "attrName" : "humidity", "attrType" : "Number", "attrValue" : "3.06", "attrMetadata" : [ { "name" : "unit", "type" : "Text", "value" : "voltage" } ] }
In case the API is not supporting the retrieval of the attribute metadata, can this feature be added?
Thanks & Best regards.
STH and Cygnus are aligned with regards to the information stored in MongoDB, both raw and aggregated one. In this sense, because Cygnus originally did not support for attribute metadata in NGSIMongoSink (the one in charge of storing the information in raw format), STH do not support attribute metadata in its raw API either.
As long as you have extended Cygnus functionality for this purpose, you'll have to extend STH API as well.

NGSI update attributes from complex entities in Wirecloud

Is it possible to update a child attribute through the updateAttributes() function from Wirecloud NGSI API?
For example, a coordinate (entity.location.coords.coordinates[0]=-2.000000) in this piece of entity.
"attrNames": [ "A1", "A2", "position" ],
"creDate": 1389376081,
"modDate": 1389376244,
"location": {
"attrName": "position",
"coords": {
"type": "Point",
"coordinates": [ -3.691944, 40.418889 ]
}
EDITED
My own answer: It is possible by passing an object as value of the attribute.
ngsi.updateAttributes([
{
'entity': {'id': "entity-id"},
'attributes':[{
"name":"location","contextValue": {
"attrName": "position",
"coords": {
"type": "Point",
"coordinates": [ -2.000000, 40.418889 ]
}
}
}]
}
], {
onSuccess: onUpdateAttributesSuccess,
onFailure: onUpdateAttributesFail
}
);
However, Wirecloud is using NGSI API v1, therefore all attributes are treated as strings when they are sent/received to/from Orion.
More info: http://fiware-orion.readthedocs.io/en/master/user/structured_attribute_valued/
Currently, it's not possible to make partial changes into an structure attribute using the WireCloud's NGSI API. Moreover, as far as I know, the NGSI API doesn't provide a direct way for making partial updates into structured attributes (neither v1 nor v2).
However, v1 of the NGSI API supports structured attribute values. So you can make use of the updateContext method to update only one attribute (e.g. the coordinates attribute). The only thing to take into account it's that you will have to provide the full value, so if you want to make a partial change you have to read the value, make the partial change and update it.
In fact, you almost have it working. You only have to fix the way you are passing the attributes to update, you should wrap them into an array:
ngsi.updateAttributes([{
"entity": {"id": "entity-id"},
"attributes": [
{
"name": "location",
"contextValue": {
"attrName": "position",
"coords": {
"type": "Point",
"coordinates": [-2.000000, 40.418889]
}
}
}
]
}],
{
onSuccess: onUpdateAttributesSuccess,
onFailure: onUpdateAttributesFail
}
);