Skip to content

Commit

Permalink
Fixed merge conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Aug 14, 2024
2 parents 2e2d6e7 + ac676e9 commit 8459ab1
Show file tree
Hide file tree
Showing 17 changed files with 278 additions and 174 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/image_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: docker-image-push-public-dash

on:
push:
<<<<<<< HEAD
branches: [ image-push-2 ]
=======
branches: [ main ]
>>>>>>> main

workflow_dispatch:
inputs:
Expand All @@ -14,7 +18,11 @@ env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}

<<<<<<< HEAD
jobs:
=======
jobs:
>>>>>>> main
build:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -79,14 +87,22 @@ jobs:
- name: rename docker images
run: |
if [ "${{ github.event_name }}" == "push" ]; then
<<<<<<< HEAD
docker image tag em-pub-dash/frontend:latest $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}
=======
docker image tag em-pub-dash/frontend:latest $DOCKER_USER/${GITHUB_REPOSITORY#*/}_frontend:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}
>>>>>>> main
fi
docker image tag em-pub-dash/viz-scripts:latest $DOCKER_USER/${GITHUB_REPOSITORY#*/}_notebook:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}

- name: push docker images
run: |
if [ "${{ github.event_name }}" == "push" ]; then
<<<<<<< HEAD
docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}
=======
docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}_frontend:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}
>>>>>>> main
fi
docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}_notebook:${GITHUB_REF##*/}_${{ steps.date.outputs.date }}

Expand Down
73 changes: 17 additions & 56 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,28 +357,6 @@
};
return dates;
};

function getDictionaryList(form_list) {
var quest_dict = {};
return new Promise(async (resolve) => {
for (i in form_list) {
response = await fetch(form_list[i]);
text = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/xml");
labels = doc.getElementsByTagName("label");
for (i in labels) {
try {
if ((labels[i].parentNode.getAttribute("appearance") !== "label" && labels[i].parentNode.nodeName != "input")) //label type questions don't ever have answers
{
quest_dict[labels[i].parentNode.getAttribute("ref").split('/').slice(-1)] = labels[i].firstChild.data;
}
} catch (e) { }
}
}
resolve(quest_dict);
})
};
</script>

