-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAUTO-UPDATING-MENU-WEEEKLY.txt
72 lines (65 loc) · 3.66 KB
/
AUTO-UPDATING-MENU-WEEEKLY.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Auto-Updating the Menu (Weekly)
Breakdown
✓ Getting the week's menu pdf link [DONE]
○ Example of the link
- https://auxiliary.fresnostate.edu/association/dining/documents/rdh_menus/menu-2023-07-02.pdf
○ menu-(YYYY)-(MM)-(DD).pdf (template of links ending)
- Using a function to get the date
- Using the links template and variables to create the current weeks menu link
• Converting PDF to Json; Can be done:
○ Using ChatGPT plugin (Link Reader) [WORKS GREAT BUT MANUALLY DONE; DIRECTLY CHANGES THE PDF TO TEXT THAT RESEMBLES JSON TO BE COPIED]
- Example of input
/*
https://auxiliary.fresnostate.edu/association/dining/documents/rdh_menus/menu-2023-07-02.pdf
Convert the table to JSON
The structure of the JSON will be as follows:
Each day of the week will be a key (word form).
Each meal (Breakfast, Lunch, Dinner, Dessert) will be a sub-key.
Each sub-key will have an array of dishes, where each dish is a dictionary with the type of dish (Entrée, Side, Protein, etc.) as the key and the actual dish as the value.
Complete for every day of the week
*/
✓ Using Node.JS packages 'axios' and 'pdf-parse' [PDF TO TEXT DATA; NEEDS TO BE CONVERTED TO JSON; DONE]
- Using the previously defined link for the current weeks menu and inputting it into the code
/*
//Packages checked
const axios = require("axios");
const pdf = require("pdf-parse");
//Creates function to read and return data of pdf from url
async function readPDF(url) {
const response = await axios.get(url, {
responseType: "arraybuffer",
});
const data = new Uint8Array(response.data);
return pdf(data).then(function (data) {
return data.text;
});
}
//Needs to use a function to define the current weeks menu link
const url =
"https://auxiliary.fresnostate.edu/association/dining/documents/rdh_menus/menu-2023-07-02.pdf";
// Calls Function and outputs the data or error
readPDF(url)
.then((text) => console.log(text))
.catch((err) => console.error(err));
*/
○ Using ChatGPT API to convert the data text to JSON [COST MONEY TO USE API; NEEDS TO BE AUTOMATED; NEEDS TO BE CREATED; TEXT TO JSON DATA]
- Use the returned text from readPDF(url) and input it into the API [HASN'T BEEN CREATED YET]
- Would take that information and convert it to JSON data
- Would then take that JSON data and input it into the database (github)
- Commit changes to the database (github)
• Using the Github JSON link and a cron job (WP CRONTROL) to run a function using PHP (funtions.php theme files) that updates the Dining Menu Pods on a schedule [NEEDS TO BE CREATED; JSON TO PODS]
- PHP will be written in the functions.php file of the theme files of the housing website
- The PHP function will be run on a schedule using a cron job (every week on Sunday at 4:00 AM)
- The PHP function will take the JSON data from the Github link and input it into the Dining Menu Pods
- The PHP function will save the changes to the Dining Menu Pods
• Automating and ensuring everything will run on a set schedule
Resources
• https://auxiliary.fresnostate.edu/association/dining/documents/rdh_menus/menu-2023-07-02.pdf
• https://www.npmjs.com/package/pdf-parse
• https://www.npmjs.com/package/axios
• https://platform.openai.com/docs/guides/gpt
• https://platform.openai.com/docs/quickstart/build-your-application
• https://github.com/Web-Jose/Housing-Changes/blob/main/Menu-Update.json
• https://openai.com/pricing
• https://platform.openai.com/tokenizer
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