Skip to content

Commit

Permalink
refactor: style errors from productivity measurement PR (OpenAdaptAI#480
Browse files Browse the repository at this point in the history
)

* check for long gaps in recording

* display basic productivity data in html page similar to visualize

* show images for each window change

* show productivity info for each window

* WIP find tasks/cycles of ActionEvents

* WIP find tasks/cycles of ActionEvents

* WIP implementing brent's algorithm

* implemented brent's algorithm

* add task duration info + style changes to display

* comments

* floyd's algorithm and basic implementation of counting errors

* implement longest repeated non-overlapping substring algorithm

* removed unused code

* small bug fixes

* no empty window titles

* small fixes

* add title

* edge case

* make longest repeated substring recursive

* changed window/tab switching

* add number of actions in a task

* add comments

* make sure no non-repeating tasks are found

* fix off by 1 error with window event screenshots

* remove unused functions, comments, and some refactoring

* docstrings

* black

* Undo changing PLOT_PERFORMANCE

* style changes
  • Loading branch information
angelala3252 authored Aug 25, 2023
1 parent 1485ae4 commit 2089e74
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions openadapt/productivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,33 @@
Usage:
$ python openadapt/productivity.py"
$ python -m openadapt.productivity
"""

from pprint import pformat
from threading import Timer
from typing import Optional, Tuple
import os
import string
from typing import Optional, Tuple

from bokeh.io import output_file, show
from bokeh.layouts import layout, row
from bokeh.models.widgets import Div
from loguru import logger

from openadapt.crud import get_latest_recording, get_window_events

from openadapt.events import (
get_events,
)

from openadapt.events import get_events
from openadapt.models import ActionEvent, WindowEvent
from openadapt.utils import (
configure_logging,
display_event,
image2utf8,
row2dict,
rows2dicts,
)

from openadapt.visualize import IMG_WIDTH_PCT, MAX_EVENTS, dict2html

from openadapt.models import (
ActionEvent,
Screenshot,
WindowEvent,
)

CSS = string.Template(
"""
CSS = string.Template("""
table {
outline: 1px solid black;
}
Expand All @@ -62,8 +51,7 @@
.screenshot:active img:nth-child(1) {
display: block;
}
"""
).substitute(
""").substitute(
IMG_WIDTH_PCT=IMG_WIDTH_PCT,
)

Expand Down Expand Up @@ -178,7 +166,7 @@ def find_num_tasks(
action_events: list[ActionEvent],
start: ActionEvent,
length: int,
task: Optional[ActionEvent] = None,
task: Optional[list[ActionEvent]] = None,
) -> Tuple[list[ActionEvent], int, float]:
"""
Given a list of ActionEvents, the start of a repeating task, the length of the task, and
Expand Down Expand Up @@ -586,13 +574,11 @@ def calculate_productivity():
</table>
""",
),
Div(
text=f"""
Div(text=f"""
<table>
{dict2html(window_info)}
</table>
"""
),
"""),
),
]
)
Expand Down Expand Up @@ -639,13 +625,11 @@ def calculate_productivity():
</table>
""",
),
Div(
text=f"""
Div(text=f"""
<table>
{dict2html(window_info)}
</table>
"""
),
"""),
),
]
)
Expand Down

0 comments on commit 2089e74

Please sign in to comment.