Commit graph

45 commits

Author SHA1 Message Date
c5cd77e9ee Stop concurrent imports from racing on package names
Production imports kept aborting with
ActiveRecord::RecordNotUnique on packages_name_key and - on
environments that never got the constraint - silently created
duplicate packages. Root cause: overlapping update_from_deb_repos
runs (scheduled + manual) both do find-by-name then insert; whichever
wins the race aborts the whole run, whichever loses gets a
duplicate if the constraint was missing.

Three things so the mechanism stops being the problem:

- An advisory lock serializes update_from_deb_repos runs. A second
  run that finds the lock held simply skips with a warning instead
  of racing the first one. The lock is session-scoped, so it is
  released automatically when the process exits.
- A per-package rescue for ActiveRecord::RecordNotUnique. If a
  create still races (e.g. a package being created by a web upload),
  the package is re-fetched and updated instead of aborting the run.
- A real migration for packages_name_key, which previously only
  existed where it had been added by hand. From now on db:migrate
  creates it everywhere, new databases included.

Also verified with a reproduction: a single sequential run of the
deployed importer against a fresh database (both architectures,
~54k packages) creates zero duplicates.
2026-09-04 21:57:35 +02:00
4948fe50e3 Add semantic package search via pgvector embeddings
Package text search now combines several strategies: exact name match,
name prefix promotion, compound word splitting ("sqlite browser" finds
"sqlitebrowser") and semantic nearest neighbor search over description
embeddings computed by an external embedding service (all-MiniLM-L6-v2,
384 dims) stored with the pgvector extension. Classic PostgreSQL
full-text search remains as fallback when the vector service is
unreachable. Gibberish queries without lexical overlap with the package
data return empty results instead of random matches.

Embeddings can be backfilled with bin/rails debshots:compute_vectors.

Also drops the unused lograge gem from the Gemfile.
2026-08-22 22:07:56 +02:00
5b624e6c30 Merge branch 'prod' 2023-12-26 01:21:15 +01:00
92aca77cdb General Rails and Ruby updates 2021-05-28 21:07:45 +02:00
9635b3968c Added per-user counter of approved/rejected screenshots 2021-03-21 23:06:51 +01:00
5d0e4a520e Allow hiding and un-hiding of screenshot by moderators 2021-03-10 01:04:37 +01:00
2fef9c7043 Audit logging improved. References users, screenshots, packages 2021-03-03 23:21:24 +01:00
7a3b65fe50 Authorisation management using CanCanCan added 2021-02-28 21:36:46 +01:00
3f2928e737 Recreate ipaddress field as PostgreSQL's inet type 2021-02-22 11:31:41 +01:00
16b14b1650 Extend uploaderip field to cope with IPv6 addresses 2021-02-22 11:25:13 +01:00
c4f5741b0c Migration to Shrine attachment handling 2020-11-01 15:07:16 +01:00
7ac69a1d8a Rails update. Fancybox update. Migrations from Paperclip. 2020-10-19 18:49:47 +02:00
cc080191fb Added explicit Rails version to migrations as needed for Rails 6 2020-08-16 19:22:47 +02:00
8adf682a0b Migrations and helpers to move from Paperclip to ActiveStorage
To migrate the application as of April 2020:

• leave models/screenshot.rb with “has_attached_file”
• bundle exec rake db:migrate
• bin/move_paperclip_to_activestorage
• set models/screenshot.rb to “has_one_attached”
2020-04-20 20:24:59 +02:00
020a864736 Added welcome and profile actions to the my controller 2017-04-23 13:37:48 +02:00
63634f00df Allow same email address with different SSO providers 2017-04-06 18:32:20 +02:00
9a5ddb5e13 Experimental authentication for Launchpad and Google added 2017-04-06 12:56:06 +02:00
464fc0de95 Renamed realname to name in users table
We do not necessarily need the real name. A nickname would be
sufficient.
2017-04-05 16:42:10 +02:00
e2671d2545 Text search now properly weighted and ranked
Default order by 'name' removed so that ranking can actually work.
2016-08-12 16:40:12 +02:00
5227c8d1fa Setting default visit counter to 0 2016-08-10 18:59:33 +02:00
5df0a96b1d Column 'visits' added to packages
Preparation for processing web server access logs to count visits of
packages.
2016-08-10 08:45:25 +02:00
9024833921 Enlarged screenshot description field to 80 chars 2016-07-15 20:10:34 +02:00
79d16b1ce0 Approved field is now false by default 2016-04-08 16:42:46 +02:00
3eeb9a63dc Using created_at instead of legacy 'uploaddatetime' field 2016-03-04 15:41:50 +01:00
16540c64f9 Removing timestamp creation - fields already created earlier 2016-03-04 10:25:50 +01:00
b1bd655998 Fixed database schema and migrations for Devise 2016-03-02 15:30:32 +01:00
a7c8f08972 Migrations cleaned up 2016-03-01 17:57:32 +01:00
d376f2e0d1 Cleanup 2016-03-01 17:48:09 +01:00
9853af43de Enable lockable feature of Devise to lock out users after brute force attempts 2015-07-15 17:30:47 +02:00
35eb83448e Added "devise" for authentication. 2015-07-15 17:06:32 +02:00
e6a0f15340 Removed "authlogic" completely. Let's try "devise". 2015-07-15 17:05:56 +02:00
737ff62cfc Trying to get authlogic running 2015-07-13 18:42:36 +02:00
56f38bcdcf Make sure that a package has a valid name
If this contraint had been there I would have found a bug
in the import_debian Rake task much sooner.
2015-06-28 15:08:16 +02:00
3b056a2db8 Added authlogic and user schema 2015-06-15 13:04:29 +02:00
239a4758c0 Dropping old "admins" table in favor of new User model. 2015-05-03 15:08:23 +02:00
5c31a94aef Devise removed. Broke tests. Trying another auth gem. 2015-05-03 13:31:13 +02:00
3988c7ddf3 Devise authentication added - no registration though 2015-05-02 16:16:29 +02:00
ac3d52a66e Adding Log model for database-based log messages 2015-04-27 00:15:55 +02:00
f741112818 Added migration to make package.long_description a longer text field 2015-04-23 17:19:11 +02:00
4a0a3c3123 Added Paperclip migrations 2015-01-04 14:19:27 +01:00
d895aa2d1d Migration added that fixes full-text search 2014-12-31 17:32:53 +01:00
8b9b40fdee Added migration to remove debtags tables 2014-12-07 22:31:44 +01:00
110cd16d6e Adding database index on full-text search for better performance. 2013-08-08 22:32:41 +02:00
f9e920aea5 Added migration to add timestamp column for screenshots 2013-08-06 22:37:17 +02:00
8df03296e9 Schema and basic migraton for "package" table added 2013-07-27 01:23:51 +02:00