JQL to search subtasks of not completed stories - jql

I am trying to create a custom search that lets me see the subtasks I touched of tasks that are still not done. I have the two queries sorted out:
q1 -> status changed by [username] after -7d
q2 -> status != Done
I tried
status changed by [username] after -7d and Parent in (status != "Done")
But it throws an error...
I dont know how to apply the search correctly. On pseudo sql, it would be
Select * from tasks where
( editor=[username] AND
parent_task = (select taskID from tasks where status != "DONE")
Any idea as on how I can do this?

Unfortunately your requirement cannot be achieved using native JQL.
You can use a plugin like ScriptRunner, in order to fulfill your requirement.

Related

Build query that brings only sessions that have only errors?

I have a table with sessions events names. Each session can have 3 different types of events.
There are sessions that have only error type event and I need to identify them by getting a list those session.
I tried the following code:
SELECT
test.SessionId, SS.RequestId
FROM
(SELECT DISTINCT
SSE.SessionId,
SSE.type,
COUNT(SSE.SessionId) OVER (ORDER BY SSE.SessionId, SSE.type) AS total_XSESIONID_TYPE,
COUNT(SSE.SessionId) OVER (ORDER BY SSE.SessionId) AS total_XSESIONID
FROM
[CMstg].SessionEvents SSE
-- WHERE SSE.SessionId IN ('fa3ed523-60f9-4af0-a85f-1dec9e9d2cdb' )
) AS test
WHERE
test.total_XSESIONID_TYPE = test.total_XSESIONID
AND test.type = 'Errors'
-- AND test.SessionId IN ('fa3ed523-60f9-4af0-a85f-1dec9e9d2cdb' )
Each session can have more than one type, and I need to count only the sessions that have only type 'errors'. I don't want to include sessions that have additional types of events in the count
While I'm running the first query I'm getting a count of 3 error event per session, but while running the all procedure the number is multiplied to 90?
Sample table :
sessionID
type
fa3ed523-60f9-4af0-a85f-1dec9e9d2cdb
Errors
fa3ed523-60f9-4af0-a85f-1dec9e9d2cdb
Errors
fa3ed523-60f9-4af0-a85f-1dec9e9d2cdb
Errors
00c896a0-dccc-41bf-8dff-a5cd6856bb76
NonError
00c896a0-dccc-41bf-8dff-a5cd6856bb76
Errors
00c896a0-dccc-41bf-8dff-a5cd6856bb76
Errors
00c896a0-dccc-41bf-8dff-a5cd6856bb76
Errors
In this case I should get
sessionid = fa3ed523-60f9-4af0-a85f-1dec9e9d2cdb
Please advice - hope this is clearer now, thanks!
It's been a long time but I think something like this should get you the desired results:
SELECT securemeSessionId
FROM <TableName> -- replace with actual table name
GROUP BY securemeSessionId
HAVING COUNT(*) = COUNT(CASE WHEN type = 'errors' THEN 1 END)
And a pro tip: When asking sql-server questions, it's best to follow these guidelines
SELECT *
FROM NameOfDataBase
WHERE type!= 'errors'
Is it what you wanted to do?

SQL or django query to find the similar entries

I want to return the user a list of similar tasks. Two tasks A and B are considered similar if all the words in task A exist in task B or vice versa.
I tried the query given below but couldn't get the required result.
SELECT t1.task
FROM todolistapp_todo t1
LEFT JOIN todolistapp_todo t2
ON
t1.task in (t2.task) and t1.id != t2.id;
I'm able to do this by the nested loop. But I want to do it with minimum complexity.
similar = set()
for task in tasks:
for nested_task in tasks
if (task.task in nested_task.task or nested_task.task in task.task) and task.id != nested_task.id:
similar.add(task)
can you try:
[similar.add(similar_task) for similar_task in tasks if tasks.filter(task=similar_task.task).count()>1]
I'm on phone then sorry if not working :)

sql query for apache airflow

i would like to query the apache airflow database directly for a report of failed tasks, but i'm struggling with the appropriate join to make in the database.
what i would like is an output consisting of the following columns
dag_run.dag_id
dag_run.run_id
dag_run.state
dag_run.conf
task_instance.task_id
task_id.state
basically a sql dump of all dag_runs and the status of their tasks; similar to the 'Graph' view but all all run_ids.
thanks!
Here is the query for information about your failed task.
SELECT dr.dag_id, dr.run_id, dr.state, dr.conf, ti.task_id, ti.state
FROM dag_run as dr
INNER JOIN
(
SELECT dag_id, task_id, state, execution_date
FROM task_instance
WHERE state = 'failed'
) as ti
ON dr.dag_id = ti.dag_id AND dr.execution_date = ti.execution_date
I don't know what you want, but you can use DAG's on_failure_callback parameter to set it to do something when it fails. I recommend using this method.

Return top N rows ordered by date after table join

I posted a few weeks back with an issue, now I've gotten past it and found a new need and new issue. I'm using access 2010, unsure what version database, have on;y access grunt tools to use (no objects, for instance). I have a query that works, it looks like this. The goal of this query is to use one row as a baseline and find all related rows that come after it chronologically. For all I know, this may be a very crude solution.
SELECT QueueA.cnlyMemberId, QueueA.updateUser AS 305UpdateUser, QueueA.updateDt AS 305UpdateDt, QueueB.statusCd
FROM (SELECT cnlyMemberID, updateUser, updateDt
FROM V_Queue_History
WHERE statusCd = "305" AND
V_Queue_History.updateDt Between [Enter Start Date:] And [Enter End Date: (must be at least one day apart)]
) AS QueueA INNER JOIN
V_Queue_History AS QueueB
ON (QueueA.cnlyMemberID = QueueB.cnlyMemberID AND
QueueA.updateDt < QueueB.updateDt
)
Now what I want to do is I want to find the first 305 statusCd and the next statusCd chronologically, rather than every statusCd that follows. I've tried a few things now, mostly trying to take the TOP 2 with an ORDER BY updateDt slipped in the ON condition. Then I tried replacing the V_Queue_History with a table and doing the same, didn't work. I just tried using a where condition where I check to see if the
QueueB.cnlyMemberId is IN (SELECT TOP 2 cnlylMemberID FROM QueueB WHERE conditions);
but still nothing. The system would tell me it didn't know what QueueB was anymore, so none of it would run in the WHERE statement. I would be more specific on but I just made Access crash and my mind is starting to get hazy from how frustrating this can be. I don't have much experience with Access/SQL at all and I'm learning it pretty much as I go.
So to recap, the first query runs fine but I need to return only the row with the status updated first after the initial 305.
Thanks!
I'm not sure what you want without a sample output, maybe something like this would help:
SELECT QueueA.cnlyMemberId, QueueA.updateUser AS 305UpdateUser, QueueA.updateDt AS 305UpdateDt, QueueB.statusCd
FROM (SELECT cnlyMemberID, updateUser, updateDt
FROM V_Queue_History
WHERE statusCd = "305" AND
V_Queue_History.updateDt Between [Enter Start Date:] And [Enter End Date: (must be at least one day apart)]
) AS QueueA INNER JOIN
V_Queue_History AS QueueB
ON QueueA.cnlyMemberID = QueueB.cnlyMemberID
WHERE (QueueB.updateDt =
(SELECT Min(updateDt) FROM V_Queue_History V2
WHERE V2.cnlyMemberID = QueueA.cnlyMemberID
AND V2.updateDt > QueueA.updateDt))
This assumes there is always a status code after the 305, and also that no two records have the same update date.
If you need to get the top N status codes after the 305 then you could change the WHERE clause as following, although I don't know if the performance will be good enough for your situation:
WHERE QueueB.updateDt IN
(SELECT TOP 5 updateDt FROM V_Queue_History V2
WHERE V2.cnlyMemberID = QueueA.cnlyMemberID
AND V2.updateDt > QueueA.updateDt
ORDER BY V2.updateDt)

Core Data SUBQUERY with key-path collection causes SQL error

I'm experiencing a SQL error from a Core Data-generated query. Here's the data model:
I want to get all of the drivers for whose busses have active passengers. This is simply described by the following fetch request and predicate, which works:
NSFetchRequest(entityName: "Driver")
NSPredicate(format: "ANY bus.passengers.active == YES")
However, let's say I want to do a more complex query on the passenger, like they are both active and a balance above 100. To do such a query, I'd have to use a SUBQUERY, like so:
NSPredicate(format: "SUBQUERY(bus.passengers, $passenger, $passenger.active == YES
AND $passenger.balance > 100).#count > 0")
I would expect SUBQUERY to accept a keypathed collection as its first argument. It generates the following SQL query:
SELECT 0,
t0.z_pk,
t0.z_opt,
t0.zbus
FROM zdriver t0
WHERE (SELECT Count(t2.z_3passengers)
FROM zbus t1
JOIN z_1passengers t2
ON t1.z_pk = t2.z_1busses
WHERE ( t0.zbus = t1.z_pk
AND (( t2.zactive = ?
AND t2.zbalance > ? )) )) > ?
And the error: 'no such column: t2.ZACTIVE'. It looks like it's missing a JOIN on the ZPASSENGER table.
Is this a Core Data bug or is there a different way to write this predicate?
Update: Here's a sample project that reproduces this issue.
Try fetching the Bus entity, avoiding the key path in the first argument in the SUBQUERY.
As was pointed out, this can be viewed as a limitation or a bug.
Update:
Further research suggests that your subquery predicate should actually work. I would recommend to check your NSManagedObject subclasses and make sure passengers returns a collection and active is properly listed as an attribute.