Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Google Apps Script to generate wins data feed only on Change #4154

Closed
13 of 19 tasks
Tracked by #4134
roslynwythe opened this issue Mar 12, 2023 · 17 comments · Fixed by #7409
Closed
13 of 19 tasks
Tracked by #4134

Update Google Apps Script to generate wins data feed only on Change #4154

roslynwythe opened this issue Mar 12, 2023 · 17 comments · Fixed by #7409
Assignees
Labels
Complexity: Large P-Feature: Wins Page https://www.hackforla.org/wins/ ready for dev lead Issues that tech leads or merge team members need to follow up on role: back end/devOps Tasks for back-end developers size: 2pt Can be done in 7-12 hours

Comments

@roslynwythe
Copy link
Member

roslynwythe commented Mar 12, 2023

Dependency

Overview

As developers we need to modify the Apps Script in the Wins-form (Responses) spreadsheet so that a json feed is pushed to GitHub only after the data has changed, in order to eliminate the need to examine daily commits for changes.

Action Items

Setup

  • Follow sections 1-3 in the Wins Apps Script Development Process1. Note that in this issue you will be modifying both Apps Scripts wins-form-responses and gh-requests so setup will be required in both /google-apps-script/wins-form-responses and /google-apps-script/gh-requests
  • As described in section 3a and 3b, you will provide a dev lead with the google account you wish to use for testing, and request the dev lead to:
    • do not modify folder level access
    • share the Wins Form Admin Guide2 as VIEWER
    • share the Wins-form (Response)3 sheet as VIEWER
    • share the gh-requests doc as VIEWER
  • Continue following instructions in 3c and d. As described in 3d, you will have to make modifications to certain documents in the test folder.
    • It will not be necessary to restore any triggers, because you can execute main() in debug mode.
    • Since you will be running main() for testing, you must follow instructions in Testing WINS in a test repository
  • Continue following instructions through section 6 "Editing". As described in this section, editing can be done locally in an IDE or in the Google Drive cloud editor, and the clasp utility can be used to transfer code back and forth between the local worksation and the Google Drive as needed.

Suggested Solutions to Implement

  • In gh-requests, modify getSHA(filename) so that it returns not just the SHA but also the json contents. To reflect this change, change the name of the function to getWins(filename). Back in main(), compare the returned JSON to the data just compiled from the spreadsheet. If differences are detected, proceed to call updateWinsFile.
  • If a different approach will be taken, explain the approach in a comment and bring to the attention of a dev lead.

Testing

  • Test in debug mode: confirm that when main() runs when there have been no changes to Wins data, the script will not create any commits/PRs in the test GitHub repository
  • In the Review sheet, find a row in which the "Display" column has the value "True" and change it to "False". Run main() in debug mode and confirm that a new commit and a new Pull Request "Update wins-data.json via Google Apps Script" is created in your test repository. Run main() again and confirm that no additional commits have been noted in the Pull Request. Merge the Pull Request into your test branch then view the wins webpage in the test branch and confirm that the corresponding wins entry is not displayed.

After successful testing

  • Update the Wins Admin Guide and the wiki "Automations for Wins page using Google Apps Script" with a description of the new logic for pushing the wins data feed to GitHub.
  • Add/commit Code.js then proceed to create a Pull Request as usual. Contact the dev lead to arrange review

dev lead:

  • Remove developer's access from each shared document and as well as any folder level access
    • Wins Form Admin Guide2
    • Wins-form (Response)3 sheet
    • Wins-form1
    • gh-requests doc
  • See instructions in Wins Apps Script Development Process[^4] under the heading "For Reviewers (Merge Team)"

Resources/Instructions

Footnotes

  1. Wins Apps Script Development Process 2

  2. Wins Form Admin Guide 2

  3. Wins-form (Response) Sheet 2

@roslynwythe roslynwythe added the Draft Issue is still in the process of being created label Mar 12, 2023
@github-actions github-actions bot added Feature Missing This label means that the issue needs to be linked to a precise feature label. role missing and removed Draft Issue is still in the process of being created labels Mar 12, 2023
@roslynwythe roslynwythe added P-Feature: Wins Page https://www.hackforla.org/wins/ role: back end/devOps Tasks for back-end developers Draft Issue is still in the process of being created and removed Feature Missing This label means that the issue needs to be linked to a precise feature label. role missing labels Mar 12, 2023
@roslynwythe

This comment was marked as outdated.

@roslynwythe roslynwythe added Complexity: Large Dependency An issue is blocking the completion or starting of another issue and removed Draft Issue is still in the process of being created Complexity: Missing labels Mar 20, 2023
@roslynwythe roslynwythe added size: 2pt Can be done in 7-12 hours and removed size: missing labels May 4, 2023
@ExperimentsInHonesty ExperimentsInHonesty added ready for dev lead Issues that tech leads or merge team members need to follow up on and removed Dependency An issue is blocking the completion or starting of another issue labels Feb 29, 2024
@ExperimentsInHonesty

This comment was marked as outdated.

@roslynwythe roslynwythe added Ready for Prioritization and removed ready for dev lead Issues that tech leads or merge team members need to follow up on labels May 9, 2024
@iancooperman iancooperman self-assigned this Jun 4, 2024

This comment has been minimized.

@iancooperman
Copy link
Member

ETA for this entire issue: 7/3/2024. I think I could complete the setup steps by this coming Sunday, 6/9/2024.
Availability this week: Tues-Fri 5pm-9pm, Sat 10am-9pm, Sun 10am-4pm.

@ExperimentsInHonesty
Copy link
Member

@iancooperman I have moved this issue to the In Progress column for you. Please remember to do that in future when you assign an issue. Thanks!

