Drupal: debug in teaserview - debugging

As soon as i am on a single-view-page, i can use this to see the whole array of my node:
dpm($content);
it helps me also to get information about the activated fields through "manage display".
but for example on the startpage, there are no singleviews but only lists of teasers and because of that, theres a timeout when trying to debug with dpm($content);
is there someting like
dpm($content[5360]);
and the number is the nodeid, to get the output of a certain node, but not on a singlepage but on a page with teaserviews

I assume you have the dpm($content) statement in your node template file?
You should be able to do something like this:
if ($node->nid == 5360) {
dpm($content);
}

Related

capybara acceptance test - how to select the right element from inspecting the UI

In this crud test I create a log entry with #notes and will try to update the log by replacing #notes with #updated_notes.
#notes = Faker::Crypto.md5
#updated_notes = Faker::Crypto.sha256
This block of code to create the log entry works. I used within and the id's of divs in the source code with inspect.
it 'User can update manpower log entry' do
# create a new entry
within '#manpower_log_div' do
find('#manpower_log_notes').send_keys(#notes)
click_button "+ Add"
expect(page.has_css?('td', #notes)).to be true
end
Here I try to click the already existing notes on the page, which lets me edit them.
# click the already existing notes to be able to edit them
within '#manpower_log_div' do
find('#inline_edit').click
end
The error received is
Capybara::ElementNotFound:
Unable to find css "#inline_edit"
Inspecting the element gives us this, but notice the id of the object is too specific: data-object_id="11747753". What element can I place in find that I can use every time I run this test?
<span textarea_cols="50" class="inline_textarea_edit inline_editable" data-object_field="notes" data-object_id="11747753" data-object_class="ManpowerLog" data-custom_callback="" id="ManpowerLog-11747753-notes" data-value_required="false">a5c3e556f108fd29b00150ca736c82d6</span>
You can find the element by any valid CSS selector that would match it. In your example you could use class or data attribute - or a combination of both.
find('span.inline_textarea_edit[data-object_field="notes"]').click()
In your code find('#inline_edit') is looking for an element with id inline_edit. As Thomas Walpole mentioned you can find your button using css selector for example by class:
find('.inline_textarea_edit')
or
find('.inline_editable')
or
find('.inline_textarea_edit.inline_editable')
Make sure that class is uniq for that element. If not, you'll need to use something else then class or something else together with class, you need to look for uniq attribute of that element.
Also make sure that your element is within element with ID manpower_log_div as you are using within '#manpower_log_div'
You can find more info about css selectors here: http://www.w3schools.com/cssref/css_selectors.asp

RethinkDB: Realtime Changes On Array, return only newly appended

Brief: I'm using RethinkDB's change feeds to watch changes on a specific document (not the entire table). Each record looks like this:
{
"feedback": [ ],
"id": "bd808f27-bf20-4286-b287-e2816f46d434" ,
"projectID": "7cec5dd0-bf28-4858-ac0f-8a022ba6a57e" ,
"timestamp": Tue Aug 25 2015 19:48:18 GMT+00:00
}
I have one process that is appending items to the feedback array, and another process that needs to watch for changes on the feedback array... and then do something (specifically, broadcast only the last item appended to feedback via websockets). I've got it wired up so that it will monitor updates to the entire document - however, it requires receiving the complete document, then getting just the last item in the feedback array. This feels overly heavy, when all I need to get back is the last thing added.
Current code used to update the document:
r.table('myTable').get(uuid)
.update({feedback:r.row('feedback').append('message 1')})
.run(conn, callback)(...}
^ That will run several times over the course of a minute or so, adding the latest message to 'feedback'.
Watching changes:
r.table('myTable').get(uuid)
.changes()
.run(conn, function(err, cursor){
cursor.each(function(err, row){
var indexLast = row.old_val ? row.old_val.feedback.length : 0,
nextItem = row.new_val.feedback[indexLast];
// ... do something with nextItem
})
})
Finally, here's the question (2 parts really):
1: When I'm updating the document (adding to feedback), do I have to run an update on the entire document (as in my code above), or is it possible to simply append to the feedback array and be done with it?
2: Is the way I'm doing it above (receiving the entire document and plucking the last element from feedback array) the only way to do this? Or can I do something like:
r.table('myTable').get(uuid)
.changes()
.pluck('feedback').slice(8) // <- kicking my ass
.run(conn, function(err, cursor){
cursor.each(function(err, row){
var indexLast = row.old_val ? row.old_val.feedback.length : 0,
nextItem = row.new_val.feedback[indexLast];
// ... do something with nextItem
})
})
Let's go over your questions
1: When I'm updating the document (adding to feedback),
do I have to run an update on the entire document (as in my code above),
No, you don't. As you did, you only update feedback field. Not an entirely document, doesn't it?
or is it possible to simply append to the feedback array and be done with it?
It's possible. And you already do it.
The way it writes looks like your client driver has to fetch content of feedback array, then append a new element, and update the whole content back. But that's not the case here. The whole query r.row('feedback').append('message 1') is serialized as a JSON string and pass to the RethinkDB. RethinkDB run it, atomically, on the server. The content of feedback and the appending isn't done on client nor sending back to server.
If you used tcpdump like this:
tcpdump -nl -w - -i lo0 -c 500 port 28015|strings
You can see this JSON string is sender to RethinkDB server when you run your query:
[1,[53,[[16,[[15,["myTable"]],1]],[69,[[2,[3]],{"feedback":[29,[[170,[[10,[3]],"feedback"]],"doc2"]]}]]]],{}]
Yes, that single JSON query was transmited over network, not the whole document. Hope it makes sense. More information of that JSON string can be found on http://rethinkdb.com/docs/writing-drivers/ and https://github.com/neumino/rethinkdbdash/blob/master/lib/protodef.js#L84
2: Is the way I'm doing it above (receiving the entire document and plucking the last element from feedback array) the only way to do this? Or can I do something like:
Ideally we will want to use bracket to get a field of document, and listen for change on that field. Unfortunately it doesn't work yet. So we have to use map to transform it. Again, this run on server and only the last document transmit to client, not the whole document:
r.table('myTable').get(1).changes().map(function(doc) {
return doc('new_val')('feedback').default([]).nth(-1)
})

Can I use Serilog.Extra.Web's HttpRequestNumber or HttpRequestId as the SerilogMetrics timed-operation identifier?

I'm using SerilogMetrics's BeginTimedOperation() in a Web API, and it would be really great to be able to use the HttpRequestNumber or HttpRequestId properties (from the respective Serilog.Extra.Web enrichers) as the identifier, making it super easy to correlate timing-related log entries with others across a request.
Something like:
using (logger.BeginTimedOperation("doing some work", HttpRequestNumberEnricher.CurrentRequestNumber))
{ ... }
Short of poking around in HttpContext.Current for the magically- (i.e. non-public) named properties, is this achievable? Thanks!
If you begin a timed operation during a web request, the operation's events will already be tagged with the HttpRequestId.
You'll see it when logging to a structured log server like Seq, but if you're writing it out to a text file or trace then the property won't be included in the output message by default. To show it in there use something like:
.WriteTo.File(...,
outputTemplate: "{Timestamp} [{Level}] ({HttpRequestId}) {Message} ...")
The logging methods use a default template you can draw on for inspiration, and there's some info spread around the wiki though there's no definitive reference.

CodedUI assert a nonexistent element

my problem is that I want to check that an element is not displayed. In other words I want to check that an element was deleted.
So I am developing an automatic test that has a option to disable comments. I want to check that the textfield for the comments is nonexistent. Is there any easy way to do this?
You need to distinguish between the element (a text field or something) being not displayed and it being empty.
If the field is displayed but is empty then a simple assertion that the value is the empty string will work.
If the field is not displayed at all then an attempt on an assertion will fail with a control not found exception. The relevant code can be enclosed within a try-catch block that expects to catch the exception
try {
... access the control...;
Assert.Fail("The control was found but it should not be present.");
}
catch (UITestControlNotFoundException ) {
// Success path.
}
Make sure that the ... access the control...; checks for the correct level in thy control hierarchy. You may also want to enclose it with code to fail quickly when the control is not present, by default Coded UI may wait in case the application is slow to draw the control.
Try this :
Bool isExists = (Boolean)BrowserWindow.ExecuteScript("return $('#yourcontrolId').length > 0;");
if(isExists)
Assert.Fail("Control is not deleted");
// Success Code

Get [Messages] values in InnoSetup's language file

I know I can easily get messages inside
[CustomMessages]
AdditionalIcons=blablabla
using this code:
ExpandConstant('{cm:AdditionalIcons}');
which gets the AdditionalIcons string message. However, how can I get messages inside this?
[Messages]
ButtonNext=huhu
ButtonInstall=bubu
What I need is to get the ButtonNext, ButtonInstall and other values, and it is NOT possible to get those values using code like this:
ExpandConstant('{cm:ButtonNext}');
How can I query those values?
Related links
Inno Setup Script tips
Try
SetupMessage(msgButtonNext);
In general, the name of the constant to use (in this case msgButtonNext) is msg + the name of the message (string concatination).

Resources