<script type="text/javascript">
Expand Down Expand Up @@ -430,38 +408,22 @@
mode_studied = data.intro.mode_studied
// Load list of plots corresponding to study/program
dynamic_labels = data.label_options
surveys = data.survey_info.surveys
console.log(data.survey_info['trip-labels'])
if (data.survey_info['trip-labels'] === 'ENKETO') { //CASE: SURVEYS
survey_list = Object.keys(surveys)
survey_list = survey_list.filter(name => name !== 'UserProfileSurvey')

sheet_list = []
for (name in survey_list) {
form_path = data.survey_info.surveys[survey_list[name]].formPath;
//THIS ASSUMES THE FILENAME IS THE SAME AS THE FORM PATH BUT WITH xml FILE TYPE
l_path = form_path.split('.')
l_path.splice(l_path.length -1, 1, 'xml');
console.log(l_path);
sheet_path = l_path.join('.')
sheet_list.push(sheet_path)
}

getDictionaryList(sheet_list).then((quest_dict) => {
console.log(quest_dict);
load_file = "metrics_study_surveys.html"
$.get(load_file, function (file) {
Object.entries(quest_dict).forEach(([key, value]) => {
var text = '<option ' + 'value="' + key + '" data-sizex="10" data-sizey="4">' + value + '</option>';
file = file.concat('\n', text);
});
console.log("configuring units");
const unitConfigured = file.replaceAll("${data.display_config.use_imperial}", dist_units);
$('#metric').append(unitConfigured);
addPreconfiguredMetrics(Object.keys(quest_dict).slice(0, 5)); //only adding the first 6 elements
survey_list = []
console.log(data.survey_info?.['trip-labels'])
if (data.survey_info?.['trip-labels'] === 'ENKETO') { //CASE: SURVEYS
surveys = data.survey_info.surveys
survey_list = Object.keys(surveys).filter(name => name !== 'UserProfileSurvey')
load_file = "metrics_study_surveys.html"
$.get(load_file, function (file) {
survey_list.forEach((name) => {
var text = '<option ' + 'value="' + name + '" data-sizex="10" data-sizey="8">' + name + '</option>';
file = file.concat('\n', text);
});
});

console.log("configuring units");
const unitConfigured = file.replaceAll("${data.display_config.use_imperial}", dist_units);
$('#metric').append(unitConfigured);
addPreconfiguredMetrics(survey_list); //only adding the first 6 elements
});
}
else if (data.intro.program_or_study == 'program') { //CASE: PROGRAM
// Note: We're disabling energy metrics on public dashboard when dynamic labels are available.
Expand Down Expand Up @@ -589,10 +551,9 @@
const htmlFile = "plots/" + metric + "_" + dateVal + program + ".html";
const altTextFile = "plots/" + metric + "_" + dateVal + program + ".txt";
const altText = loadFile(altTextFile);
const quest_dict = await getDictionaryList(sheet_list);
const stackedMetrics = ['ntrips_total', 'ntrips_total_survey', 'ntrips_purpose', 'ntrips_under80', 'ntrips_under80_survey', 'ntrips_commute_mode_confirm',
'total_trip_length', 'total_trip_length_land', 'total_trip_length_land_survey',`ntrips_${mode_studied}_total`,
`ntrips_${mode_studied}_purpose`,`total_trip_length_${mode_studied}_replaced_mode`].concat(Object.keys(quest_dict));
`ntrips_${mode_studied}_purpose`,`total_trip_length_${mode_studied}_replaced_mode`].concat(survey_list);
const isStackedMetric = stackedMetrics.includes(metric);
const jsonData = { metric, dateVal, program, metricLabel, dateLabel, programLabel, sizex, sizey };

Expand Down Expand Up @@ -649,4 +610,4 @@
</script>
</body>

</html>
</html>
1 change: 1 addition & 0 deletions frontend/metrics_program.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<option value="ts_emissions_vmt" data-sizex="8" data-sizey="2">Timeseries of emissions per ${data.display_config.use_imperial}</option>
<option value="ts_users" data-sizex="8" data-sizey="2">Timeseries of active users</option>
<option value="ts_all_modes" data-sizex="8" data-sizey="2">Timeseries of all mode shares</option>
<option value="ts_totalvlabeled" data-sizex="8" data-sizey="2">Timeseries of Total and Labeled Trip Counts</option>
<!-- Mode Specific -->
<option value="ntrips_${data.intro.mode_studied}_purpose" data-sizex="10" data-sizey="4">`${data.intro.mode_studied}` specific trip count by purpose</option>
<option value="ntrips_${data.intro.mode_studied}_total" data-sizex="10" data-sizey="4">`${data.intro.mode_studied}` specific number of trips by replaced mode</option>
Expand Down
1 change: 1 addition & 0 deletions frontend/metrics_program_withoutEnergyMetrics.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<option value="ts_emissions_vmt" data-sizex="8" data-sizey="2">Timeseries of emissions per ${data.display_config.use_imperial}</option>
<option value="ts_users" data-sizex="8" data-sizey="2">Timeseries of active users</option>
<option value="ts_all_modes" data-sizex="8" data-sizey="2">Timeseries of all mode shares</option>
<option value="ts_totalvlabeled" data-sizex="8" data-sizey="2">Timeseries of Total and Labeled Trip Counts</option>
<!-- Mode Specific -->
<option value="ntrips_${data.intro.mode_studied}_purpose" data-sizex="10" data-sizey="4">`${data.intro.mode_studied}` specific trip count by purpose</option>
<option value="ntrips_${data.intro.mode_studied}_total" data-sizex="10" data-sizey="4">`${data.intro.mode_studied}` specific number of trips by replaced mode</option>
Expand Down
1 change: 1 addition & 0 deletions frontend/metrics_study.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
<option value="ts_emissions_vmt" data-sizex="8" data-sizey="2">Timeseries of emissions per ${data.display_config.use_imperial}</option>
<option value="ts_users" data-sizex="8" data-sizey="2">Timeseries of active users</option>
<option value="ts_all_modes" data-sizex="8" data-sizey="2">Timeseries of all mode shares</option>
<option value="ts_totalvlabeled" data-sizex="8" data-sizey="2">Timeseries of Total and Labeled Trip Counts</option>
3 changes: 2 additions & 1 deletion frontend/metrics_study_surveys.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<option value="average_miles_sensed_mode" data-sizex="6" data-sizey="4">Average trip length (${data.display_config.use_imperial}) (sensed)</option>
<option value="ntrips_sensed_per_day" data-sizex="6" data-sizey="4">Trip frequency (sensed)</option>
<option value="ntrips_sensed_per_weekday" data-sizex="6" data-sizey="4">Trip frequency (weekday, sensed)</option>
<option value="ts_users" data-sizex="8" data-sizey="2">Timeseries of active users</option>
<option value="ts_users" data-sizex="8" data-sizey="2">Timeseries of active users</option>
<option value="ts_totalvlabeled" data-sizex="8" data-sizey="2">Timeseries of Total and Labeled Trip Counts</option>
1 change: 1 addition & 0 deletions frontend/metrics_study_withoutEnergyMetrics.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
<option value="ts_emissions_vmt" data-sizex="8" data-sizey="2">Timeseries of emissions per ${data.display_config.use_imperial}</option>
<option value="ts_users" data-sizex="8" data-sizey="2">Timeseries of active users</option>
<option value="ts_all_modes" data-sizex="8" data-sizey="2">Timeseries of all mode shares</option>
<option value="ts_totalvlabeled" data-sizex="8" data-sizey="2">Timeseries of Total and Labeled Trip Counts</option>
4 changes: 3 additions & 1 deletion viz_scripts/bin/generate_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def compute_for_date(month, year):
dynamic_labels = dynamic_labels,
use_imperial = dynamic_config.get('display_config', {}).get('use_imperial', True),
sensed_algo_prefix=dynamic_config.get('metrics', {}).get('sensed_algo_prefix', "cleaned"),
survey_info = dynamic_config.get('survey_info', {}))
bluetooth_only = dynamic_config.get('tracking', {}).get('bluetooth_only', False),
survey_info = dynamic_config.get('survey_info', {}),
)

print(f"Running at {arrow.get()} with params {params}")

Expand Down
2 changes: 1 addition & 1 deletion viz_scripts/docker/start_notebook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cd saved-notebooks
# tail -f /dev/null
if [ -z ${CRON_MODE} ] ; then
echo "Running notebook in docker, change host:port to localhost:47962 in the URL below"
PYTHONPATH=/usr/src/app jupyter notebook --no-browser --ip=${WEB_SERVER_HOST} --allow-root
PYTHONPATH=/usr/src/app jupyter notebook --no-browser --ip=0.0.0.0 --allow-root
else
echo "Running crontab without user interaction, setting python path"
export PYTHONPATH=/usr/src/app
Expand Down
Loading

0 comments on commit 8459ab1

Please sign in to comment.