open-bounty/resources/migrations/20170226230237-activity-feed.up.sql
Teemu Patja 2599b85d41
WIP: Activity feed feature
* backend support for activity feed
* partial frontend support (still needs work)
* save issue modification timestamp to db
* rename commit-id -> commit-sha everywhere for consistency
* "No data" texts for UI collections when no data exists
2017-02-26 23:43:57 +02:00

88 lines
1.6 KiB
SQL

create view bounties_view as
select
i.title as issue_title,
i.issue_number,
r.repo as repo_name,
u.name as user_name,
u.avatar_url as user_avatar_url,
i.payout_receipt,
i.balance,
i.updated as updated
FROM issues i, users u, repositories r
WHERE r.repo_id = i.repo_id
AND r.user_id = u.id
and contract_address is not null
and comment_id is not null
order by updated;
create view claims_view as
select
i.title as issue_title,
i.issue_number,
r.repo as repo_name,
u.name as user_name,
u.avatar_url as user_avatar_url,
i.payout_receipt,
p.updated as updated,
i.balance,
p.state as pr_state
FROM issues i, users u, repositories r, pull_requests p
WHERE r.repo_id = i.repo_id
AND p.issue_id = i.issue_id
AND p.user_id = u.id
and i.contract_address is not null
and i.comment_id is not null
order by p.updated;
create view activity_feed_view as
select 'open-claim' as type,
issue_title,
repo_name,
issue_number,
user_name,
user_avatar_url,
balance,
updated
from claims_view
where
pr_state=0
and payout_receipt is null
union
select 'claim-payout' as type,
issue_title,
repo_name,
issue_number,
user_name,
user_avatar_url,
balance,
updated
from claims_view
where
pr_state=1
and payout_receipt is not null
union
select 'new-bounty' as type,
issue_title,
repo_name,
issue_number,
user_name,
user_avatar_url,
balance,
updated
from bounties_view
where balance=0
and payout_receipt is null
union
select 'balance-update' as type,
issue_title,
repo_name,
issue_number,
user_name,
user_avatar_url,
balance,
updated
from bounties_view
where balance>0
and payout_receipt is null
order by updated desc;