jamietr1 / google-docs-writing-tracker

Automation scripts to track writing in Google Docs
187 stars 39 forks source link

Duplicate DailyAlmanac Emails? #15

Closed naalvarez closed 10 years ago

naalvarez commented 10 years ago

I've skimmed through the existing issues and pull requests but didn't notice this one, I apologize if it's been addressed already.

I am receiving the DailyAlmanac email and they seem to have the correct information, however I receive them three times every morning, typically around 12:02 AM, 12:06 AM, and again between 3-4 AM. The word count and other stats seem to stay consistent in each email, although the goals change, likely building off the last run DailyAlmanac script?

For example, on 7/31 I received three Daily Almanacs. 12:02 - 1087 words - new 1 day record, new consecutive day record, new consecutive-day record for meeting your goal 12:06 am - 1087 words - new consecutive day record 3:49 am - 1087 words - new consecutive day record

All other numbers stay the same.

I thought maybe it was a fluke, but it has happened every day since then.

I have also received emails almost daily from Google Apps Script saying that the DailyAlmanac script failed to finish successfully. These are the details it provides:

Details: Start Function Error Message Trigger End 8/1/14 12:36 AM getAlamancText Range not found (line 373, file "Code") time-based 8/1/14 12:36 AM

Details: Start Function Error Message Trigger End 8/1/14 12:44 AM getAlamancText ReferenceError: "updateRanges" is not defined. (line 39, file "Code") time-based 8/1/14 12:44 AM

It's the same two errors (delivered in two emails) every day.

Thanks!

jamietr1 commented 10 years ago

I can't explain why you'd get 3 emails each night at those times, unless you have more than one trigger set up, or more than one version of the script running. First, I'd check that you have only one instance of the script. If you have more than one, either delete the others, or remove the triggers from the others.

Once you've confirmed you have only one version running, make sure you have only 1 trigger set up for the script. Mine looks like this:

screenshot_080414_104927_am

Note that there is just the one trigger.

Regarding the range error, the range being set is the range of the *total words column in your Writing sheet. The script gets the value of this column from the value set in the Writing Total setting on the Config sheet. Mine looks like this:

screenshot_080414_105618_am

That column (in my case, D) corresponds to column D on the Writing sheet. If you are using the sheet that I shared that would look like this:

screenshot_080414_105739_am

All that function is doing is setting the range value to the range of the column, from D2 to the last cell in the column. The only reason I can think it would throw an error was if the column didn't exist or a setting on the Config tab was pointing to the wrong place.

naalvarez commented 10 years ago

I double checked, and I don't have any extra copies of the DailyAlmanac, and the current version only has 1 trigger, set up as you show above. I did notice some test copies of DailyAlmanac in the Trash, and while I doubt they run, I deleted them just in case.

The Writing Sheet and Config sheet are set up as you have them above.

I'll keep poking around to see if I notice a pattern or something off in one of the docs. I updated all the scripts and docs this morning to the latest versions you have on github, just in case.

jamietr1 commented 10 years ago

It occurs to me that the Trigger may retry a few times if it gets an error, which would explain the duplicates. I'm still puzzling over the 0's in the Daily Almanac output, however.

naalvarez commented 10 years ago

Well the good news is I did not get duplicate Daily Almanac emails this morning, just the one - so perhaps those Daily Almanacs in the trash were running after all?

But I still got the two emails of "Summary of failures for Google Apps Script: DailyAlmanac" with the same two errors above. Roughly the same times, too, 12:36 AM and 12:44 AM.

But what's even stranger, is that it really seems like everything is working. Spreadsheet is updating, it's accurately capturing word counts...I don't mind getting the error emails if everything works. Could be another fluke I guess.

naalvarez commented 10 years ago

No duplicate emails and no summary of error emails - it looks like the trash was the problem! Thanks!!

jamietr1 commented 10 years ago

Cool! Glad it's working!