@iancooperman
Copy link
Member

Output of step 5.3 on gh-requests in Wins Google Apps Script Development Process:

git diff Code.js
warning: in the working copy of 'google-apps-scripts/gh-requests/Code.js', LF will be replaced by CRLF the next time Git touches it
diff --git a/google-apps-scripts/gh-requests/Code.js b/google-apps-scripts/gh-requests/Code.js
index 2c14f52a..edb0ea73 100644
--- a/google-apps-scripts/gh-requests/Code.js
+++ b/google-apps-scripts/gh-requests/Code.js
@@ -119,7 +119,8 @@ function setToken_() {
   }

   const doc = DocumentApp.openById(id);
-  documentProperties.setProperty('TOKEN', doc.getBody().getText())
+  documentProperties.setProperty('TOKEN', doc.getBody().getText());
+  console.log(documentProperties.getProperty(`TOKEN`))
 }

 // Uses base64 to decode an input

The only significant difference between the version of Code.js cloned from Google and the one from GitHub is the addition of one line of logging.

@iancooperman
Copy link
Member

No such output for wins-form-respones.

git diff Code.js

@iancooperman
Copy link
Member

Hi!. Still working on this! Life just got in the way. Hope to have this done by the end of next week at the latest.

@github-actions github-actions bot added the To Update ! No update has been provided label Aug 9, 2024

This comment has been minimized.

@iancooperman
Copy link
Member

Successfully set up test environment and finally resolved authentication issues on my end. Just need to make the appropriate changes in both files.
ETA: 8/17

@iancooperman iancooperman added Status: Updated No blockers and update is ready for review and removed To Update ! No update has been provided labels Aug 13, 2024
@iancooperman
Copy link
Member

iancooperman commented Aug 21, 2024

Will need to implement a deeper comparison of the wins-form-responses and _wins.json than just comparing their lengths.
ETA: 8/25

@HackforLABot HackforLABot added To Update ! No update has been provided and removed Status: Updated No blockers and update is ready for review labels Aug 30, 2024
@HackforLABot
Copy link
Contributor

@iancooperman

Please add update using the below template (even if you have a pull request). Afterwards, remove the 'To Update !' label and add the 'Status: Updated' label.

  1. Progress: "What is the current status of your project? What have you completed and what is left to do?"
  2. Blockers: "Difficulties or errors encountered."
  3. Availability: "How much time will you have this week to work on this issue?"
  4. ETA: "When do you expect this issue to be completed?"
  5. Pictures (optional): "Add any pictures of the visual changes made to the site so far."

If you need help, be sure to either: 1) place your issue in the Questions/In Review column of the Project Board and ask for help at your next meeting, 2) put a "Status: Help Wanted" label on your issue and pull request, or 3) put up a request for assistance on the #hfla-site channel. Please note that including your questions in the issue comments- along with screenshots, if applicable- will help us to help you. Here and here are examples of well-formed questions.

You are receiving this comment because your last comment was before Tuesday, August 27, 2024 at 12:04 AM PST.

@roslynwythe
Copy link
Member Author

Hi @iancooperman please leave an update regarding the comparison you mentioned above. Also, are you still having authentication errors when posting _wins_data.json to your test repository? I am asking because I would like to know if there is something missing in the instructions. Thanks Ian.

@iancooperman
Copy link
Member

Hey @roslynwythe. I'm sorry for not being more active. I've been dreadfully sick the past few days.

After trying various methods to go through the spreadsheet data and the _wins-data.json file for direct comparisons, I decided to simply convert the formatted spreadsheet data and the contents of the existing file into two strings and compare those. I know it might sound a bit unconventional, but it has passed every test I've given it so far.

I'd like to test it a bit more before making a PR for this. And I also haven't run into the authentication error again. Go figure.

@iancooperman
Copy link
Member

I am currently working on writing new material for the Wins Admin Guide and the wiki "Automations for Wins page using Google Apps Script". PR will come soon after that is finished.

@iancooperman
Copy link
Member

Proposed updated entry for "Automations for Wins page using Google Apps Script":

Automations for Wins page using Google Apps Script

  • As soon as a user submits the share your wins form, the On form submit triggers two functions:
    • The first function: Which grabs the data from the form and reformats it, and adds it to the same spreadsheet the form response goes to, but on another more readable tab (review)
      • Parses users' response using JSON.parse()
      • Adds a timestamp to when the form was submitted
      • Formats the response to be used in our spreadsheet
      • Calls the Google App Script
      • Posts response to the review tab in the spreadsheet.
    • The second function:
      • Creates an issue to be added to our project board.
  • The user's response will require an admin review to be considered for the Wins page.
  • Next, a time-based trigger which triggers daily, in the same Google Apps Script, creates a Pull Request which if merged adds the new row (in the spreadsheet with a True value in the Display column) to the Wins page on the website. Note that if no new rows or other changes have been made to the spreadsheet, no pull request is made.

@HackforLABot HackforLABot removed the To Update ! No update has been provided label Sep 6, 2024
@iancooperman iancooperman added the ready for dev lead Issues that tech leads or merge team members need to follow up on label Oct 16, 2024
@iancooperman
Copy link
Member

Hi,

I have been awaiting a rereview on the linked PR for the past three weeks. If Roslyn is currently unavailable to complete it, I would appreciate it if another dev lead could take over. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Large P-Feature: Wins Page https://www.hackforla.org/wins/ ready for dev lead Issues that tech leads or merge team members need to follow up on role: back end/devOps Tasks for back-end developers size: 2pt Can be done in 7-12 hours
Projects
4 participants