Commit graph

357 commits

Author SHA1 Message Date
Matt Jankowski
0b249ebdb0
Extract StatusSafeReblogInsert concern from Status (#24821) 2023-05-04 14:06:20 +02:00
Matt Jankowski
b5c4b47746
Fix Rails/ActiveRecordCallbacksOrder cop (#24689) 2023-05-02 18:23:35 +02:00
KMY
3a1a6ba39e Merge commit '15fd712464' into kb_migration 2023-05-01 15:05:34 +09:00
Matt Jankowski
af824db398
Fix Rails/InverseOf cop (#24732) 2023-04-30 14:06:53 +02:00
KMY
9b032185b8 Merge branch 'kb_development' into kb_migration 2023-04-25 10:32:16 +09:00
KMY
7e125b276f Remove extra media attachments and support raw array 2023-04-22 17:13:48 +09:00
KMY
004129dfbb Set mark searchability unlisted as activitypub note 2023-04-16 09:55:21 +09:00
KMY
1582bb0610 Merge commit '8a412f0f59' into kb_migration 2023-04-15 14:44:23 +09:00
KMY
81f32dee4f Change column name emoji_reactions_count_per_account to emoji_reaction_accounts_count 2023-04-14 17:27:50 +09:00
KMY
d52daef203 Merge commit 'fed859a7d6' into kb_migration 2023-04-14 10:21:19 +09:00
KMY
fed859a7d6 Add emoji_reactions_count_per_account 2023-04-14 10:20:15 +09:00
KMY
4c6f15fca1 Merge commit 'af49d93fd6' into kb_migration 2023-04-13 18:57:57 +09:00
KMY
5a661415e2 Merge commit 'fac734b6a8' into kb_migration 2023-04-13 18:57:03 +09:00
Claire
f53d009778
Refactor Status._insert_record slightly and tighten the test around reblogs of discarded statuses (#24516) 2023-04-12 12:47:05 +02:00
KMY
25c3915728 Add markdown selection support 2023-04-12 10:16:46 +09:00
KMY
d4e0ef254d Fix trends error 2023-04-11 12:47:01 +09:00
KMY
139030f230 Merge branch 'kb_development' into kb_migration 2023-04-10 14:14:00 +09:00
KMY
e6fcf1543b Add emoji reactions to trends 2023-04-10 14:08:53 +09:00
KMY
c459fcb78b Merge commit '55f59b4343' into kb_migration 2023-04-09 09:28:58 +09:00
KMY
0b9151859d Separate media_attachments property 2023-04-08 09:35:23 +09:00
KMY
94cd200097 Merge remote-tracking branch 'origin/kb_development' into kb_migration 2023-04-06 16:57:01 +09:00
KMY
60d54b847e Fix searchability values 2023-04-06 13:50:08 +09:00
KMY
af20b1d2aa Add searchability support 2023-04-06 04:27:52 +09:00
KMY
86915f0cdb Merge branch 'kb_development' into kb_migration 2023-04-05 18:55:45 +09:00
KMY
08e5d96a4a Expand search range 2023-04-05 13:55:37 +09:00
KMY
76340285d6 Merge commit '34225d7199' into kb_migration 2023-03-27 14:06:56 +09:00
Claire
2626097869
Fix Rails cache namespace being overriden with v2 for cached statuses (#24202) 2023-03-22 15:47:44 +01:00
KMY
348a641eca Merge remote-tracking branch 'parent/main' into kb_migration 2023-03-21 15:20:15 +09:00
KMY
0071b15fa3 Merge remote-tracking branch 'origin/kb_development' into kb_migration 2023-03-21 15:20:00 +09:00
KMY
16079b4db5 Add status expiration 2023-03-21 11:12:33 +09:00
Vyr Cossont
94cbd808b5
Webhooks for local status.create, status.update, account.update (#24133) 2023-03-19 07:47:54 +01:00
KMY
7a4dc84202 Merge remote-tracking branch 'parent/main' into kb_migration 2023-03-18 13:30:34 +09:00
Christian Schmidt
bd047acc35
Replace Status#translatable? with language matrix in separate endpoint (#24037) 2023-03-16 11:07:24 +01:00
KMY
9e2390f3c9 Merge branch 'kb_development' into kb_migration 2023-03-08 16:38:48 +09:00
KMY
df6f55b750 Remove muted accounts emoji reaction 2023-03-08 16:33:36 +09:00
KMY
ed3abf4f2a Add public_unlisted scope as status privacy 2023-03-05 13:24:31 +09:00
KMY
370f25f3cd Merge commit 'aa98c8fbeb' into kb_migration 2023-03-04 09:46:40 +09:00
Christian Schmidt
5a8c651e8f
Only offer translation for supported languages (#23879) 2023-03-03 21:06:31 +01:00
KMY
9ad51e001e Add emoji_reactioned_by_slim api (not work) 2023-02-27 08:45:11 +09:00
KMY
15bc0df759 Add emoji reaction deletion api 2023-02-25 10:42:19 +09:00
KMY
092f9916b0 Add emoji_reactions property to status api object 2023-02-23 20:32:27 +09:00
Nick Schonning
9909b4b653
Autofix Rubocop Rails/WhereEquals (#23759) 2023-02-21 03:20:56 +09:00
Nick Schonning
717683d1c3
Autofix Rubocop remaining Layout rules (#23679) 2023-02-20 06:58:28 +01:00
Nick Schonning
63e6353886
Autofix Rubocop Rails/EnumHash (#23737) 2023-02-20 05:00:36 +01:00
Nick Schonning
597767a9f7
Autofix Rubocop Rails/RedundantForeignKey (#23731) 2023-02-20 02:19:40 +01:00
Nick Schonning
2177daeae9
Autofix Rubocop Style/RedundantBegin (#23703) 2023-02-19 07:09:40 +09:00
Nick Schonning
ab7816a414
Autofix Rubocop Style/Lambda (#23696) 2023-02-18 12:39:00 +01:00
Claire
13a2abacc8
Add roles attribute to Account entities in REST API (#23255) 2023-01-25 19:55:40 +01:00
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.
2023-01-11 21:57:24 +01:00
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)
```
2022-11-27 20:41:18 +01:00