Commit Graph

1061 Commits

Author SHA1 Message Date
Oliver Falk
15062b3cda Return full avatar URLs instead of digests in stats
- Replace digest_sha256 with avatar_url in top_viewed_avatars
- Replace digest_sha256 with avatar_url in top_queried_emails
- Replace digest_sha256 with avatar_url in top_queried_openids
- All avatar URLs now use https://libravatar.org/avatar/{digest} format
- Update tests to verify avatar_url presence and correct format
- All 5 stats tests pass successfully

This makes the stats API more user-friendly by providing complete
avatar URLs that can be directly used in applications instead of
requiring clients to construct the URLs themselves.
2025-09-26 09:21:00 +02:00
Oliver Falk
928ffaea76 Switch to my version until upstream is fixed 2025-09-24 17:27:43 +02:00
Oliver Falk
2fbdd74619 Use newer image, now with the new server also having newer Python 2025-09-24 17:12:36 +02:00
Oliver Falk
44a738d724 Fix code comment 2025-09-24 09:40:33 +02:00
Oliver Falk
10255296d5 Fix SQLite AVG() type conversion in photo size stats
- Convert avg_size_bytes to float to handle SQLite returning string values
- Fixes TypeError: '>' not supported between instances of 'str' and 'int'
- Ensures photo size statistics work correctly across different database backends
- All 5 stats tests pass successfully

The issue occurred because SQLite's AVG() function can return string representations
of numbers in some cases, causing type comparison errors in tests.
2025-09-24 09:40:33 +02:00
Oliver Falk
213e0cb213 Remove privacy-sensitive data from stats JSON response
- Remove email addresses from top_viewed_avatars and top_queried_emails
- Remove OpenID URLs from top_viewed_avatars and top_queried_openids
- Remove Bluesky handles from bluesky_handles section
- Keep only access_count and digest_sha256 for privacy protection
- Update tests to reflect privacy changes
- All 5 stats tests pass successfully

This ensures that the stats endpoint no longer exposes:
- User email addresses
- OpenID URLs
- Bluesky handles
- Any other personally identifiable information

The stats now only show aggregated counts and hashed identifiers.
2025-09-24 09:40:33 +02:00
Oliver Falk
4a684f9947 Refactor stats tests into separate file with random data
- Add random_ip_address() function to ivatar.utils for generating random IP addresses
- Create separate test_views_stats.py file with StatsTester class
- Move all stats tests from test_views.py to test_views_stats.py
- Update tests to use random_string() for emails and OpenIDs instead of static @example.com
- Update tests to use random_ip_address() for IP addresses instead of static 192.168.1.x
- Remove stats tests from original test_views.py file
2025-09-24 09:40:33 +02:00
Oliver Falk
9d647fe075 Add comprehensive tests for StatsView
- Add test_stats_basic: Test basic count statistics
- Add test_stats_comprehensive: Test all new statistics with real data
- Add test_stats_edge_cases: Test edge cases with empty data
- Add test_stats_with_bluesky_handles: Test Bluesky handles functionality
- Add test_stats_photo_duplicates: Test potential duplicate photos detection

All tests cover:
- Top 10 viewed avatars with associated email/OpenID details
- Top 10 queried email addresses and OpenIDs
- Photo format distribution statistics
- User activity metrics (multiple photos, email+OpenID users, avg photos per user)
- Bluesky handles statistics with top handles by access count
- Average photo size calculation using SQL queries
- Potential duplicate photos detection by format and size
- Edge cases and error handling

Tests use valid PNG image data and proper model relationships.
All 5 new test methods pass successfully.
2025-09-24 09:40:33 +02:00
Oliver Falk
a58e812fb6 Add comprehensive statistics to StatsView
- Implement top 10 viewed avatars with associated email/OpenID details
- Add top 10 queried email addresses and OpenIDs by access count
- Include photo format distribution statistics
- Add user activity metrics (multiple photos, email+OpenID users, avg photos per user)
- Implement Bluesky handles statistics with top handles by access count
- Add average photo size calculation using fast SQL queries
- Include potential duplicate photos detection by format and size
- Use raw SQL for performance optimization on large datasets
- Remove orphaned photos check as requested

All statistics now return consistent data structure with access_count and digest_sha256 fields.
2025-09-24 09:40:33 +02:00
Oliver Falk
9d3d5fe5a1 Merge branch 'devel' into 'master'
Hotfixes from Devel

See merge request oliver/ivatar!252
2025-09-15 15:17:24 +02:00
Oliver Falk
ed27493abc Simple logic error and some Bluesky (still beta) fixes 2025-09-15 09:49:53 +02:00
Oliver Falk
94b21c15d2 Merge branch 'devel' into 'master'
Middleware and logging adjustments

See merge request oliver/ivatar!250
2025-09-13 18:35:26 +02:00
Oliver Falk
f7d72c18fb This is creating a lot of noise and caching now anyway happens more on Apache side - use debug logging 2025-09-13 18:20:22 +02:00
Oliver Falk
7a1e38ab50 Use the hash value from the URL instead, less compute intense and more reliable 2025-09-12 11:49:34 +02:00
Oliver Falk
9d390a5b19 Add last modified and etag for better caching 2025-09-11 20:07:24 +02:00
Oliver Falk
52576bbf18 Remove the debug print 2025-09-11 20:00:47 +02:00
Oliver Falk
d720fcfa50 Rename the custom middleware to ensure it's know this is a localemiddleware. Also ensure we delete the Vary header, it could be empty - still problematic 2025-09-11 19:54:40 +02:00
Oliver Falk
02b199333a Merge branch 'devel' into 'master'
Final Vary headers fix from devel

