How do you find the PHID of a Phabricator object? - phabricator

I need to get the PHIDs for one project and several users in our Phabricator install. It seems like it should be trivial to find out how to do this, but I've searched the docs to no avail. Am I looking in the wrong place or something?

Easiest way:
Go to the project
Click New Task
Look at the URL, it will have a parameter like:
?projects=PHID-PROJ-owipizovyry4fatifwfd
PHID is "PHID-PROJ-owipizovyry4fatifwfd"
Option 2:
Go to your Conduit [phabricator_url]\conduit
Find the method project.query
Enter the name in a JSON encoded array (i.e. ["project name"])
Click Call Method
PHID will be one of the data elements:
{
"data" : {
"PHID-PROJ-oybqquyhhke4awiw2akz" : {
"id" : "19",
"phid" : "PHID-PROJ-oybqquyhhke4awiw2akz",
"name" : "project name",
"members" : [
"PHID-USER-gapak5h34h6d5yvl67dx",
"PHID-USER-674vq754zfuhyxgvvq7x",
"PHID-USER-qvcdsyc4oz7rzpzziiyk",
"PHID-USER-qmefzjtsrmnxjxpc45km",
"PHID-USER-pbhygge7rgpdowz3s5vk"
],
"slugs" : [
"project_name"
],
"dateCreated" : "1396666703",
"dateModified" : "1396668261"
}
}
}

A more robust method would be to call the conduit method phid.lookup:
https://<your install>/conduit/method/phid.lookup/
Then enter in names something like #user, #project or Z2 and you'll get the PHID.

Related

VTL: Add a new property to an maps inside an array (AWS Appsync, DynamoDB)

I'm new to VTL and AWS appsync and try to get my head around how things are working.
The maps that are representing Steps in a List should have the property id with a UUID before there are stored in DynamoDB. To accomplish this I tried to iterate over the array and access the put method on the map like in the example below.
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key": {
"id" : $util.dynamodb.toDynamoDBJson($util.autoId())
},
#set($input = $util.dynamodb.toMapValues($ctx.args.input))
#set($input.createdAt = $util.dynamodb.toDynamoDB($util.time.nowISO8601()))
#foreach($step in $input.steps)
$step.put('id', $util.dynamodb.toDynamoDBJson($util.autoId())))
#end
"attributeValues": $util.toJson($input)
}
my second try:
#foreach($step in $input.steps)
#set($step.id = $util.dynamodb.toDynamoDBJson($util.autoId()))
#end
but still, for no reason, my maps do not have the property id.
Is there maybe the problem what the foreach loop is giving me just a copy of the map I try to modify and not the original object?
Thank you for your time!
Hopefully, my question will serve all newbies to VTL and appsync
They do, it's just that the toMapValues utility method is returning you DynamoDB types.
So if "input.steps" is supposed to be a list what you're gonna get in there is an object like {"L": [ ... ]}
Try this:
#foreach($step in $input.steps.L)
$step.put('id', $util.dynamodb.toDynamoDBJson($util.autoId())))
#end

Add Custom index pattern ID to existing Index Pattern

I have created an Index Pattern in Kibana, which successfully matches the indexes that I need. I would like to go back and give that existing Index Pattern a custom ID (In the Advanced Options in Step 2 of the wizard in Kibana when creating). Is that possible, or do I need to delete/recreate the Index Pattern?
Just for reference how an index pattern looks in the background:
{
"_index" : ".kibana_1",
"_type" : "_doc",
"_id" : "index-pattern:metricbeat-*",
"_score" : 1.0,
"_source" : {
"index-pattern" : {
...,
"timeFieldName" : "#timestamp",
"title" : "metricbeat-*"
},
"type" : "index-pattern",
"references" : [ ],
"migrationVersion" : {
"index-pattern" : "6.5.0"
},
"updated_at" : "2019-08-11T09:00:09.020Z"
}
}
If you set a custom ID for the index pattern, it will result in "_id" : "index-pattern:<your-name>". So whatever you do, you will need to remove the old index pattern and create a new one (even if you update parts of the document through the API), since the document ID defines the document.
But generally, the index pattern doesn't contain too much information, so it should be easy to recreate, right?
Also, why do you need a specific ID for the index pattern?

AppSync Resolver only works when I hard code the input. context.arguments does not work

