Skip to content

Commit

Permalink
New oldest tasks widget
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoOG committed Mar 6, 2023
1 parent 2d4084c commit 811699a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set up
FROM python:3.8-slim
FROM python:3.10-slim
WORKDIR /app

# Install dependencies
Expand Down
19 changes: 16 additions & 3 deletions pages/02_📈_Productivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def render():
active_tasks = active_tasks[active_tasks["added_at"].apply(lambda x: not pd.isnull(x))]
active_tasks = active_tasks[active_tasks["due_date"].apply(lambda x: pd.isnull(x))]
active_tasks = active_tasks[active_tasks["recurring"].apply(lambda x: not x)]
age_in_days = (date.today() - active_tasks["added_at"].dt.date).dt.days.rename("Age In Days")
active_tasks["age_in_days"] = (date.today() - active_tasks["added_at"].dt.date).dt.days

# Daily goals, velocity and recommendation
col1, col2, col3 = st.columns(3)
Expand Down Expand Up @@ -102,14 +102,27 @@ def render():
"{} tasks".format(active_tasks.shape[0]),
help="Current amount of active tasks.")
col2.metric("Average Age",
"{} days".format(round(age_in_days.mean(), 1)),
"{} days".format(round(active_tasks["age_in_days"].mean(), 1)),
help="Average age since tasks were created.")
col3.metric("Lead time",
"{} days".format(round(active_tasks.shape[0] / day_velocity, 1)),
help="Expected amount of time to complete a task once its created.")
fig, _ = histogram(age_in_days)
fig, _ = histogram(active_tasks["age_in_days"])
st.pyplot(fig)

# Oldest task list
with st.expander("Oldest tasks"):
st.write("")
oldest = active_tasks.sort_values("age_in_days", ascending=False).head(10)
table_str = "| Added Date | Project | Labels | Content | URL |\n"
table_str += "|----|----|----|----|----|\n"
for added, project, labels, task, task_id in zip(oldest["added_at"], oldest["project_name"], oldest["labels"],
oldest["content"], oldest["task_id"]):
table_str += f"| **{added.date()}** | {project} | {', '.join(labels)} | {task} | " \
f"*[open in todoist](https://todoist.com/app/task/{task_id})* | \n"
st.markdown(table_str)
st.write("")


if __name__ == "__main__":
if is_data_ready():
Expand Down
24 changes: 12 additions & 12 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ def refresh_data():
token = run_auth()
if token:
with st.spinner("Getting your data :)"):
colector = get_data(token)
st.session_state["colector"] = colector
st.session_state["tasks"] = colector.items
st.session_state["user"] = colector.user
st.session_state["collecting"] = colector.collecting
collector = get_data(token)
st.session_state["collector"] = collector
st.session_state["tasks"] = collector.items
st.session_state["user"] = collector.user
st.session_state["collecting"] = collector.collecting
st.session_state["data_is_ready"] = True
st.info("Your data is loaded, you can start using this app now.")


def load_more_data():
if 'colector' in st.session_state:
colector = st.session_state["colector"]
if 'collector' in st.session_state:
collector = st.session_state["collector"]
with st.spinner("Getting more data :)"):
colector.collect_more_items()
st.session_state["colector"] = colector
st.session_state["tasks"] = colector.items
st.session_state["user"] = colector.user
st.session_state["collecting"] = colector.collecting
collector.collect_more_items()
st.session_state["collector"] = collector
st.session_state["tasks"] = collector.items
st.session_state["user"] = collector.user
st.session_state["collecting"] = collector.collecting
st.session_state["data_is_ready"] = True
st.info("Your data is loaded, you can start using this app now.")

0 comments on commit 811699a

Please sign in to comment.