Find comments made by particular author in Azure DevOps - azure-devops

I want to find out all comments in a User Story/Task made by me in Azure DevOps which contain a certain text.
I know how to make a query that searches for a particular text (the relevant field is "History") but but it will return comments made by anyone.
I can narrow it down to tasks "Assigned To" me, but we usually assign tasks to the PO once they are resolved so the "Assigned To" field becomes useless. Since Azure shows me who made the comment, that info is stored in its db, but is available in its Query Editor?
Edit: A REST API solution would also work for me, if available.

You can query the Get Comments Rest API:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?api-version=6.1-preview.3
In the results you will get every comment who created it.
If you want to query many work items in one call you can use Get Comments Batch Api.

Hi you can use query editor to add history for your query clause, comments entered into the discussion area can be queried. These are indexed for full text search.
Items I've been associated with
History Contains Words MyName Or Assigned To Was Ever _ #Me
you can change that based on who you would like to search for using contains word of the username
for more you can learn from Query By history

Related

AzureDevops - extract test steps to powerbi with odata query

I need to extract a table with test steps that correspond to each test case, from AzureDevops to PowerBI.
I was able to retrieve a list of tables that I can extract with odata, but none of them contains test steps. I’m attaching the metadata request and an extract of its results. extract
I’ve read that another possibility would be you to use an api query, but I’m not sure which one.
Does anyone know a possible solution?
Thank you.
According to the note in this documentation,
You can’t add fields with a data type of Plain Text (long text) or HTML (rich-text). These fields aren’t available from Analytics for the purposes of reporting.
And the type of the Steps field is Text (multiple lines), so they cannot be extract with odata.
You can try to use this REST API to get the detail of the testcase which will contain the Steps detail. Please refer the screenshot:

Getting user/users details based on user name/alias as parameter in azure devops