See merge request oliver/ivatar!249
2025-09-11 14:50:55 +02:00
Oliver Falk
c6e1583e7e Merge with master 2025-09-11 14:32:28 +02:00
Oliver Falk
5114b4d5d0 We actually need to implement this via Middleware, as the Locale Middleware comes later in the process and hinders us from removing the header. Anyway, it's cleaner, since we're not duplicating code 2025-09-11 14:22:34 +02:00
Oliver Falk
f81d6bb84c Merge branch 'devel' into 'master'
Hotfixes from devel

See merge request oliver/ivatar!248
2025-09-11 14:18:41 +02:00
Oliver Falk
16dd861953 Hotfixes from devel 2025-09-11 14:18:41 +02:00
Oliver Falk
4316c2bcc6 Merge branch 'master' into devel 2025-09-11 13:59:34 +02:00
Oliver Falk
b711594c1f We need to ensure the Vary setting isn't set of image responses 2025-09-11 13:55:08 +02:00
Oliver Falk
0d16b1f518 Remove the token auth - that was a bad idea. We may look into implementing a full oauth solution at a later point in time 2025-09-09 10:42:16 +02:00
Oliver Falk
4abbfeaa36 Handle next parameter on the token auth page to correctly redirect to the initiating page 2025-09-08 12:52:24 +02:00
Oliver Falk
13f13f7443 The login page is missing the next parameters, preventing it from working properly 2025-09-08 10:55:23 +02:00
Oliver Falk
f5c8cda222 Login page didn't respect the next parameter, bad UX. Fixed. 2025-09-08 10:37:22 +02:00
Oliver Falk
59c8db6aec Unauthenticated accesses need to be redirected for the full auth flow to work properly 2025-09-08 10:30:21 +02:00
Oliver Falk
ebfcd67512 One more fix for multiple objects 2025-09-07 17:18:18 +02:00
Oliver Falk
0df2af4f4b Unauthenticated requests leads to error - fix that case 2025-09-07 12:53:37 +02:00
Oliver Falk
797ec91320 Missing constraint 2025-09-07 11:59:48 +02:00
Oliver Falk
85c06cd42c §Fix and enhance tests, esp. remove occurances of hardcoded username/pass/email. Also treat request to admin group special and also allow superusers, which is a flag on the userobject and not a group 2025-09-06 11:13:11 +02:00
Oliver Falk
aa742ea181 Implement ExternalAuth for token based authorization 2025-09-06 10:28:50 +02:00
Oliver Falk
deeaab7e23 Identation fixes 2025-09-06 10:26:56 +02:00
Oliver Falk
0832ac9fe0 Some syntax adjustments 2025-09-06 10:26:18 +02:00
Oliver Falk
b3f580e51b Merge branch 'devel' into 'master'
Pull in fixes and updates from devel

See merge request oliver/ivatar!247
2025-08-23 16:17:58 +02:00
Oliver Falk
12bc7e5af4 Filter is a reserved word 2025-08-23 15:35:36 +02:00
Oliver Falk
e44a84e9ae Add thanks for Ezequiel 2025-08-23 15:35:36 +02:00
Oliver Falk
a1d13ba3ce MAX_ENTRIES for PyMemcacheCache doesn't work with all versions - remove it. 2025-08-13 21:40:37 +02:00
Oliver Falk
aa3e1e48dc Merge branch 'master' into devel 2025-05-24 16:31:44 +02:00
Oliver Falk
919ed4d485 We need to check if we already have an ID 2025-05-24 16:30:21 +02:00
Oliver Falk
cb7328fe23 Initial shot at invalidating the cache entry - to be confirmed to work (read: TODO) 2025-05-24 16:16:00 +02:00
Oliver Falk
1892e9585e Increase cache entries 2025-05-24 16:15:02 +02:00
Oliver Falk
7d0d2f931b Merge branch 'devel' into 'master'
Update exception handling for Bluesky to Email

See merge request oliver/ivatar!246
2025-05-07 10:28:12 +02:00
Oliver Falk
5dcd69f332 Handle exceptions during Bluesky assignment to email the same way we handle it for OpenID 2025-05-07 10:13:01 +02:00
Oliver Falk
1560a5d1de Merge branch 'devel' into 'master'
Quick fix to handle an exception in Bluesky handle assignment

See merge request oliver/ivatar!245
2025-05-07 09:06:41 +02:00
Oliver Falk
1f17526fac Move the setting of the handle up to ensure we catch the potential exception as well 2025-05-07 08:47:19 +02:00
Oliver Falk
c36d0fb808 Merge branch 'devel' into 'master'
Merge devel for updating the Bluesky test handles

See merge request oliver/ivatar!244
2025-05-06 14:25:41 +02:00
Oliver Falk
771a386bf4 Change to the libravatar handle 2025-05-06 13:17:31 +02:00