Skip to content

Commit

Permalink
update dashboard and added dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanderLaan committed Oct 29, 2024
1 parent d392e54 commit 8e34f85
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.11

WORKDIR /app

RUN apt-get update && apt-get install -y \
build-essential \
python3-gdal \
libgdal-dev \
&& rm -rf /var/lib/apt/lists/*

COPY . .

RUN pip3 install -r requirements.txt

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "wim.py", "--server.port=8501", "--server.address=0.0.0.0"]
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '2'
services:

web:
build: .
ports:
- 8501:8501
volumes:
- .:/app
24 changes: 5 additions & 19 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,20 @@ def read_user_data(username):

# Define the file path based on the username

pickle_file = f"./input_employees/{username}.pkl"
csv_file = f"./input_employees/{username}.csv"



# Check if the file exists

if os.path.exists(pickle_file):

with open(pickle_file, 'rb') as f:

user_data = pickle.load(f)

if os.path.exists(csv_file):


# Convert the stored weeks data into a DataFrame

if 'weeks' in user_data:
user_data = pd.read_csv(csv_file)

df = pd.DataFrame.from_dict(user_data['weeks'], orient='index').reset_index()

df.columns = ['week', 'druk', 'note'] # Rename columns

return df

else:

return pd.DataFrame(columns=['week', 'druk', 'note']) # Return empty DataFrame if no weeks data

return user_data


else:
Expand All @@ -190,6 +176,7 @@ def read_user_data(username):
# checks all employees files based on list of employees and creates for selected week overview of work pressure of each employee
# if employee didn't fill form for selected week, it will be listed as bad_employee and shamed in dashboard
def create_week_planning_team(week_number, employees_list):
print(week_number)
df_current_week = pd.DataFrame(columns=['name', 'druk', 'note', 'color'])
good_employees = []
bad_employees = []
Expand All @@ -200,7 +187,6 @@ def create_week_planning_team(week_number, employees_list):

# check if it is filled in
filled_in = planning_employee_cw['druk'].isin(['Afwezig', 'Heel Rustig', 'Rustig', 'Goed', 'Druk', 'Heel druk']).any()


if filled_in == True:
good_employees += [employee]
Expand Down
6 changes: 3 additions & 3 deletions input_employees/esther.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
week,druk,note
week,druk,note
37,druk,hallo
38,heel rustig,yooo
39,goed,doei
40,,
41,,
42,,
43,,
44,,
45,,
44, Druk,wimmm
45,Goed,lekker werken
46,,
47,,
48,,
Expand Down
4 changes: 3 additions & 1 deletion wim.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if submitted:
selected_category = selected_category[2:]
print(selected_category)
update_user_data(username, week_numbers, selected_category, notes)
update_user_csv(username, week_numbers, selected_category, notes)


elif nav == 'overzicht':
Expand Down Expand Up @@ -130,7 +130,9 @@
import datetime
with tab1:
current_week_number = datetime.datetime.now().isocalendar()[1]

current_week_planning, bad_employees = create_week_planning_team(current_week_number, employees_list)
#print(current_week_planning)
graph_current_week = create_overview_graph(current_week_planning, current_week_number)

# place graphic on right spot
Expand Down

0 comments on commit 8e34f85

Please sign in to comment.