aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2023-05-16 14:11:51 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2023-05-16 14:11:51 +0100
commit953dc5ef8652a0b7e8ae2c7db3535f1bd157cdd4 (patch)
tree08a4c9cd4f10a12927f7c57056617672369ed9b6
parent0faf95d56815d310290d3533d81d888deb7731f0 (diff)
downloadUKGenderPayGap-953dc5ef8652a0b7e8ae2c7db3535f1bd157cdd4.tar.gz
UKGenderPayGap-953dc5ef8652a0b7e8ae2c7db3535f1bd157cdd4.zip
Added alt text, docker
-rw-r--r--Dockerfile12
-rw-r--r--charts.json71
-rw-r--r--docker-compose.yml22
-rw-r--r--requirements.txt2
-rw-r--r--src/app.py (renamed from app.py)20
-rw-r--r--src/charts.json77
-rw-r--r--src/database.py (renamed from database.py)0
-rw-r--r--src/insinuations.py (renamed from insinuations.py)0
-rw-r--r--src/parser.py (renamed from parser.py)0
-rw-r--r--src/static/scripts.js (renamed from static/scripts.js)0
-rw-r--r--src/static/style.css (renamed from static/style.css)6
-rw-r--r--src/static/ukcounties.json (renamed from static/ukcounties.json)0
-rw-r--r--src/templates/index.html.j2 (renamed from templates/index.html.j2)4
-rw-r--r--src/templates/plot.html.j28
-rw-r--r--src/templates/search.html.j2 (renamed from templates/search.html.j2)0
-rw-r--r--src/templates/template.html.j2 (renamed from templates/template.html.j2)2
-rw-r--r--templates/plot.html.j28
17 files changed, 144 insertions, 88 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..70a11f6
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM ubuntu:20.04
+MAINTAINER Eden Attenborough "gae19jtu@uea.ac.uk"
+ENV TZ=Europe/London
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+RUN apt-get update -y
+RUN apt-get install -y python3-pip
+COPY . /app
+RUN touch .docker
+WORKDIR /app
+RUN pip3 install -r requirements.txt
+ENTRYPOINT ["python3"]
+CMD ["src/app.py", "--production"] \ No newline at end of file
diff --git a/charts.json b/charts.json
deleted file mode 100644
index 4b266aa..0000000
--- a/charts.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "index": [
- {
- "title": "Median Hourly Pay by County or Local Authority: Choropleth Map",
- "url": "/plot/heatmap",
- "filters": {
- "Year": "<Years>"
- }
- },
- {
- "title": "Median Hourly Pay Difference by Year",
- "url": "/plot/years?Pay+Type=Hourly",
- "filters": {
- "Pay Type": {
- "options": [
- "Hourly",
- "Bonuses"
- ],
- "default": "Hourly"
- },
- "SIC Type": "<SICType>",
- "Employer Type": "<CompanyType>",
- "Employer Size": "<CompanySize>"
- }
- },
- {
- "title": "Median Bonus Pay Difference by Year",
- "url": "/plot/years?Pay+Type=Bonuses",
- "filters": {
- "Pay Type": {
- "options": [
- "Hourly",
- "Bonuses"
- ],
- "default": "Bonuses"
- },
- "SIC Type": "<SICType>",
- "Employer Type": "<CompanyType>",
- "Employer Size": "<CompanySize>"
- }
- },
- {
- "title": "Median Hourly Pay Difference by SIC Section",
- "url": "/plot/sic_sec?Pay+Type=Hourly",
- "filters": {
- "Pay Type": {
- "options": [
- "Hourly",
- "Bonuses"
- ],
- "default": "Hourly"
- },
- "Year": "<Years>"
- }
- },
- {
- "title": "Median Bonus Pay Difference by SIC Section",
- "url": "/plot/sic_sec?Pay+Type=Bonuses",
- "filters": {
- "Pay Type": {
- "options": [
- "Hourly",
- "Bonuses"
- ],
- "default": "Bonuses"
- },
- "Year": "<Years>"
- }
- }
- ]
-} \ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..dad3c33
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,22 @@
+version: '3'
+
+services:
+ paygap:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ image: jwansek/paygap
+ ports:
+ - "5006:5006"
+ networks:
+ - db-network
+ external_links:
+ - mariadb:mysql
+ restart: unless-stopped
+ env_file:
+ - db.env
+
+networks:
+ db-network:
+ external:
+ name: mariadb \ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 0dad989..dc0ba2d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,5 @@ python-dotenv
flask
requests
pandas
+PasteScript==3.2.0
+waitress
diff --git a/app.py b/src/app.py
index d5d6ef1..aa0d2b7 100644
--- a/app.py
+++ b/src/app.py
@@ -1,14 +1,17 @@
+from paste.translogger import TransLogger
+from waitress import serve
import database
import urllib.parse
import flask
+import sys
import json
import os
app = flask.Flask(__name__)
-if not os.path.exists(".docker"):
+if not os.path.exists(os.path.join(os.path.dirname(__file__), "..", ".docker")):
import dotenv
- dotenv.load_dotenv(dotenv_path = "db.env")
+ dotenv.load_dotenv(dotenv_path = os.path.join(os.path.dirname(__file__), "..", "db.env"))
host = "srv.home"
else:
host = "db"
@@ -25,7 +28,7 @@ def serve_index():
)
def get_charts():
- with open("charts.json", "r") as f:
+ with open(os.path.join(os.path.dirname(__file__), "charts.json"), "r") as f:
return json.load(f)
@app.route("/api/charts.json")
@@ -160,11 +163,18 @@ def serve_large_plot(name):
"plot.html.j2",
title = elem["title"],
elem = elem,
- alt = "Lorem ipsum.",
+ alt = elem["description"],
filters = filters,
current_filters = current_filters,
len = len
)
if __name__ == "__main__":
- app.run("0.0.0.0", port = 5005, debug = True) \ No newline at end of file
+ try:
+ if sys.argv[1] == "--production":
+ #serve(TransLogger(app), host='127.0.0.1', port = 6969)
+ serve(TransLogger(app), host='0.0.0.0', port = 5006, threads = 32)
+ else:
+ app.run(host = "0.0.0.0", port = 5005, debug = True)
+ except IndexError:
+ app.run(host = "0.0.0.0", port = 5005, debug = True) \ No newline at end of file
diff --git a/src/charts.json b/src/charts.json
new file mode 100644
index 0000000..8624fec
--- /dev/null
+++ b/src/charts.json
@@ -0,0 +1,77 @@
+{
+ "index":
+ [
+ {
+ "title": "Median Hourly Pay by County or Local Authority: Choropleth Map",
+ "url": "/plot/heatmap",
+ "filters": {
+ "Year": "<Years>"
+ },
+ "description": "A chloropleth map showing gender pay inequality data in the counties or local authorities of the United Kingdom. The general trend is that women get paid 5-15% less but there are some areas in the South of England where women get paid 15% less hourly. There are some parts of South Wales, North Wales or Northern Ireland where women get paid slightly more. In some parts of Scotland hourly pay is nearly equal. The user can adjust the time frame of the data being shown, back to 2017. The default is all years. The general trend is as time continues forwards, fewer parts of the country have equal pay and more pay inequality appears on the map. As with all chloropleth maps, it is important to consider population density."
+ },
+ {
+ "title": "Median Hourly Pay Difference by Year",
+ "url": "/plot/years?Pay+Type=Hourly",
+ "filters": {
+ "Pay Type": {
+ "options": [
+ "Hourly",
+ "Bonuses"
+ ],
+ "default": "Hourly"
+ },
+ "SIC Type": "<SICType>",
+ "Employer Type": "<CompanyType>",
+ "Employer Size": "<CompanySize>"
+ },
+ "description": "A line plot showing hourly gender pay inequality data from 2017 to today. Hourly pay for women is 12-15% lower for all time periods and hasn't changed much. The user can filter down the data into SIC Categories (SIC is a system of codes to describe what an employer does), employer types (for example a private corporation or overseas entity) and the employer size. The overral trend doesn't change much with these filters, but some fields have more or less gender inequality in hourly pay. For example social work activities, and the accomodation and food industry typically have less inequality, i.e. 6-10% less. The areas with the greatest inequality are in the construction, financial services and education industries, where it can be 20-25% less per hour. Public sector employers typically have more pay inequality, from around 13% to 17%. In terms of number of employees, the general trend is that the more employees an employer has, the less pay inequality there is: From 13% to 9%."
+ },
+ {
+ "title": "Median Bonus Pay Difference by Year",
+ "url": "/plot/years?Pay+Type=Bonuses",
+ "filters": {
+ "Pay Type": {
+ "options": [
+ "Hourly",
+ "Bonuses"
+ ],
+ "default": "Bonuses"
+ },
+ "SIC Type": "<SICType>",
+ "Employer Type": "<CompanyType>",
+ "Employer Size": "<CompanySize>"
+ },
+ "description": "A line plot showing median bonus pay in a time-series from 2017 to today. In 2017 to 2018 the women received more bonuses than men but in previous years this trend has reduced (from +7% to -7% approximately). The user can filter down the plot according to SIC Categories (SIC is a system of codes to describe what an employer does), employer types (for example a private corporation or overseas entity) and the employer size. The general trend is that employers who work in traditional male dominated areas pay their female employees more in bonues than other areas, for example in waste management storage they are paid more than men. In most other fields, however, women are paid much less in bonses than men. In some field, like health and social work, as well as in education, men and women are generally paid a similar amount in bonuses. Generally private corportations pay their female employers 10% more in bonuses than public sector employers. The number of employees does not seem to have an impact upon the general trend."
+ },
+ {
+ "title": "Median Hourly Pay Difference by SIC Section",
+ "url": "/plot/sic_sec?Pay+Type=Hourly",
+ "filters": {
+ "Pay Type": {
+ "options": [
+ "Hourly",
+ "Bonuses"
+ ],
+ "default": "Hourly"
+ },
+ "Year": "<Years>"
+ },
+ "description": "A bar chart showing median hourly pay inequality by SIC Section. SIC is a system that describes the business of an employer. All employer types pay their female employees less than their male employees, but the specific amount less varies. In the human health and social works sector, and the accomodation and food industry sectors, for example, it is 5% lower, and in the construction, mining and financial services industries it is 20-24% lower. The user can filter down these results to a specific year section, from 2017 to today. Refining the year does not seem to have an effect upon the general trend."
+ },
+ {
+ "title": "Median Bonus Pay Difference by SIC Section",
+ "url": "/plot/sic_sec?Pay+Type=Bonuses",
+ "filters": {
+ "Pay Type": {
+ "options": [
+ "Hourly",
+ "Bonuses"
+ ],
+ "default": "Bonuses"
+ },
+ "Year": "<Years>"
+ },
+ "description": "A bar chart showing median bonus pay gender inequality by SIC Section. SIC is a system that describes the business of an employer. The general trend is the same as hourly median pay, but in some fields such as waste management, transportation and storage, and construction, women are sometimes paid significantly more than men in bonus pay. The user can refine the chart by filtering down to a specific year. The general trend of doing this is that during the years 2019-2020 bonus pay inequality increased, with most employers paying their female employees less, but this trend has not generally continued."
+ }
+ ]
+} \ No newline at end of file
diff --git a/database.py b/src/database.py
index d67b96c..d67b96c 100644
--- a/database.py
+++ b/src/database.py
diff --git a/insinuations.py b/src/insinuations.py
index 107c84e..107c84e 100644
--- a/insinuations.py
+++ b/src/insinuations.py
diff --git a/parser.py b/src/parser.py
index f9e3e81..f9e3e81 100644
--- a/parser.py
+++ b/src/parser.py
diff --git a/static/scripts.js b/src/static/scripts.js
index 9b52215..9b52215 100644
--- a/static/scripts.js
+++ b/src/static/scripts.js
diff --git a/static/style.css b/src/static/style.css
index 9273cae..c363de6 100644
--- a/static/style.css
+++ b/src/static/style.css
@@ -118,7 +118,11 @@ aside form p {
#singlechart {
/* background-color: pink; */
width: 70%;
- min-height: 70%;
+ min-height: 90%;
+}
+
+.highcharts-description {
+ font-size: small;
}
.chart {
diff --git a/static/ukcounties.json b/src/static/ukcounties.json
index 46ecac0..46ecac0 100644
--- a/static/ukcounties.json
+++ b/src/static/ukcounties.json
diff --git a/templates/index.html.j2 b/src/templates/index.html.j2
index 234759f..68f9837 100644
--- a/templates/index.html.j2
+++ b/src/templates/index.html.j2
@@ -4,10 +4,10 @@
<ul>
{% for elem in charts %}
<li>
- <div class="chart_container">
+ <figure class="chart_container">
<div class="minichart" id="/minichart{{ elem['url'] }}">
</div>
- </div>
+ </figure>
<a class="bottom_text" href="{{ elem['url'] }}">{{ elem['title'] }}</a>
</li>
{% endfor %}
diff --git a/src/templates/plot.html.j2 b/src/templates/plot.html.j2
new file mode 100644
index 0000000..56f5e87
--- /dev/null
+++ b/src/templates/plot.html.j2
@@ -0,0 +1,8 @@
+{% extends "template.html.j2" %}
+{% block content %}
+ <figure id="singlechart" class="highcharts-figure">
+ <div class="chart" id="/chart{{ elem['url'] }}">
+ </div>
+ <p id=chart_alt class="highcharts-description">{{ alt }}</p>
+ </figure>
+{% endblock %} \ No newline at end of file
diff --git a/templates/search.html.j2 b/src/templates/search.html.j2
index 4de432c..4de432c 100644
--- a/templates/search.html.j2
+++ b/src/templates/search.html.j2
diff --git a/templates/template.html.j2 b/src/templates/template.html.j2
index 164caa8..02da03a 100644
--- a/templates/template.html.j2
+++ b/src/templates/template.html.j2
@@ -90,6 +90,6 @@
</div>
<footer>
- <p>Source code released under GPLv3</p>
+ <p><a href="https://github.com/jwansek/UKGenderPayGap">Source code</a> released under GPLv3</p>
</footer>
</body> \ No newline at end of file
diff --git a/templates/plot.html.j2 b/templates/plot.html.j2
deleted file mode 100644
index 91a3a36..0000000
--- a/templates/plot.html.j2
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends "template.html.j2" %}
-{% block content %}
- <div id="singlechart">
- <div class="chart" id="/chart{{ elem['url'] }}">
- </div>
- <p id=chart_alt>{{ alt }}</p>
- </div>
-{% endblock %} \ No newline at end of file