Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gsheet_webapp/Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service

version="2.0.0"; //change when the version changes
version="2.1.0"; //change when the version changes

//Best practice for using BetterLog and logging to a spreadsheet:
// You can add and set the property "BetterLogLevel" in File > Project Properties and change it to
Expand Down Expand Up @@ -61,11 +61,12 @@ function doPost(e){
objJSON = JSON.parse(jsonString);
action = objJSON.action;
key = objJSON.accesskey;
srcip = objJSON.from_ip;

if(key != SCRIPT_PROP.getProperty("accesskey"))
throw new Error("Invalid access key.");

Logger.info(action);
Logger.info(action + " from " + srcip);

result = handleAction(action, objJSON);

Expand Down
17 changes: 17 additions & 0 deletions lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def sync_to_dashboard(data, report):
return 'No data to send'

postdata = {"action": "insertupdate",
"from_ip": get_public_ip(),
"sheet": report,
"accesskey": environ['GSHEETS_DASHBOARD_KEY'],
"data": data}
Expand Down Expand Up @@ -200,6 +201,22 @@ def format_duration(duration_string: str, target_unit: str, append_unit: bool=Fa
return f'{converted_duration:.2f} {target_unit}' if append_unit else f'{converted_duration:.2f}'


def get_public_ip():
"""
Returns the publicly visible IP address of the current host
"""
try:
r = requests.get("https://checkip.amazonaws.com")
if r.status_code == 200:
return r.text.strip()
else:
print(f"Error getting public IP address of the current host. {0}", r.status_code)
return("Unknown")
except Exception as e:
print(f"Error executing requests.get. {0}", e.message)
return("Unknown")


def get_report_outfile(reportname, prefix=''):
"""
Returns a writable file in the current directory
Expand Down
6 changes: 4 additions & 2 deletions packages/redata_reports/run/items_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_public_article_info(article_ids):
unpublished_article_ids.append(id)

else:
print('Error getting article versions for {1}, Response code {0}'.format(id, response.status_code))
print('Error getting article versions for {0}, Response code {1}'.format(id, response.status_code))

return article_info, unpublished_article_ids

Expand Down Expand Up @@ -114,7 +114,7 @@ def run(args):
if len(r2) > 0:
unpublished_article_ids.append(r2)

print("total public articles (excluding removed articles): {0}".format(len(public_articles_info)))
print("total processed public articles (excluding removed articles): {0}".format(len(public_articles_info)))

print('Getting usage by private articles')
private_articles = [item for item in institution_articles if item['published_date'] is None]
Expand All @@ -135,6 +135,8 @@ def run(args):
if len(r) > 0:
private_articles_info.append(r)

print("total private articles processed (including removed articles): {0}".format(len(private_articles_info)))

articles = []
total_usage = 0
for article in public_articles_info + private_articles_info:
Expand Down
2 changes: 1 addition & 1 deletion packages/redata_reports/run/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def get_commit(repo_path):


__commit__ = get_commit('.')
__version__ = '1.1.2'
__version__ = '1.2.0'
2 changes: 1 addition & 1 deletion packages/trello_reports/run/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def get_commit(repo_path):


__commit__ = get_commit('.')
__version__ = '1.0.0'
__version__ = '1.1.0'
Loading