Skip to content

Commit

Permalink
optimize people cover cache
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang committed Mar 1, 2025
1 parent 7cda15e commit 793306a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const People = ({ haveFreezed, people, onOpenPeople, onRename, onFreezed, onUnFr

const similarPhotoURL = useMemo(() => {
const repoID = window.sfMetadataContext.getSetting('repoID');
return `${siteRoot}thumbnail/${repoID}/${thumbnailDefaultSize}/_Internal/Faces/${people._id}.jpg`;
let photoURL = `${siteRoot}thumbnail/${repoID}/${thumbnailDefaultSize}/_Internal/Faces/${people._id}.jpg`;
if (people._name === '_Unknown_people') {
return photoURL;
}
return `${photoURL}?t=${people.file_mtime}`;
}, [people]);

const onImgLoadError = useCallback(() => {
Expand Down
7 changes: 7 additions & 0 deletions seahub/repo_metadata/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,12 @@ def get(self, request, repo_id):
faces_records = query_result.get('results', [])
metadata_columns = query_result.get('metadata', [])

dirents = seafile_api.list_dir_by_path(repo_id, '/_Internal/Faces')
file_name_to_mtime_dict = {}
for dirent in dirents:
file_name, ext = os.path.splitext(dirent.obj_name)
file_name_to_mtime_dict[file_name] = dirent.mtime

valid_faces_records = []
for record in faces_records:

Expand All @@ -1290,6 +1296,7 @@ def get(self, request, repo_id):
FACES_TABLE.columns.name.name: record.get(FACES_TABLE.columns.name.name),
FACES_TABLE.columns.photo_links.name: valid_photo_links,
'_is_someone': record.get(FACES_TABLE.columns.name.name) != UNKNOWN_PEOPLE_NAME,
'file_mtime': file_name_to_mtime_dict.get(record.get(FACES_TABLE.columns.id.name))
})

return Response({
Expand Down

0 comments on commit 793306a

Please sign in to comment.