Jira - JQL - Field Text Lenght - jql

To be honest - the health of a backlog can be quickly determined by the length of a few text field lengths:
Where project = fooBar AND Status != Done or Status != To Do AND
Description < 50 characters OR
Acceptance Criteria < 50 characters OR
Definition of Done < 50 characters OR
Links to Design != null
If this was SQL I could do a query easily. Does JQL have a query where I can easily do that?

Related

RegEx for multiline search and replace in SQL query code

There is a lot of qualified documents on the Internet regarding the topic of "search and replace using regular expressions". Only few of them show how to do this in a multiline context. Even fewer show indicate how to generate a regex for several items therein.
I have tried both installable RegEx tools within editors (EditPad Pro, RJ TextED, EmEditor, Notepad++, Sublime Text 3, Visual Studio Professional 2019, the latest JetBrains PHPstorm version, and others) and online RegEx services (regular expressions 101, RegExr) the entire day, read the answers on StackOverflow which corresponded to my title criteria, and additionally tried to make the most of various online tutorials.
You make call me stupid, but I have not been able to understand whether the following concept is feasible at all
The part of the SQL query I want to change is the following one:
AND op.OP1OPVerfahren > 0
AND p.Testzwecke = 0
AND NOT EXISTS (SELECT DISTINCT 1 FROM ods39.dat_optherapie op2 WHERE op2.patID = p.ID AND op2.revision > op.revision)
UNION ALL
Legend:
op.OP1OPVerfahren is the database field for the first surgery performed, 10 surgical procedures can be documented (OP1OPVerfahren until OP10OPVerfahren)
p.Testzwecke is a JOIN to the patient's personal data such as first name, last name, etc.
ods39.dat_optherapie is the table dat_optherapie from database ods39 - the system consists of 50 MySQL databases of the exact same structure
p.ID is merely the patient's ID
op.revision is an autoincrementing tracker of how many data record sets for the same surgical procedure have been saved (sometime revisions in the sense of precisions are required)
The above-mentioned part of the query has a quantitative complexity associated: Within the query, this segment appears 780 times in the following variation:
AND **op.OP1OPVerfahren** _up_to_ **op.OP10OPVerfahren** > 0
AND p.Testzwecke = 0
AND NOT EXISTS (SELECT DISTINCT 1 FROM **ods01.dat_optherapie** _up_to_ **ods39.dat_optherapie** op2 WHERE op2.patID = p.ID AND op2.revision > op.revision)
UNION ALL
To fully understand what I want to solve here the expression I want to replace the fore-mentioned with:
AND **op.OP1OPVerfahren** _up_to_ **op.OP10OPVerfahren** > 0
AND p.Testzwecke = 0
AND NOT EXISTS (SELECT DISTINCT 1 FROM **ods01.dat_optherapie** _up_to_ **ods39.dat_optherapie** op2 WHERE op2.patID = p.ID AND op2.revision > op.revision)
GROUP BY **OP1OPVerfahren** _up_to_ **OP10OPVerfahren**
UNION ALL
The op.OP_x_OPVerfahren (x = 1 to 10) from the very first line and the OP_x_OPVerfahren (x = 1 to 10) within the GROUP BY statement are numerically correlated to each other, i. e. when I want to change my replacing procedure from op.OP1OPVerfahren along 39 databases to op.OP2OPVerfahren for again 39 databases and so on, the GROUP BY numbers shall change accordingly.
Now, this replacement shall be carried out for all 39 databases. The entire SQL query code is about 20.000 lines of code - my reason why I do not want to spend hours on replacing manually as there are more such SQL query structures in different files which need replacing in a similar fashion.
To give you an example:
The code ...
AND op.OP1OPVerfahren > 0
AND p.Testzwecke = 0
AND NOT EXISTS (SELECT DISTINCT 1 FROM ods39.dat_optherapie op2 WHERE op2.patID = p.ID AND op2.revision > op.revision)
UNION ALL
... needs to be expanded with a GROUP BY OP1OPVerfahren before the UNION ALL for the 39 databases ods01 up to ods39, accordingly. Then with op.OP2OPVerfahren and OP2OPVerfahren for the same 39 databases again until (op.)OP10OPVerfahren is finally reached (= 780 replacements).
The newly inserted GROUP BY statement's OP_x_... counting shall have the same number as the op.OP_x_... numbering.
I have experimented with tons of different regex statements (such as \d\d, (\d)(\d), \d{2}, and many others according to the individual needs of the above-mentioned editors I used) but I was not able to find out how to make one "number detection" (op.OP_x_OPVerfahren and OP_x_OPVerfahren) dependent on the "number detection" from the databases ods_x_.dat_optherapie).
I would greatly appreciate a bit of help from your most valuable experience and expertise, and I would also be very thankful for receiving further recommendations for other than the mentioned editors with a good (and maybe even testable) regex handling.
We can make this work using a regex replace like this:
(AND\ +op\.(OP\d0?OPVerfahren)\ *>\ *0\s+AND\ +p\.Testzwecke\ *=\ *0\s+AND\ +NOT\ +EXISTS\ *\(SELECT\ +DISTINCT\ +1\ +FROM\ +ods[0123][0-9]\.dat_optherapie\ +op2\ +WHERE\ +op2\.patID\ *=\ *p\.ID\ +AND\ +op2\.revision\ *>\ *op\.revision\))(\s+UNION\s+ALL)
Demo
It's sticks rather tight to the original string and mostly only introduces variable-length quantifiers for whitespace characters. When there is a \ * an optional space may occur, if the space is mandatory \ + is used. Otherwise the whitespace shorthand character \s is used to allow not only spaces but newlines and alike. To make it work, enable the s|singleline flag (or add (?s) in front of the pattern).
I believe something like the following regex find/replace expressions will do what you are asking:
Find:
AND op.OP(\d{1,2})(OPVerfahren.*?\))
Replace with:
AND op.OP$1$2 \n GROUP BY OP$1OPVerfahren
Note that it needs the "global" and "dot matches newline" options set for the regex.
To briefly explain, this has 2 capturing groups, one for the digit(s) between op.OP and OPVerfahren and the second to capture everything after that up to the closing bracket of the "(SELECT DISTINCT... ). These are then used as $1 and $2 in the replacement section of the regex.
Test example here. I believe this should work in Notepad++.
(By the way, I think your "GROUP BY OP1Verfahren" should be "GROUP BY OP1OPVerfahren" right? i.e. 2 lots of "OP"s!)

