-
Notifications
You must be signed in to change notification settings - Fork 0
/
Recent.py
38 lines (31 loc) · 1.25 KB
/
Recent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import streamlit as st
from utils import get_connection, get_sidebar_filters
def main():
st.set_page_config(layout="wide")
conn = get_connection()
filters = get_sidebar_filters(conn)
last_commits = conn.sql(f"""
SELECT repo, message, author_when, author_name, author_email
FROM git_commits JOIN repos ON git_commits.repo_id=repos.id
WHERE {filters.commit_filter} ORDER BY author_when DESC LIMIT 100
""", params=filters.commit_params).df()
st.markdown("### Last commit activity")
st.dataframe(last_commits, hide_index=True)
last_projects = conn.sql(f"""
WITH maxdate AS (
select (date_trunc('day', max(author_when)) - interval '7 day')::date as maxdate
from git_commits JOIN repos ON git_commits.repo_id=repos.id
WHERE {filters.commit_filter}
)
SELECT repo, count(hash), max(author_when)
FROM git_commits JOIN repos ON git_commits.repo_id=repos.id
WHERE {filters.commit_filter}
AND author_when > (SELECT maxdate FROM maxdate)
GROUP BY repo
ORDER BY count(hash) DESC LIMIT 100
""", params=filters.commit_params).df()
st.markdown("### Most active in last 7 days")
st.dataframe(last_projects, hide_index=True)
if __name__ == '__main__':
main()