mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
stats
This commit is contained in:
parent
64da72f0b9
commit
82b89d66de
2 changed files with 26 additions and 2 deletions
18
app/cli.py
18
app/cli.py
|
@ -12,7 +12,7 @@ from app.activitypub.signature import RsaKeys
|
|||
from app.auth.util import random_token
|
||||
from app.email import send_verification_email
|
||||
from app.models import Settings, BannedInstances, Interest, Role, User, RolePermission, Domain, ActivityPubLog, \
|
||||
utcnow, Site, Instance
|
||||
utcnow, Site, Instance, File
|
||||
from app.utils import file_get_contents, retrieve_block_list
|
||||
|
||||
|
||||
|
@ -164,6 +164,22 @@ def register(app):
|
|||
file.file_path = ''
|
||||
db.session.commit()
|
||||
|
||||
def list_files(directory):
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
yield os.path.join(root, file)
|
||||
|
||||
@app.cli.command("findorphanfiles")
|
||||
def findorphanfiles():
|
||||
with app.app_context():
|
||||
for file_path in list_files('app/static/media/users'):
|
||||
|
||||
if 'thumbnail' in file_path:
|
||||
f = File.query.filter(File.thumbnail_path == file_path).first()
|
||||
else:
|
||||
f = File.query.filter(File.file_path == file_path).first()
|
||||
if f is None:
|
||||
print(file_path)
|
||||
|
||||
def parse_communities(interests_source, segment):
|
||||
lines = interests_source.split("\n")
|
||||
|
|
|
@ -20,7 +20,7 @@ from sqlalchemy_searchable import search
|
|||
from app.utils import render_template, get_setting, gibberish, request_etag_matches, return_304, blocked_domains, \
|
||||
ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \
|
||||
joined_communities, moderating_communities, parse_page, theme_list
|
||||
from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic
|
||||
from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic, File
|
||||
from PIL import Image
|
||||
import pytesseract
|
||||
|
||||
|
@ -247,8 +247,16 @@ def keyboard_shortcuts():
|
|||
return render_template('keyboard_shortcuts.html')
|
||||
|
||||
|
||||
def list_files(directory):
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
yield os.path.join(root, file)
|
||||
|
||||
|
||||
@bp.route('/test')
|
||||
def test():
|
||||
|
||||
return ''
|
||||
retval = ''
|
||||
for user in User.query.all():
|
||||
filesize = user.filesize()
|
||||
|
|
Loading…
Reference in a new issue