I've a tool(web application) which creates work-items in azure devops. (skipping the unnecessary details), just like how we assign any user a particular work-item from the Assigned To dropdown in azure devops, I too have a dropdown which when user enters any name/alias, a list of users starts showing based on the input.
The api which I was using in the backend was
https://abcorganization.vsaex.visualstudio.com/_apis/UserEntitlements?top=10&filter=name+eq+%27Tejas
Here filter=name+eq+%27Tejas in the query parameter helps to query the api and used to give set of users whose name starts with Tejas. It can be email alias too.
But for some reason, that doesn't work anymore. My guess, they've deprecated that API version
So in my search to find the alternative/answer, I came across the following documentation:
(https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/users/get?view=azure-devops-rest-5.1) in which the API given is: https://vssps.dev.azure.com/abcorganization/_apis/graph/users/{userDescriptor}?api-version=5.1-preview.1
Here the userDescriptor is some sort of unique key of AAD related to a particular user. (which I certainly can't use to fulfill my purpose).
The other thing which I've tried is the below query parameters but it still didn't worked out
https://vssps.dev.azure.com/abcorganization/_apis/graph/users?subjectTypes={subjectTypes}&continuationToken={continuationToken}&api-version=5.1-preview.1
So is there anyway/api which can fullfil my purpose or is it that I'm using this new API in a wrong way or something?
Any help would be much appreciated
I believe it should be $filter in the query. You are also missing the closing quote.
(See docs for more details)
https://abcorganization.vsaex.visualstudio.com/_apis/UserEntitlements?top=10&$filter=name+eq+'Tejas'
Use this. I tested it and worked for me:
https://vsaex.dev.azure.com/{organization}/_apis/userentitlements?$filter=name+eq+%27{name}%27&api-version=6.0-preview.3
Replace {organization} and {name} as needed

In Github, is there a way to search for pull requests created by any author from a provided list?

For my team's weekly builds, I go through all pull requests from the company GitHub and pull out the PRs associated to my team. This requires an annoying sieving step that requires a walk-through of the company's previous week of code contribution.
I looked at the official GitHub search documentation (HERE) and found the "author" field could be used to narrow down the search in the way I want, but when I try this at https://github.com/pulls it only works on one author at a time.
Is there a way to search across a list of authors?
For a little extra context, my team operates across a large list of repos, all of which are under a blanket organization which houses all repos across the company.
Make sure that you are using the full search at https://github.com/search.
Then simply add extra author: <name> fields to your query. The searching engine will OR fields. For example:
is:pr author:username1 author:username2
(Note that this only works on https://github.com/search. The search syntax on other pages, like https://github.com/pulls, is severely limited and does not support searching by multiple authors. If you try the same search on https://github.com/pulls, GitHub will simply ignore all but one author that you list.)
To limit it to repositories by a specific owner, add the user: <owner> field to the query.
Using the route github.com/search instead of github.com/pulls is the "right" answer in some sense, but I like the format of the /pulls page better. When working in a small team my approach is to use /pulls but substitute "involves" for "author", like this (for reference, the same query using /search and "author").
You will get "extra" hits where the author is someone outside the list, but it's another trick to know. (Names in the examples picked at random from recent public PRs)
You could simply use the advanced search for that: https://github.com/search/advanced 🤗
Option 1: Using Github's Search Query Language
Go to https://github.com/search
Type in a query following the format of this example (replacing author:* with your usernames.
Example: is:pr repo:zino-hofmann/graphql-flutter author:apackin author:kvenn
Explained
is:pr - only PRs (since Github treats Issues and PRs both as "Issues")
repo: - only show PRs in that repo
author: - only show PRs for these authors
It shows as "Issues", but the list will only include PRs.
Option 2: Fancy Bookmark/Alfred/Spotlight Search
You can modify the query params in the following URL to have the list of people on your team.
Replacing <username1,2,3,4> with your teammates Github username's.
Replacing <your_company> with your company URL (or removing that entirely if not on enterprise).
https://github.<your_company>.com/search?q=author%3A<username1>+author%3A<username2>+author%3A<username3>+author%3A<username4>+is%3Apr&type=Issues
Option 3: Using Github's Advanced Search UI
You can use Github's "Advanced Search" to achieve what you're looking for without needing to learn Github's query language.
For public repos: http://github.com/search/advanced
For internal/enterprise repos: http://github.<your_company>.com/search/advanced
You can use the fields below for filtering:
To filter for specific repos, use "Advanced options" -> "In these repositories"
To filter for specific authors, use "Issues options" -> "Opened by the author"
It uses query params under the hood, so you can generate the search with your UI and copy and paste it (to use for Option 3).
Note: You'll need to add "is:pr" to the resulting search query, no way to do that in the UI.

Best way to store/get values referenced from a list in Mongo/RectiveMongo?

I have a quite common use case - a list of comments. Each comment has an author.
I'm storing the reference from a comment to the author using a reference, since an author can make multiple comments.
Now I'm working with ReactiveMongo and want to try to keep the database access asynchronous, but in this case, I don't know how. I do an asynchronous access to the database, to get the comments, but then for each comment I have to get the author, and until now the only way I know is to loop through the comments and get the user synchronously:
val userOption:Option[JsObject] = Await.result(usersCollection.find(Json.obj("id" -> userId).one[JsObject], timeout)
//...
Other than that, I could:
Get each user asynchronously but then I have to introduce some functionality to wait until all user were fetched, in order to return the response, and my code is likely to become a mess.
Store the complete user object - at least what I need for the comment (picture, name and such) in each comment. This redundancy could become troublesome to manage, since each time a user changes something (relevant to the data stored in the comments) I would have to go through all the comments in the database and modify it.
What is the correct pattern to apply here?
I tackled this exact problem a while ago.
There are no joins in mongo.
You have to manually take care of the join.
Your options are:
Loop through each comment entry and query mongo for the user. this is what you're doing.
Get all user id's from comments, query mongo for the users matching these ids, then take care to match user to comment.This is just what you did but a little more optimized.
Embed the user in comments or comments in users. Wouldn't recommend this, this is probably not the right place for comments/users.
Think of what set of data do you need from user when displaying a comment, and embed just this info in comment
I ended up going with the last option.
We embedded the user id, first and last name in each comment.
This info is unlikely to change (possibly not even allowed to change after creation?).
If it can change then it is not too hard to tailor the update-user method to update the related comments with the new info (we did that too).
So now no join is needed.

How to get list of aggregates using JOliviers's CommonDomain and EventStore?

The repository in the CommonDomain only exposes the "GetById()". So what to do if my Handler needs a list of Customers for example?
On face value of your question, if you needed to perform operations on multiple aggregates, you would just provide the ID's of each aggregate in your command (which the client would obtain from the query side), then you get each aggregate from the repository.
However, looking at one of your comments in response to another answer I see what you are actually referring to is set based validation.
This very question has raised quite a lot debate about how to do this, and Greg Young has written an blog post on it.
The classic question is 'how do I check that the username hasn't already been used when processing my 'CreateUserCommand'. I believe the suggested approach is to assume that the client has already done this check by asking the query side before issuing the command. When the user aggregate is created the UserCreatedEvent will be raised and handled by the query side. Here, the insert query will fail (either because of a check or unique constraint in the DB), and a compensating command would be issued, which would delete the newly created aggregate and perhaps email the user telling them the username is already taken.
The main point is, you assume that the client has done the check. I know this is approach is difficult to grasp at first - but it's the nature of eventual consistency.
Also you might want to read this other question which is similar, and contains some wise words from Udi Dahan.
In the classic event sourcing model, queries like get all customers would be carried out by a separate query handler which listens to all events in the domain and builds a query model to satisfy the relevant questions.
If you need to query customers by last name, for instance, you could listen to all customer created and customer name change events and just update one table of last-name to customer-id pairs. You could hold other information relevant to the UI that is showing the data, or you could simply hold IDs and go to the repository for the relevant customers in order to work further with them.
You don't need list of customers in your handler. Each aggregate MUST be processed in its own transaction. If you want to show this list to user - just build appropriate view.
Your command needs to contain the id of the aggregate root it should operate on.
This id will be looked up by the client sending the command using a view in your readmodel. This view will be populated with data from the events that your AR emits.