Skip to content

Instantly share code, notes, and snippets.

View dorkness-io's full-sized avatar

Dorkness dorkness-io

View GitHub Profile
@dorkness-io
dorkness-io / newproject.sh
Last active June 8, 2020 07:16
A script to simplify the creation of new pyenv-virtualenv environments.
#!/bin/sh
# This script automates most the dirty work in configuring new Python virtual
# environments. It requires that you've installed pyenv and pyenv-virtualenv.
display_usage() {
echo "\nThis script creates and activates pyenv-virtualenv environments."
echo "It requires that you have pyenv and pyenv-virtualenv installed."
echo "\nUsage: $0 <project_name> <python_version>\n"
echo "Example: $0 new_project 3.8.2\n"
/* Let's create a table */
create table some_table (
id integer unique
,some_column text
,other_column numeric
);
/* Let's add a column */
alter table some_table
add column another_column text;
select
p.pkey || '-' || ji.issuenum AS issue_key
,ja.actionbody
from jiraaction ja
full outer join jiraissue ji
on ja.issueid = ji.id
join project p
on p.id = ji.project
where p.pkey = 'TP';
select
p.pkey || '-' || ji.issuenum AS issue_key
,ja.actionbody
from jiraaction ja
right join jiraissue ji
on ja.issueid = ji.id
join project p
on p.id = ji.project
where p.pkey = 'TP';
select
p.pkey || '-' || ji.issuenum AS issue_key
,ja.actionbody
from jiraissue ji
inner join project p
on ji.project = p.id
inner join jiraaction ja
on ji.id = ja.issueid
and actiontype = 'comment'
where p.pkey = 'TP';
select
p.pkey || '-' || ji.issuenum AS issue_key
,ja.actionbody
from jiraissue ji
inner join project p
on ji.project = p.id
left join jiraaction ja
on ji.id = ja.issueid
and actiontype = 'comment'
where p.pkey = 'TP';
drop table if exists weekly_issues;
select
p.pkey || '-' || ji.issuenum AS issue_key
,ji.summary
,ji.reporter
,ji.created
into temp weekly_issues
from jiraissue ji
join project p
select
p.pkey || '-' || ji.issuenum AS issue_key
from jiraissue ji
join project p
on ji.project = p.id
join jiraaction ja
on ji.id = ja.issueid
and actiontype = 'comment'
group by 1
having count(ja.id) >= 10;
@dorkness-io
dorkness-io / aggregates.sql
Created March 19, 2020 19:19
A brief example that retrieves a count of comments per project. We retrieve the counts for each each issue in a sub-select, and then aggregate by project and sum at the top level. Demonstrates the "count" and "sum" aggregate functions.
select
ss.pname
,sum(ss.comment_count) as sum_comments
from (
select
p.pname
,p.pkey || '-' || ji.issuenum AS issue_key
,count(distinct ja.id) as comment_count
from jiraissue ji
join project p
@dorkness-io
dorkness-io / union.sql
Last active March 19, 2020 18:40
An example to illustrate how unions work. This query unions the os_currentstep and os_historystep table to get the timestamps of all status transitions for issues. You'd be much better off using changegroup/changeitem without a union, but I needed an example :)
select
p.pkey || '-' || ji.issuenum AS issue_key
,cs.start_date
from jiraissue ji
join project p
on ji.project = p.id
join os_currentstep cs
on ji.workflow_id = cs.entry_id
union