mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
remove avg comment length experiment
This commit is contained in:
parent
910ba06620
commit
75f52fbd59
7 changed files with 0 additions and 28 deletions
|
@ -1426,8 +1426,6 @@ def create_post_reply(activity_log: ActivityPubLog, community: Community, in_rep
|
||||||
post_reply.ranking = confidence(post_reply.up_votes, post_reply.down_votes)
|
post_reply.ranking = confidence(post_reply.up_votes, post_reply.down_votes)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
user.recalculate_avg_comment_length()
|
|
||||||
|
|
||||||
# send notification to the post/comment being replied to
|
# send notification to the post/comment being replied to
|
||||||
if parent_comment_id:
|
if parent_comment_id:
|
||||||
notify_about_post_reply(parent_comment, post_reply)
|
notify_about_post_reply(parent_comment, post_reply)
|
||||||
|
|
|
@ -616,8 +616,6 @@ class User(UserMixin, db.Model):
|
||||||
markdown_editor = db.Column(db.Boolean, default=False)
|
markdown_editor = db.Column(db.Boolean, default=False)
|
||||||
interface_language = db.Column(db.String(10)) # a locale that the translation system understands e.g. 'en' or 'en-us'. If empty, use browser default
|
interface_language = db.Column(db.String(10)) # a locale that the translation system understands e.g. 'en' or 'en-us'. If empty, use browser default
|
||||||
language_id = db.Column(db.Integer, db.ForeignKey('language.id')) # the default choice in the language dropdown when composing posts & comments
|
language_id = db.Column(db.Integer, db.ForeignKey('language.id')) # the default choice in the language dropdown when composing posts & comments
|
||||||
average_comment_length = db.Column(db.Integer)
|
|
||||||
comment_length_warning = db.Column(db.Integer, default=21)
|
|
||||||
|
|
||||||
avatar = db.relationship('File', lazy='joined', foreign_keys=[avatar_id], single_parent=True, cascade="all, delete-orphan")
|
avatar = db.relationship('File', lazy='joined', foreign_keys=[avatar_id], single_parent=True, cascade="all, delete-orphan")
|
||||||
cover = db.relationship('File', lazy='joined', foreign_keys=[cover_id], single_parent=True, cascade="all, delete-orphan")
|
cover = db.relationship('File', lazy='joined', foreign_keys=[cover_id], single_parent=True, cascade="all, delete-orphan")
|
||||||
|
@ -811,19 +809,6 @@ class User(UserMixin, db.Model):
|
||||||
else:
|
else:
|
||||||
self.attitude = (total_upvotes - total_downvotes) / (total_upvotes + total_downvotes)
|
self.attitude = (total_upvotes - total_downvotes) / (total_upvotes + total_downvotes)
|
||||||
|
|
||||||
def recalculate_avg_comment_length(self):
|
|
||||||
replies = db.session.execute(text('SELECT body, body_html FROM "post_reply" WHERE user_id = :user_id ORDER BY created_at DESC LIMIT 30'),
|
|
||||||
{'user_id': self.id}).all()
|
|
||||||
lengths = []
|
|
||||||
for reply in replies:
|
|
||||||
if reply.body.strip() != '':
|
|
||||||
lengths.append(len(reply.body.strip()))
|
|
||||||
else:
|
|
||||||
soup = BeautifulSoup(reply.body_html, 'html.parser')
|
|
||||||
lengths.append(len(soup.get_text()))
|
|
||||||
if len(lengths) > 5:
|
|
||||||
self.average_comment_length = math.ceil(sum(lengths) / len(lengths))
|
|
||||||
|
|
||||||
def subscribed(self, community_id: int) -> int:
|
def subscribed(self, community_id: int) -> int:
|
||||||
if community_id is None:
|
if community_id is None:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -111,8 +111,6 @@ def show_post(post_id: int):
|
||||||
db.session.add(reply)
|
db.session.add(reply)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
current_user.recalculate_avg_comment_length()
|
|
||||||
|
|
||||||
notify_about_post_reply(None, reply)
|
notify_about_post_reply(None, reply)
|
||||||
|
|
||||||
# Subscribe to own comment
|
# Subscribe to own comment
|
||||||
|
@ -673,8 +671,6 @@ def add_reply(post_id: int, comment_id: int):
|
||||||
db.session.add(reply)
|
db.session.add(reply)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
current_user.recalculate_avg_comment_length()
|
|
||||||
|
|
||||||
# Notify subscribers
|
# Notify subscribers
|
||||||
notify_about_post_reply(in_reply_to, reply)
|
notify_about_post_reply(in_reply_to, reply)
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,6 @@
|
||||||
{% elif comment['comment'].author.reputation < 0 %}
|
{% elif comment['comment'].author.reputation < 0 %}
|
||||||
<span class="fe fe-warning orangered" title="Low reputation."> </span>
|
<span class="fe fe-warning orangered" title="Low reputation."> </span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_user.is_authenticated and current_user.comment_length_warning and comment['comment'].author.average_comment_length and comment['comment'].author.average_comment_length <= current_user.comment_length_warning %}
|
|
||||||
<span class="fe fe-warning purple" title="{{ _('Usually makes short and low effort comments.') }}"> </span>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if comment['comment'].author.id == post.author.id %}<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small">[OP]</span>{% endif %}
|
{% if comment['comment'].author.id == post.author.id %}<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small">[OP]</span>{% endif %}
|
||||||
<span class="text-muted small" aria_label="{{ _('When: ') }}">{{ moment(comment['comment'].posted_at).fromNow(refresh=True) }}{% if comment['comment'].edited_at %}, edited {{ moment(comment['comment'].edited_at).fromNow(refresh=True) }} {% endif %}</span>
|
<span class="text-muted small" aria_label="{{ _('When: ') }}">{{ moment(comment['comment'].posted_at).fromNow(refresh=True) }}{% if comment['comment'].edited_at %}, edited {{ moment(comment['comment'].edited_at).fromNow(refresh=True) }} {% endif %}</span>
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
{{ render_field(form.markdown_editor) }}
|
{{ render_field(form.markdown_editor) }}
|
||||||
{{ render_field(form.default_sort) }}
|
{{ render_field(form.default_sort) }}
|
||||||
{{ render_field(form.theme) }}
|
{{ render_field(form.theme) }}
|
||||||
{{ render_field(form.comment_length_warning) }}
|
|
||||||
<small class="field_hint">{{ _('Accounts which usually post comments shorter than this will have a warning. Set to 0 to disable warning.') }}</small>
|
<small class="field_hint">{{ _('Accounts which usually post comments shorter than this will have a warning. Set to 0 to disable warning.') }}</small>
|
||||||
<h5>Import</h5>
|
<h5>Import</h5>
|
||||||
{{ render_field(form.import_file) }}
|
{{ render_field(form.import_file) }}
|
||||||
|
|
|
@ -50,7 +50,6 @@ class SettingsForm(FlaskForm):
|
||||||
]
|
]
|
||||||
default_sort = SelectField(_l('By default, sort posts by'), choices=sorts, validators=[DataRequired()], coerce=str, render_kw={'class': 'form-select'})
|
default_sort = SelectField(_l('By default, sort posts by'), choices=sorts, validators=[DataRequired()], coerce=str, render_kw={'class': 'form-select'})
|
||||||
theme = SelectField(_l('Theme'), coerce=str, render_kw={'class': 'form-select'})
|
theme = SelectField(_l('Theme'), coerce=str, render_kw={'class': 'form-select'})
|
||||||
comment_length_warning = IntegerField(_('Useless comment cutoff length'))
|
|
||||||
submit = SubmitField(_l('Save settings'))
|
submit = SubmitField(_l('Save settings'))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,6 @@ def change_settings():
|
||||||
current_user.email_unread = form.email_unread.data
|
current_user.email_unread = form.email_unread.data
|
||||||
current_user.markdown_editor = form.markdown_editor.data
|
current_user.markdown_editor = form.markdown_editor.data
|
||||||
current_user.interface_language = form.interface_language.data
|
current_user.interface_language = form.interface_language.data
|
||||||
current_user.comment_length_warning = form.comment_length_warning.data
|
|
||||||
session['ui_language'] = form.interface_language.data
|
session['ui_language'] = form.interface_language.data
|
||||||
import_file = request.files['import_file']
|
import_file = request.files['import_file']
|
||||||
if propagate_indexable:
|
if propagate_indexable:
|
||||||
|
@ -228,7 +227,6 @@ def change_settings():
|
||||||
form.theme.data = current_user.theme
|
form.theme.data = current_user.theme
|
||||||
form.markdown_editor.data = current_user.markdown_editor
|
form.markdown_editor.data = current_user.markdown_editor
|
||||||
form.interface_language.data = current_user.interface_language
|
form.interface_language.data = current_user.interface_language
|
||||||
form.comment_length_warning.data = current_user.comment_length_warning
|
|
||||||
|
|
||||||
return render_template('user/edit_settings.html', title=_('Edit profile'), form=form, user=current_user,
|
return render_template('user/edit_settings.html', title=_('Edit profile'), form=form, user=current_user,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue