"complex" grouping and sorting with sunspot - ruby-on-rails

I have a problem to which I can't seem to find a solution.
I want to achieve the following:
* i have a list of tasks, each with an owner and a due date
* i want to display a list of all tasks grouped by owner
* i want to sort the owners based on the due dates: e.g. The owner with the lowest due date first, followed by the owner with the second lowest, etc
To ilustrate, this would be a result i am looking for:
Harry
- task 1, due date 1
- task 3, due date 4
Ben
- task 2, due date 2
Carol
- task 4, due date 3
I am using sunspot to search and filter results, so ideally i would like to use sunspot to do this. I've been trying to get the results with facets and ordering but haven't gotten this result to work yet(i can group by owners, or order by due date just not both).
Any help would be appreciated.
Erwin

What you want to use is the Result Grouping/Field Collapsing feature of solr.
Unfortunately, this is a fairly new feature in solr, and isn't yet supported in sunspot (as of 1.3.0). However, it is under active development and explicitly listed as a feature for a "future release". This might be soon-ish, as a pull request for this feature was just submitted a couple days ago.
If you haven't found a workaround, you could grab the code from that pull request and see if it does what you need it to do....always fun to walk on the bleeding edge, right? :)
UPDATE: Support for field grouping was just merged in to the master branch of sunspot. Check it out. The readme for sunspot has been updated with examples of how to do exactly what you're trying to do.

Related

Best practices for events and date ranges

I’m trying to find the best practice for how to store and then query a event like this. User has purchased 3 items on separate dates.
Over that period there were two events that were held (events added in well after the user purchased the items as a retrospect, so at the time of purchase, event was not known). I’m trying to see how many items were purchased during each event by that user. How should I do that?
One solution but it sounds weird to me: When inserting a event, scan and add a relationship to all vertices that match
Manage date-time types isn't exactly an easy task on Neo4j, even in 3.2 version.
You have two options:
Hard way: convert all date to unix "timestamp" format ('s' or 'ms' from 1970), in order to calc date ranges.
Easy, convenient way: use "APOC" (here), a set of procedures and functions available as plugin for Neo4j; installation can be a bit tricky but it's worth it, indeed. It has a good number of 'date-time' functions.

Is there a way to find the deleted transactions by list Id?

My goal is to find the deleted transactions during a period of the time for a list of jobs. The period of the time can be different from job to job. I am currently using TxnDeletedQueryRq but the request only provides filter on date range. I tried to look into other requests, but no luck so far. I am wondering if anyone knows a way to achieve this.
Thank you.
The only way that I can think of would be to create an audit trail report and parse for the state "Deleted". This allows you to set an entity filter for the name, plus you could set the modified date range an the report period to maybe help narrow down the information you would need to parse:
IGeneralDetailReportQuery report = MsgRequest.AppendGeneralDetailReportQueryRq();
report.DisplayReport.SetValue(false);
report.GeneralDetailReportType.SetValue(ENGeneralDetailReportType.gdrtAuditTrail);
report.ReportEntityFilter.ORReportEntityFilter.FullNameList.Add("Customer");
report.ORReportPeriod.ReportPeriod.FromReportDate.SetValue(fromDate);
report.ORReportPeriod.ReportPeriod.ToReportDate.SetValue(toDate);
report.ORReportModifiedDate.ReportModifiedDateRangeFilter.FromReportModifiedDate.SetValue(fromModDate);
report.ORReportModifiedDate.ReportModifiedDateRangeFilter.ToReportModifiedDate.SetValue(toModDate);

How can I have FogBugz show me cases with no recent activity?

I have a particular saved filter that shows me all cases in a specific project and area that are active and assigned to humans (by excluding some users that don't correspond to real people but are instead used for unrelated project management operations.
It looks something like:
"All open cases in PROJECT that are active containing -assignedto:"Non-Human User 1" -assignedto:"Non-Human User 2"
I would like to amend this filter to show me the subset of these cases that have had no edits of any kind in the last two weeks. I have tried adding various flavors of the edited axis using relative time ranges as I've seen examples of in the FogBugz documentation, but I get unexpected results every time. In particular, -edited:"-2w.." or even the simpler -edited:"yesterday" shows me results where the Last Updated column says, maddeningly, "DD/MM/YYYY (Yesterday)."
(This is with FB 8, for what it's worth).
I was able to get this to work reasonably close to what I expected by adding a search axis term for edited:"..-2w" (where -2w means "two weeks ago" and could of course be changed to whatever window of time was relevant). What tripped me up is that I was trying to exclude things edited between two weeks ago and now using -edited and that didn't quite do what I expected.
Instead, my final query looks like it is grabbing things edited from the dawn of time until two weeks ago (further restricted by additional filters of course).

Find WorkItems that were assigned to X in the last 30 days

I'm trying to find all WorkItems that were assigned to a person X in the last 30 days.
The big problem I have is the "in the last 30 days"-part.
I thought about using the "ever" or "asof" keywords, but couldn't find a good answer yet.. something like WHERE [Assigned To] = 'X' AND (([Assigned To] != 'X') asof '<30daysago>').
But this is still not a bulletproof solution.
Any better ideas?
Thanks & kind regards
Simon
It appears that this is not possible using just WIQL, but you can get close.
The keyword #Today will give you today's date, then just subtract your range from it. The EVER keyword applied to [Status]='AssignedTo' and a comparison against a date 30 days in the past to [StateChangeDate] is what you'll need to accomplish this.
As close as you can get with WIQL and existing fields:
This says, from all revisions (status changes) return records where the user 'X' has ever been AssignedTo and the State has changed in the last 30 days. This will basically give you a slightly fuzzy picture of what your User has been working on in the last month.
WHERE [Microsoft.VSTS.Common.StateChangeDate] >= #today - 30
AND [System.AssignedTo] EVER 'Bennett Aaron'
ORDER BY [System.State]
Add the missing field:
You could add a custom field called AssignedDate that is captured during the New->AssignedTo workflow transition that you create in the Work Item Definition XML. You can accomplish this using the Team Foundation Server Power Tools extension to Visual Studio. This would give you exactly what you need as well as additional reporting options going forward.
TFS API
I cannot help you with this one, but I believe you could query using the TFS API.
A couple of quick gotchas I've experienced to save you time on ASOF and EVER:
AsOf won't help you by itself with this as it does not support a range of dates. It allows you to query as if it were another date. In other words, if you forgot to capture the results of a query yesterday, you can use an AsOf query to get the results that you would have gotten had it run yesterday. What I understand is that you want to query a basic date range.
EVER might not work as you expect against dates as I believe it uses the exact value of the field (timestamp portion of the date field would be included) it tests with. Just make sure the EVER keyword is used against the status field rather than a date.

In TFS how do I pull all the items that were assigned to me between certain dates in the past?

I am trying to figure out the way to pull all the items that were on my plate between certain dates. Is this possible? Could you please help me to figure out how to write a query for that? Thanks.
The best that I know how to do is to set 'Assigned To' Was Ever #Me, then manually scan the list of work items returned (setting other fields as necessary to filter the results). In the UI, at least, there isn't a way to query on historical data.
You can do this via query window as well, below is my query that i use to see what have i been working on in the past two sprints.
This will give you any tickets you worked on regardless of who they are currently assigned to (system test / uat or whatever).
You can add more clauses and have Changed Date > xxx AND ChangedDate < xxx to find what you are looking for in any given dates.

Resources