Commit Graph

304 Commits (d58173e45bf0fdf5a6015d40eb88c313a3d99e5c)

Author SHA1 Message Date
Matt Jankowski 477412d62a
Use hash arguments to `select` when possible (Rails 7.2) (#32917) 1 month ago
Matt Jankowski 68b545ef33
Add `Status.not_direct_visibility` scope (#32065) 2 months ago
Jonny Saunders 9074c1fac9
Use `likes` and `shares` totalItems on status creations and updates (#32620) 2 months ago
Christian Schmidt 8cdc148167
Handle invalid visibility (#31571) 4 months ago
Claire d41b43ed4f
Limit attachments to `MEDIA_ATTACHMENTS_LIMIT` when returning posts through the API (#30932) 6 months ago
Eugen Rochko 128987eded
Add support for `fediverse:creator` OpenGraph tag (#30398) 7 months ago
Matt Jankowski c61e356475
Add `Status::MEDIA_ATTACHMENTS_LIMIT` configuration constant (#30433) 7 months ago
Claire e5062b7135
Fix post deletion not being deferred when those are part of an account warning (#30163) 8 months ago
Matt Jankowski 88882fbbee
Move Rails/HABTM cop out of todo (#30118) 8 months ago
Matt Jankowski ac7f4d57bb
Use composable query in `Status.without_replies` scope (#30086) 8 months ago
Matt Jankowski caad1e2628
Add scope `Status.distributable_visibility` (#29950) 9 months ago
Matt Jankowski 3159c0a547
Add scope `Status.list_eligible_visibility` (#29951) 9 months ago
Claire babbf6017d
Remove caching in `cache_collection` (#29862) 9 months ago
Matt Jankowski 1d0a43f6a3
Use composable query in `Status.not_domain_blocked_by_account` scope (#29766) 9 months ago
Matt Jankowski 6c3e718b86
Remove setting of `sensitive` value (default false, not null) in Status model (#29589) 10 months ago
Matt Jankowski 0bc17a3d48
Use enum-generated `public_visibility` scope on Status (#28156) 10 months ago
Wolfgang Fournès cfadb87077
Update enum syntax to use the new Rails 7.0 style (#29217) 11 months ago
Matt Jankowski 9d413cbaf8
Fix `Rails/WhereExists` cop in app/models (#28863) 11 months ago
Matt Jankowski aaa6f2e930
Group common `class_name` options in associations (#28779) 11 months ago
Matt Jankowski 4ccba94489
Remove unused `*_silenced_accounts` scopes on Status (#28644) 12 months ago
Claire 2bf84b93d4
Fix media attachment order of remote posts (#28469) 1 year ago
Matt Jankowski 3918dc68c7
Use composite primary key for `PreviewCardsStatus` model (#28208) 1 year ago
Matt Jankowski f70f39dd04
Add explicit `dependent: nil` to associations (#28169) 1 year ago
Matt Jankowski 440b80b2e7
Model concerns organization into module namespaces (#28149) 1 year ago
Eugen Rochko 0d14fcebae
Change link previews to keep original URL from the status (#27312) 1 year ago
Claire 9e77ab7db2
Change private statuses index to index without crutches (#26713) 1 year ago
jsgoldstein 30c191aaa0
Add new public status index (#26344)
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
1 year ago
Claire 60b9fa641d
Fix cached posts including stale stats (#26409) 1 year ago
Claire d5bee37c57
Fix missing cached preview cards attributes (#26343) 1 year ago
Matt Jankowski 644c5fddd8
Refactor `Status.tagged_with_all` for brakeman SQL injection warning (#25941) 1 year ago
Matt Jankowski 0b249ebdb0
Extract StatusSafeReblogInsert concern from Status (#24821) 2 years ago
Matt Jankowski b5c4b47746
Fix Rails/ActiveRecordCallbacksOrder cop (#24689) 2 years ago
Matt Jankowski af824db398
Fix Rails/InverseOf cop (#24732) 2 years ago
Claire f53d009778
Refactor `Status._insert_record` slightly and tighten the test around reblogs of discarded statuses (#24516) 2 years ago
Claire 2626097869
Fix Rails cache namespace being overriden with `v2` for cached statuses (#24202) 2 years ago
Vyr Cossont 94cbd808b5
Webhooks for local status.create, status.update, account.update (#24133) 2 years ago
Christian Schmidt bd047acc35
Replace `Status#translatable?` with language matrix in separate endpoint (#24037) 2 years ago
Christian Schmidt 5a8c651e8f
Only offer translation for supported languages (#23879) 2 years ago
Nick Schonning 9909b4b653
Autofix Rubocop Rails/WhereEquals (#23759) 2 years ago
Nick Schonning 717683d1c3
Autofix Rubocop remaining Layout rules (#23679) 2 years ago
Nick Schonning 63e6353886
Autofix Rubocop Rails/EnumHash (#23737) 2 years ago
Nick Schonning 597767a9f7
Autofix Rubocop Rails/RedundantForeignKey (#23731) 2 years ago
Nick Schonning 2177daeae9
Autofix Rubocop Style/RedundantBegin (#23703) 2 years ago
Nick Schonning ab7816a414
Autofix Rubocop Style/Lambda (#23696) 2 years ago
Claire 13a2abacc8
Add `roles` attribute to Account entities in REST API (#23255) 2 years ago
Kaspar V ae62e5fa53
Fix/remove calling private method with send in model (#22951)
* fix(status): remove send usage for private unlink_from_conversations

- make unlink_from_conversations public method
- rename unlink_from_conversations to unlink_from_conversations!
- fix send call on private method in statuses_vacuum and batched_remove_status_service

* fix(feeds_vacuum): replace find_in_batches with in_batches

because active record query results should be a little more efficient than
itterating with map and each. Postgres can grasp such lists of ids much quicker
than ruby can.
Will probably make allmost no difference, but cannot hurt either.
2 years ago
Kaspar V 47f0d7021e
refactor(vacuum statuses): reduce amount of db queries and load for each query - improve performance (#21487)
* refactor(statuses_vacuum): remove dead code - unused

Method is not called inside class and private.
Clean up dead code.

* refactor(statuses_vacuum): make retention_period present test explicit

This private method only hides functionality.
It is best practice to be as explicit as possible.

* refactor(statuses_vacuum): improve query performance

- fix statuses_scope having sub-select for Account.remote scope by
  `joins(:account).merge(Account.remote)`
- fix statuses_scope unnecessary use of `Status.arel_table[:id].lt`
  because it is inexplicit, bad practice and even slower than normal
  `.where('statuses.id < ?'`
- fix statuses_scope remove select(:id, :visibility) for having reusable
  active record query batches (no re queries)
- fix vacuum_statuses! to use in_batches instead of find_in_batches,
  because in_batches delivers a full blown active record query result,
  in stead of an array - no requeries necessary
- send(:unlink_from_conversations) not to perform another db query, but
  reuse the in_batches result instead.
- remove now obsolete remove_from_account_conversations method
- remove_from_search_index uses array of ids, instead of mapping
  the ids from an array - this should be more efficient
- use the in_batches scope to call delete_all, instead of running
  another db query for this - because it is again more efficient
- add TODO comment for calling models private method with send

* refactor(status): simplify unlink_from_conversations

- add `has_many through:` relation mentioned_accounts
- use model scope local instead of method call `Status#local?`
- more readable add account to inbox_owners when account.local?

* refactor(status): searchable_by way less sub selects

These queries all included a sub-select. Doing the same with a joins
should be more efficient.
Since this method does 5 such queries, this should be significant,
since it technically halves the query count.

This is how it was:

```ruby
[3] pry(main)> Status.first.mentions.where(account: Account.local, silent: false).explain
  Status Load (1.6ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL ORDER BY "statuses"."id" DESC LIMIT $1  [["LIMIT", 1]]
  Mention Load (1.5ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."status_id" = $1 AND "mentions"."account_id" IN (SELECT "accounts"."id" FROM "accounts" WHERE "accounts"."domain" IS NULL) AND "mentions"."silent" = $2  [["status_id", 109382923142288414], ["silent", false]]
=> EXPLAIN for: SELECT "mentions".* FROM "mentions" WHERE "mentions"."status_id" = $1 AND "mentions"."account_id" IN (SELECT "accounts"."id" FROM "accounts" WHERE "accounts"."domain" IS NULL) AND "mentions"."silent" = $2 [["status_id", 109382923142288414], ["silent", false]]
                                                    QUERY PLAN
------------------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.15..23.08 rows=1 width=41)
   ->  Seq Scan on accounts  (cost=0.00..10.90 rows=1 width=8)
         Filter: (domain IS NULL)
   ->  Index Scan using index_mentions_on_account_id_and_status_id on mentions  (cost=0.15..8.17 rows=1 width=41)
         Index Cond: ((account_id = accounts.id) AND (status_id = '109382923142288414'::bigint))
         Filter: (NOT silent)
(6 rows)
```

This is how it is with this change:

```ruby
[4] pry(main)> Status.first.mentions.joins(:account).merge(Account.local).active.explain
  Status Load (1.7ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL ORDER BY "statuses"."id" DESC LIMIT $1  [["LIMIT", 1]]
  Mention Load (0.7ms)  SELECT "mentions".* FROM "mentions" INNER JOIN "accounts" ON "accounts"."id" = "mentions"."account_id" WHERE "mentions"."status_id" = $1 AND "accounts"."domain" IS NULL AND "mentions"."silent" = $2  [["status_id", 109382923142288414], ["silent", false]]
=> EXPLAIN for: SELECT "mentions".* FROM "mentions" INNER JOIN "accounts" ON "accounts"."id" = "mentions"."account_id" WHERE "mentions"."status_id" = $1 AND "accounts"."domain" IS NULL AND "mentions"."silent" = $2 [["status_id", 109382923142288414], ["silent", false]]
                                                    QUERY PLAN
------------------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.15..23.08 rows=1 width=41)
   ->  Seq Scan on accounts  (cost=0.00..10.90 rows=1 width=8)
         Filter: (domain IS NULL)
   ->  Index Scan using index_mentions_on_account_id_and_status_id on mentions  (cost=0.15..8.17 rows=1 width=41)
         Index Cond: ((account_id = accounts.id) AND (status_id = '109382923142288414'::bigint))
         Filter: (NOT silent)
(6 rows)
```
2 years ago
Claire c2170991c7
Fix reblogs being discarded after the reblogged status (#19731) 2 years ago
Eugen Rochko 45ebdb72ca
Add support for language preferences for trending statuses and links (#18288) 2 years ago
Eugen Rochko 9f65909f42
Change public timelines to be filtered by current locale by default (#19291)
In the absence of an opt-in to multiple specific languages in the
preferences, it makes more sense to filter by the user's presumed
language only (interface language or `lang` override)
2 years ago