MS Access - multiple count from same table

First time poster...
I am using access to build a report for alarms from a control system. The list is an export from the alarm utility which needs needs 3 important bits of data:
Module - Name of instrument associated with alarm
Description - description of the instrument
Alarm type - High, High High etc.
I would like to do a top ten of all the alarms but the issue I'm having is that the instrument module contains multiple different types of alarms and I need to filter for each one. I used the group by then count, but it takes all instances of module and does not break it down.
I am not very good at SQL and access and I'm sure its a simple fix.
Any help would be appreciated
I you want multiple count from same table you can write the query like below
record = session.createSQLQuery("select count(village_id),count(date_of_action), from TABLE_NAME where CONDITION ORDER BY date_of_action DESC" ).list();
if (record != null && record.size() > 0) {
for(Object[] obj:(List<Object[]>)record ){
int i = 0;
BigInteger villageCounts = (BigInteger)obj[i];
BigInteger memberCounts = (BigInteger)obj[++i];

How to extract multiple substring keywords in SQL Server and show results in multiple columns?

I have a table called Usage and there is a column called TEXT.
This TEXT columns holds a string value that looks something like this below.
"TIME EXPENSE ACCRUALS COST DC WITH RATES XX INTEGRATION TIME OD TRAVEL..."
I would like to write a SQL query that would search this column by the selected keywords like TIME or TIME OD or COST, etc., and if the search is true return a check or X that represent that there is that keyword in there or nothing if it doesn't.
For example, if I ran a substring looking for my keywords, my results would like this:
I hope this helps identify what I'm looking for. Any help would be appreciated.
Image of current data fields
How about:
select
section,
name,
case when charindex('TIME', text) > 0 then 'X' else '' end as Time,
case when charindex('EXPENSE', text) > 0 then 'X' else '' end as Expense,
... all other columns here
from usage;

oracle text definescore with accum and Query rewriting

I am using Oracle text to search in a corpus of sentences
I want the scoring to be as counting the discrete occurrences only,
Example : My Query is ( dog cat table )
If it found the term " dog " it must count 1 even if the sentence has more than one "dog" term. If it found " dog cat " it must count 2 ... etc
I used this query, but it gives me 51 if it finds the two terms. I need to accumulate the discrete occurrences. So I want to override the behaviour of the scoring algorithm of Oracle Text.
select /*+ FIRST_ROWS(1)*/ sentence_id
,score(1) as sc
, isn
,sentence_length
from plag_docsentences
where contains(PROCESSED_TEXT,'DEFINESCORE(dog, DISCRETE*.01)
,DEFINESCORE(cat, DISCRETE*.01)'
,1)>0
order by score(1) desc
OK, I Solved that Issue.
suppose I find 2 terms out of 3, the score will be 67
which means ( 2/3=67 ) this is the default behavior of oracle text scoring alg.
so I derived an equation to find the number of occurrences (i.e number of terms in query found in the corpus sentence)
as follows:
x/query_lenght = score/100
then
x=query_lenght * score/100
this will find the number of matching words between the query and the corpus query
I hope this will help reasearchers in IR.

Oracle 'Contains' / 'Group' function return incorrect value

I have this query:
SELECT last_name, SCORE(1)
FROM Employees
WHERE CONTAINS(last_name, '%sul%', 1) > 0
It produces output below:
The question is:
Why does the SCORE(1) produce 9? As I recall that CONTAINS function returns number of occurrences of search_string (in this case '%sul%').
I expect the output should be:
Sullivan 1
Sully 1
But when I try this syntax:
SELECT last_name, SCORE(1)
FROM Employees
WHERE CONTAINS(last_name, 'sul', 1) >0;
It returns 0 rows selected.
And can someone please explain me what is the third parameter for?
Thanks in advance :)
The reason your second query is returning no rows is, you are looking for word sul in your search. Contains will not do pattern search unless you tell it to, it searches for words which you specified as your second paramter. To look for patterns, you will have to use wildcards, as you did in your first example.
Now, coming to the third parameter in CONTAINS - it is label and is just used to label the score operator. You should use the third parameter when you use SCORE in your SELECT list. It's importance is more clear when there are multiple SCORE operators
Quoting directly from documentaion
label
Specify a number to identify the score produced by the query.
Use this number to identify the CONTAINS clause which returns this
score.
Example
Single CONTAINS
When the SCORE operator is called (for example, in a SELECT clause),
the CONTAINS clause must reference the score label value as in the
following example:
SELECT SCORE(1), title from newsindex
WHERE CONTAINS(text, 'oracle', 1) > 0 ORDER BY SCORE(1) DESC;
Multiple CONTAINS
Assume that a news database stores and indexes the title and body of
news articles separately. The following query returns all the
documents that include the words Oracle in their title and java in
their body. The articles are sorted by the scores for the first
CONTAINS (Oracle) and then by the scores for the second CONTAINS
(java).
SELECT title, body, SCORE(10), SCORE(20) FROM news WHERE CONTAINS
(news.title, 'Oracle', 10) > 0 OR CONTAINS (news.body, 'java', 20) > 0
ORDER BY SCORE(10), SCORE(20);
The Oracle Text Scoring Algorithm does not score by simply counting the number of occurrences. It uses an inverse frequency algorithm based on Salton's formula.
Inverse frequency scoring assumes that frequently occurring terms in a document set are noise terms, and so these terms are scored lower. For a document to score high, the query term must occur frequently in the document but infrequently in the document set as a whole.
Think of a google search. If you search for the term Oracle you will not find (directly) any result that may help to explain your scoring value questioning, so we can consider this term a "noise" to your expectations. But if you search for the term Oracle Text Scoring Algorithm you will find your answer in the first google result.
And about your other questionings, I think that #Incognito already gives them a good answer.