Edit for clarity: There are no error messages, it simply returns an empty list if the input string is from the context.arguments, suggesting that it simply isn't getting the input variable out on the query tester (setting it up incorrectly brings up that famous typing error of course). I've also made this into a pipeline with the exact same result. Looking around, people suggest making an intermediate object, but surely I'm just getting my input variables out wrong somehow.
I'm working on a project in AWS Appsync using DynamoDB and I've run into a problem with the context.arguments input.
Basically the code all works if I hardcode the string for the book id into the query (full context to follow), but if I use the context.arguments, it simply refuses to work properly, returning an empty array for the "spines".
I have the following types in my schema:
type Book {
id: ID!
title: String
spines: [Spine]
}
type Spine {
id: ID!
name: String
bookId: ID!
}
I use the following query:
type Query {
getBook(id: ID!): Book
query getBook($bookId: ID!){
getBook(id: $bookId){
title
id
spines {
name
bookId
}
}
}
With the following input (assume this is a relevant guid):
{
"bookId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
}
And this resolver for the spines object:
{
"version" : "2017-02-28",
"operation" : "Query",
"index" : "bookId-index",
"query" : {
"expression": "#bookId = :bookId",
"expressionNames" : {
"#bookId" : "bookId"
},
"expressionValues" : {
":bookId" : { "S" : "${context.arguments.id}" }
}
}
}
}
I made sure my data set contained false positives too (spines for other books) so that I know when my query brings back the correct data.
This works if I hardcode a guid as string instead of using context.arguments, and gets exactly what I'm looking for for each book guid.
For example, replacing the expression values with this works perfectly:
"expressionValues" : {
":bookId" : { "S" : "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" }
}
Why does "${context.arguments.id}" not get the input variable here the same way as it seems to in other queries?
Thanks to #IonutTrestian for pointing me in the right direction.
$ctx.args was empty, but I decided to go up the chain to see what was in the entire context, so $util.error($util.toJson($ctx)).
The json object I found included a little object called "Source", which contained the query return for the Book object.
Long story short, $ctx.source.id when applied to my query worked a charm.
I also know a bit more about debugging DynamoDB resolvers in case I encounter problems like this in future. Thank you so much!

Mongo's elemMatch with meteor publish composite

I have a Mongo collection that looks similar to the below example, I am using meteor-publish-composite, https://atmospherejs.com/reywood/publish-composite to publish documents to the client. I know with Mongo I can do the following to return specific items within the authors array.
db.books.find({"authors.authorSlug": "author-1}, {authors: {$elemMatch: { authorSlug: "author-1"}});
When I try to achieve the same thing using meteor-publish-composite, this does not seem to work as it returns the entire the authors' array, my code is as below.
Books.find({"authors.authorSlug": slug}, {authors: {$elemMatch:{authorSlug: slug}}});
Is this even possible to achieve with publish-composite?
{
"title" : "Book1",
"authors" : [
{
"name" : "Author 1",
"authorSlug": "author-1"
},
{
"name" : "Author 2",
"slug" : "author-2"
},
],
"slug" : "book1"
}
You only use publish-composite when you are trying to join 2 or more related collections into a single reactive subscription. You simply need a standard publish/subscribe for your collection - and you say you have working code so I don't see what your problem is! Or are you trying to get at your books data in addition to other data around it?

Removing the Last Item From a List created By .push()

I am having trouble deleting a single item from a list. I want to delete the 'oldest' item, and these have been added via the .push() method. It seemed pretty straightforward to do this but I am having issues. For my data structure, please see below. I am sure I am just doing something dumb as this must be a common use-case.
Any ideas/feedback would be greatly appreciated.
Code:
firebase.child('articlesList').orderByChild('site').equalTo('SciShow').limitToFirst(1).once('value', function(snapshot){
// This was one try, This seems to remove the entire articleList
snapshot.ref().remove();
// I have also tried this, and this seems to do nothing at all
snapshot.forEach(function(dataSnapshot){
dataSnapshot.ref().remove();
});
});
Data Structure:
"articlesList" : {
"-Jc16JziK668LV-Sno0s" : {
"id" : "http://gdata.youtube.com/feeds/api/videos/c8UpIJIVV4E",
"index" : "SciShow",
"link" : "http://www.youtube.com/watch?v=c8UpIJIVV4E&feature=youtube_gdata",
"site" : "SciShow",
"title" : "Why Isn't \"Zero G\" the Same as \"Zero Gravity\"?"
},
"-Jc16Jzkn6q41qzWw3DA" : {
"id" : "http://gdata.youtube.com/feeds/api/videos/Wi9i8ULtk4s",
"index" : "SciShow",
"link" : "http://www.youtube.com/watch?v=Wi9i8ULtk4s&feature=youtube_gdata",
"site" : "SciShow",
"title" : "The Truth About Asparagus and Your Pee"
},
"-Jc16Jzkn6q41qzWw3DB" : {
"id" : "http://gdata.youtube.com/feeds/api/videos/J7IvxfcOkmM",
"index" : "SciShow",
"link" : "http://www.youtube.com/watch?v=J7IvxfcOkmM&feature=youtube_gdata",
"site" : "SciShow",
"title" : "Hottest Year Ever, and Amazing Gecko-Man Getup!"
},
The folks over at Firebase answered this for me on their Google Group. I figured I would post for others to use.
= = =
Hey Ryan,
You are close! Instead of using the value event, you want to use the child_added event. The value event will get fired once with all the data at your /articlesList/ node. That is why you are seeing it delete the whole list. If you use the child_added event, it will fire for each child. Or, if you limit it like you did, it will only fire for a subset of children. One other thing to change is to use limitToLast(1) instead of limitToFirst(1) to get the last child.
Here's the code:
firebase.child('articlesList').orderByChild('site').equalTo('SciShow').limitToLast(1).once('child_added', function(snapshot){
snapshot.ref().remove();
});
Jacob

Resources