Skip to content

Commit

Permalink
Merge pull request #2226 from Sefaria/feature/sc-31547/metrics-webpage
Browse files Browse the repository at this point in the history
Feature/sc 31547/metrics webpage
  • Loading branch information
edamboritz authored Jan 14, 2025
2 parents c96abd4 + 9257c6f commit 5eb3afb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/scheduled/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
contributors = len(contributors)

# Number of Links
links = db.links.count()
links = db.links.count_documents({})

# Number of Source sheets
sheets = db.sheets.count()
sheets = db.sheets.count_documents({})

metrics = {
"timestamp": datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0),
Expand All @@ -37,6 +37,6 @@
}

try:
db.metrics.save(metrics)
db.metrics.insert_one(metrics)
except DuplicateKeyError:
pass
6 changes: 5 additions & 1 deletion sefaria/model/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,11 @@ class AbstractTextRecord(object):

def word_count(self):
""" Returns the number of words in this text """
return self.ja(remove_html=True).word_count()
try:
wc = self.ja(remove_html=True).word_count()
except AttributeError:
wc = 0
return wc

def char_count(self):
""" Returns the number of characters in this text """
Expand Down

0 comments on commit 5eb3afb

Please sign in to comment.