How to find task status of any developer on daily basis through JIRA - jira

I am looking to generate a report with the following columns through JIRA. A nearby query may also work for me.
Date | Assignee Name | Number of tasks | Type of Tasks Task/Bug | JIRA Ids | TAT (In Days) | Total Reopen | Reopened JIRA Ids

Related

How to return a list of users who should be notified of an appointment at a set time each day

I have a list of users who need to be notified at different times per day, and based on their timezone.
So I have essentially 2 tables: Schedule and User
Schedule
-id
-scheduled_time
Users
-id
-schedule_id
-timezone
So there could be a schedule for 9AM.
Users who are associated with this 9AM schedule, by they also have their timezone set to UTC -4 or UTC -5.
I will have a service that will Poll every x minutes to query the database.
Is this a query I can perform in postgresql directly or is this application dependant and based on the ORM I am using?
Parsing timestamps for time of day just sounds annoying and I recommend doing it from your Rails models.
If you're dead set on doing it from the database, see this question: Convert a UTC timezone in postgresql to EST (local time), and here's another article describing how to work with time zones in postgres: http://blog.untrod.com/2016/08/actually-understanding-timezones-in-postgresql.html.
But my sense is you'll get a simpler and easier solution if you use ActiveSupport::TimeWithZone maths, in order to associate each user with a given UTC time at which to notify them.
Example:
Schedule X runs at 16:00 UTC and schedule Y runs at 17:00 UTC.
User A is in UTC-0700 (PDT) and User B is in UTC-0600 (Mountain).
If B wants to be notified at 10:00 AM, then do the math in your application in order to associate them with Schedule X.
If A wants to be notified at 10:00 AM, then do the math in your application in order to associate them with Schedule Y.
Let me know if you would need help with the specifics. Hints:
The Time of Day gem offers a nice way to work with times of day, including time zone maths.
https://github.com/jackc/tod
https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html
I will have a service that will Poll every x minutes to query the database.
Is this a query I can perform in Postgresql directly ... ?
Yes, you can. Imagine the use of the PostgreSQL-server time (function now() or current_timestamp) something as
SELECT u.*
FROM schedule s INNER JOIN users u
ON u.schedule_id=s.id
WHERE now()::time=(s.scheduled_time+u.timezone)
But, as we will see, the "every x minutes" can't sync with the Schedule table. There are two ways for sync:
using <= and updating the table with a boolean day-flag at users (cleaning every day after 24hs to re-scheduling). No risk.
using = with a round(time,x) here... Perhaps with a very little risk when your hypothesis of "every x minutes" is not perfect.
Lets simulate all the thing:
CREATE TABLE schedule (id serial PRIMARY KEY, scheduled_time time);
INSERT INTO schedule (scheduled_time) VALUES
(now()), ('9:00AM'::time), ('16:30'::time);
CREATE TABLE users (
id serial,
schedule_id int references schedule(id),
timezone interval -- see pg_timezone_names.utc_offset
);
INSERT INTO users (schedule_id,timezone) VALUES
(2, '00:00:00'::interval), (2, '-04:00:00'::interval), (1, '-05:00:00'::interval),
(1, '-05:00:00'::interval), (1, '-04:00:00'::interval), (2, '-05:00:00'::interval);
CREATE VIEW vw_user_scheduled AS
SELECT u.*, s.scheduled_time, s.scheduled_time+u.timezone AS ref_time
FROM schedule s INNER JOIN users u
ON u.schedule_id=s.id
;
The samples vw_user_scheduled are:
id | schedule_id | timezone | scheduled_time | ref_time
----+-------------+-----------+-----------------+-----------------
1 | 2 | 00:00:00 | 09:00:00 | 09:00:00
2 | 2 | -04:00:00 | 09:00:00 | 05:00:00
3 | 1 | -05:00:00 | 20:54:27.898109 | 15:54:27.898109
4 | 1 | -05:00:00 | 20:54:27.898109 | 15:54:27.898109
5 | 1 | -04:00:00 | 20:54:27.898109 | 16:54:27.898109
6 | 2 | -05:00:00 | 09:00:00 | 04:00:00
Supposing you adopt the round-solution and x=5 (service that will Poll every 5 minutes to query the database), the users of scheduled_time 9AM (server time) will be not the set {id=1, id=2 and id=6} as column scheduled_time shows, but only user id=1 of the correct ref_time.
SELECT * from vw_user_scheduled
WHERE round_minutes(ref_time,5)=round_minutes(now(),5)
The cited round time adapted to time datatype.
CREATE FUNCTION round_minutes(time, integer) RETURNS time AS $$
SELECT
date_trunc('hour', $1)::time
+ (cast(($2::varchar||' min') as interval)
* round(
(date_part('minute',$1)::float + date_part('second',$1)/ 60.)::float
/ $2::float
))
$$ LANGUAGE SQL IMMUTABLE STRICT;
PS: as the question not show your SQL table, there are many ways to model time and time zone formats at tables.

Rails finder method that finds an entity that is just more than 24 hours away?

