Skip to content

Commit 5eb3afb

Browse files
authored
Merge pull request #2226 from Sefaria/feature/sc-31547/metrics-webpage
Feature/sc 31547/metrics webpage
2 parents c96abd4 + 9257c6f commit 5eb3afb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

scripts/scheduled/metrics.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
contributors = len(contributors)
2222

2323
# Number of Links
24-
links = db.links.count()
24+
links = db.links.count_documents({})
2525

2626
# Number of Source sheets
27-
sheets = db.sheets.count()
27+
sheets = db.sheets.count_documents({})
2828

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

3939
try:
40-
db.metrics.save(metrics)
40+
db.metrics.insert_one(metrics)
4141
except DuplicateKeyError:
4242
pass

sefaria/model/text.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,11 @@ class AbstractTextRecord(object):
10291029

10301030
def word_count(self):
10311031
""" Returns the number of words in this text """
1032-
return self.ja(remove_html=True).word_count()
1032+
try:
1033+
wc = self.ja(remove_html=True).word_count()
1034+
except AttributeError:
1035+
wc = 0
1036+
return wc
10331037

10341038
def char_count(self):
10351039
""" Returns the number of characters in this text """

0 commit comments

Comments
 (0)