- Make it a Server method.
- Pass Server instead of App.
- Remove global app instance from NewServer, rather
create local instances whenever needed.
- Remove App from Websocket router, and create dynamically
on every request.
- Remove HubStart and HubStop from App methods.
- Explicitly using s.Log instead of the global logger
to indicate dependency on Server. We could have passed the logger
explicitly but it doesn't look ideal.
```release-note
NONE
```
* MM-36862: should remove user from participants
When deleting a reply in a thread we should also delete the participant
from the participants array. This should happen if they have no other
replies in that thread.
This commit fixes that.
* Adds warning logs
* Delete Post: fetches participants only when needed
* Minor refactor
* Remove participant should check for error in count
* Fixes error when binary_parameters=true
* Fixes: removes ArrayToJSON so we can handle the error
* Satisfies the linter
* Better error handling
* Satisfy govet
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Improve API4 initialization
- Refactored openGraphDataCache to be inside app layer.
- Moved the cache instance from global variable to be inside server.
- Moved out the app instantiation from the global commands package
to be instantiated on every call. Only the server instance is passed.
- Moved InitLocal to be called from inside Init.
```release-note
NONE
```
* Remove commented line
```release-note
NONE
```
* Remove outdated translations
* update go-i18n dependency
* reflect review comments
* add message count for languages which has two translations for plurals
* Add functionality to cleanup old jobs
Historically, we never cleaned up old jobs from the DB
leading to them being accumulated forever.
This PR introduces functionality to cleanup old jobs
older than a defined threshold.
The functionality is set to false by default and has
to be enabled for it to work.
```release-note
2 new config settings were added.
JobSettings.CleanupOldJobs: This indicates whether to clean up old jobs
from the DB or not. Default is false.
JobSettings.CleanupJobsThresholdHours: This defines the time gap in hours beyond
which older jobs will be removed. This has no effect if the above config
setting is set to false. Default is -1
```
* fix copy pasta
```release-note
NONE
```
* address review comments
```release-note
NONE
```
* Fix lint
```release-note
NONE
```
* Use single config option for everything
```release-note
NONE
```
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* MM-36743: adds last_root_post_at in channels table
Channel recency for CRT users should not count replies,
this commit solves that issue by adding a new column to the channels
table: LastRootPostAt.
With that new info CRT users can have recent channels to work as
expected.
* Adds the 'LastRootPostAt' to the SQL scripts
* Fixes tests
* Adds LastRootPostAt migration to v6.1
* Fixes index
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Allow Embeds editing without editing
* Add focalboard to embed after it being in props
* Fix tests
* change to boards
* remove extra gunk
* Fix tests
* Add Feature Flag
* update boardsunfurl
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Move Channels into App
In this PR, we make Channels as part of App
instead of Server. This is part of the transition period
of moving fields from Server to Channels.
For now, Channels contains Server. So the hierarchy is
App -> Channels -> Server.
And as a first step, we also move httpService to Channels.
```release-note
NONE
```
* Fixing another test
```release-note
NONE
```
* new method
```release-note
NONE
```
* Creating empty Channels shell
This is the first step in moving to a product-based
isolated architecture.
For now, Channels is empty and does not contain anything.
Next step is to change App to contain Channels instead
of Server. Some of the initialization code in NewServer
would need to be moved inside NewChannels.
This would complete the full pass-through mode of accessing
everything.
The last step would be to gradually move Channels related
fields from Server into Channels, keeping Server to be
just the global level struct.
```release-note
NONE
```
* fix vet failure
```release-note
NONE
```
* Change internal getProducts to filter on a set of families instead of a single family.
* Extend /products endpoint to be able to return any of the current four sets of product families.
* Use include_legacy query param to decide which cloud products to request.
From Grafana charts, GetCountbyStatusandType and
GetNewestJobByStatusesAndType were the two top queries.
Overall, a through look into all job methods leads to
the conclusion of 2 indexes - one on CreateAt, another
a compound index of Status+Type. I have just gone ahead
with the compound index for now. Once the job cleaner
is implemented, I want to take a second look to decide
whether to add the second index or not.
Here is the before-after of the queries:
Query 1:
```
explain analyze select count(*) from jobs where status='error' and type='migrations';
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=103.42..103.43 rows=1 width=8) (actual time=0.032..0.034 rows=1 loops=1)
-> Bitmap Heap Scan on jobs (cost=4.54..103.42 rows=1 width=0) (actual time=0.027..0.028 rows=0 loops=1)
Recheck Cond: ((type)::text = 'migrations'::text)
Filter: ((status)::text = 'error'::text)
-> Bitmap Index Scan on idx_jobs_type (cost=0.00..4.54 rows=34 width=0) (actual time=0.018..0.019 rows=0 loops=1)
Index Cond: ((type)::text = 'migrations'::text)
explain analyze select count(*) from jobs where status='error' and type='migrations';
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=8.31..8.32 rows=1 width=8) (actual time=0.079..0.080 rows=1 loops=1)
-> Index Only Scan using jobs_multi on jobs (cost=0.29..8.30 rows=1 width=0) (actual time=0.072..0.073 rows=0 loops=1)
Index Cond: ((status = 'error'::text) AND (type = 'migrations'::text))
Heap Fetches: 0
explain analyze select * from jobs where status='error' and type='migrations' order by createat desc limit 1;
```
Query 2:
```
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------
Limit (cost=8.31..8.32 rows=1 width=187) (actual time=0.037..0.039 rows=0 loops=1)
-> Sort (cost=8.31..8.32 rows=1 width=187) (actual time=0.035..0.036 rows=0 loops=1)
Sort Key: createat DESC
Sort Method: quicksort Memory: 25kB
-> Index Scan using idx_jobs_type on jobs (cost=0.29..8.30 rows=1 width=187) (actual time=0.027..0.027 rows=0 loops=1)
Index Cond: ((type)::text = 'migrations'::text)
Filter: ((status)::text = 'error'::text)
explain analyze select * from jobs where status='error' and type='migrations' order by createat desc limit 1;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
Limit (cost=8.31..8.32 rows=1 width=187) (actual time=0.065..0.067 rows=0 loops=1)
-> Sort (cost=8.31..8.32 rows=1 width=187) (actual time=0.063..0.064 rows=0 loops=1)
Sort Key: createat DESC
Sort Method: quicksort Memory: 25kB
-> Index Scan using jobs_multi on jobs (cost=0.29..8.30 rows=1 width=187) (actual time=0.021..0.022 rows=0 loops=1)
Index Cond: (((status)::text = 'error'::text) AND ((type)::text = 'migrations'::text))
```
```release-note
NONE
```
* Migrate from gorp to sqlx in store/sqlstore/command_webhook_store.go
* fixing small things
change `CreatedAt` to `CreateAt` and change GetReplicaX().Select to GetReplicaX().Get
Co-authored-by: Saul Pinales <saul021002@gmai.com>