I'm using Rails 5 and PostgreSQL 9.5. I have a table with the following columns .
cindex=# \d crypto_index_values;
Table "public.crypto_index_values"
Column | Type | Modifiers
------------+-----------------------------+------------------------------------------------------------------
id | integer | not null default nextval('crypto_index_values_id_seq'::regclass)
value | double precision |
index_date | timestamp without time zone | not null
created_at | timestamp without time zone | not null
updated_at | timestamp without time zone | not null
Given a point in time (say "2017-07-29 11:10") stored in a variable "my_date", how would I write a Rails finder query that returns a single Rails entry that returns the row with the smallest "index_date" that was also at least 24 hours away from "my_date"? So if I had this table data
14 | 133.951211424387 | 2017-07-31 19:10:03.235566 | 2017-07-29 19:10:03.267727 | 2017-07-31 19:10:03.267727
15 | 133.951211424387 | 2017-07-31 19:20:03.59569 | 2017-07-28 19:20:03.629418 | 2017-07-31 19:20:03.629418
16 | 139.104155235946 | 2017-07-31 19:30:08.037045 | 2017-07-31 19:30:08.04715 | 2017-07-31 19:30:08.04715
and given my example, I would expect the query to return the row with id "15" because the row with id "14" is not 24 hours away from my example. Normally this kind of query would work
CryptoIndexValue.where('index_date = ?', my_date - 1)
but since there isn't an entry exactly 24 hours away, it doesn't.
I don't think your example values quite work -- at least I don't see how you would choose that value from the table with that index date, subtracting a day. Do you mean "the row with the earliest date which is also at least 1 day in the future from my_date"?
CryptoIndexValue.
where('index_date > ?', my_date + 1.days).
order(:my_date, :id).
take
I added :id to the order by in case you need a tie-break on two rows that have the same index_date, but remove it if that's impossible due to a constraint.
Maybe you mean to subtract one day instead of adding, though.
You should use > operator combined with order.
CryptoIndexValue.order(:index_date).find_by('index_date > ?', DateTime.now - 24.hours)

Total hours of overtime

I keep a google spreadsheet where I enter hours worked per day. I'm supposed to work 8 hours per day and anything more than that is overtime.
So I need to check if a value in the column with hours is greater than 8. If so I want the difference between 8 and the value entered, added to or accumulated in another cell so that I can see how many hours of overtime I have worked. Also if the value is less than 8 then I need to make a deduction.
Can anyone help me with such a formula?
Let's say your hours are entered in column B, and start on row 2. In a column further along, put the following formula:
=if(B2>8,B2-8,0)
This first checks whether that day have any overtime =if(B2>8 - if it does, it calculates how much B2-8 - if it doesn't, it shows 0 instead.
Then, underneath that column, you can sum for your answer. It will look something like this.
A | B | C
Day | Hours | Overtime
------------------------------
Monday | 8 | =if(B2>8,B2-8,0)
Tuesday | 9 | =if(B3>8,B3-8,0)
Wednesday | 9 | =if(B4>8,B4-8,0)
Thursday | 8 | =if(B5>8,B5-8,0)
Friday | 10 | =if(B6>8,B6-8,0)
------------------------------
Total | Total | =SUM(C2:C6)

Public activity select unique foreign keys by created time

I'm looking to do a query for an activity object in my app. I'm using the public_activity gem and I have a list of activities which are connected to several models and I would like to list out the most recent unique activity.
Basically I would like to query the most recent activity for a particular tracking. Let's say that I'm tracking the like button and it's ID is 29. I want to query out the most recent (one) instance of tracking ID=29 and other tracking IDs. I don't know the querying for rails too well. Right now this is the only line I have which displays all activity:
#activities = PublicActivity::Activity.order("created_at desc").where(owner_id: current_user.id)
Let's say I have a table of activities as follows:
id activity_id description created_on
1 3 Like yesterday
2 3 Unlike two days ago
3 6 Comment yesterday
4 7 Review yesterday
5 7 Review two days ago
I want to pull out the most recent entries of each activity ID into the #activities variable like the following:
id activity_id description created_on
1 3 Like yesterday
3 6 Comment yesterday
4 7 Review yesterday
Does public_activity have a workaround for this?
You can use a combination of group and select to accomplish this.
PublicActivity::Activity.
select("MAX(created_at) as when, trackable_type").
group("trackable_type").
where(owner_id: current_user.id)
Here's the output
+-------------------------+-------------------------+
| trackable_type | when |
+-------------------------+-------------------------+
| Report | 2015-11-27 20:25:31 UTC |
| QuickAnswer | 2016-01-04 23:36:21 UTC |
| Comment | 2015-10-23 15:35:32 UTC |
| TakenExam | 2016-01-04 23:46:11 UTC |
| SeenVideo | 2015-08-23 21:27:58 UTC |
| Provider | 2015-09-17 23:47:40 UTC |
| AnswerForRecommendation | 2015-08-18 15:13:03 UTC |
| Subscription | 2015-08-24 08:37:08 UTC |
+-------------------------+-------------------------+

Primefaces calendar pop up with out year field

In primefaces (Version 3) , can I make a calendar pop up having date and month only (no year selection is required).
From the Primefaces User Guide 3.0:
NAME | Default | Type | Description
showOtherMonths | FALSE | Boolean | Displays days belonging to other months.
selectOtherMonths | FALSE | Boolean | Enables selection of days belonging to
other months.
This should hide the view and selection of other months, possibly preventing the selection of other years (it has to have a year, but maybe you can hide it from the user).
yearRange | null | String | Year range for the navigator, default
"c-10:c+10"
Perhaps you can use the yearRange attribute above in conjunction to limit the range to a single year as well.
You can use mindate and maxdate attributes to restrict year selection:
<p:calendar mindate="#{dataItem.LOWER_RANGE}" maxdate="#{dataItem.UPPER_RANGE}"/>

Resources