Plans Week 12

Finals Week

  • Monday: Open Study day, Review of Project
  • Tuesday, Wednesday, Thursday: MCQ Test Review
  • Friday: No School

Final Exam (3 points)

Summary of Points

  • 1.8 of 2 points for scoring above 50%
  • 1 point on blog

Extra Credit Review and Makeups must be complete before EOD Thu

Posters is an example

Coding for Extra Credit

There are always opportunities to show understanding of coding. This weekend I was observing World-O-Meter. How would you do this with our group projects.

Step 1 - JavaScript document element updates

Below is a code segment that updates a clock on a page every second, adaptation would be to update data from API fetch on an interval, then updating all document elements after fetch.

// Clock Control
// clockElement global element set for convenience
let clockElement = document.getElementById('clock')
// Execute clock function on load
clock();
// Clock update executes on each interval set by timer
function clock() {
    let date = new Date();
    clockElement.textContent = date.toLocaleString();
}
// Clock refresh timer, a reoccurring event
setInterval(clock, 1000);

Step 2 - JavaScript update backend content

To make the updates document elements meaningful you would need to have an interval to update the Haha or Boohoo content. This could be done in same or different JavaScript timer. This would be calling appropriate fetch in add to the counters. Together, these would give the same effect as the World-O-Meter.

Step 2 (Java Option) - update backend content

Instead of having frontend update counter, you could have backend update the counter. The below python code could be adapted for Java.

import threading  # import threading

def keepUpdating(): # build a function to run over and over
# global variable setup
global run  
try: run
except: run = 0

print("Seconds:", run)  # replace this line with updates to data
run += 3  # this is update to global variable
threading.Timer(3.0, keepUpdating).start()

keepUpdating()  # you need to call this function at application startup

Step 2 (Bash Option) - do updates on server

Update content using curl and scheduling on the system. To make a PUT request with Curl, you need to use the -X PUT command-line option.

$ curl -X PUT localhost:8080/api/like/1

This command would need to be added to crontab or a bash script and crontab to run repeatedly.

$ crontab -l
# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task

Automatic Deployment for Extra Credit

Change AWS Spring Deployment to be automatic Student Reference GitHub Actions

3rd Party Spring to EC2