- Notifications
You must be signed in to change notification settings - Fork927
Commit6287502
authored
fix: delete workspace agent stats after 180 days (#14489)
Fixes#13430.The test for purging old workspace agent stats from the DB was consistently failing when ran with Postgres towards the end of the month, but not with the in-memory DB. This was because month intervals are calculated differently for `time.Time` and the `interval` type in Postgres:```ethan=# SELECT '2024-08-30'::DATE AS original_date, ('2024-08-30'::DATE - INTERVAL '6 months') AS sub_date; original_date | sub_date---------------+--------------------- 2024-08-30 | 2024-02-29 00:00:00(1 row)```Using `func (t Time) AddDate(years int, months int, days int) Time`, where `months` is `-6`:```Original: 2024-08-30 00:00:00 +0000 UTC6 Months Earlier: 2024-03-01 00:00:00 +0000 UTC```Since 6 months was chosen arbitrarily, we should be able to change it to 180 days, to remove any ambiguity between the in-memory DB, and the Postgres DB. The alternative solution would involve implementing Postgres' month interval algorithm in Go.The UI only shows stats as old as 168 days (24 weeks), so a frontend change isn't required for the extra days of stats we lose in some cases.1 parent4672849 commit6287502
File tree
4 files changed
+17
-17
lines changed- coderd/database
- dbmem
- dbpurge
- queries
4 files changed
+17
-17
lines changedLines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1749 | 1749 |
| |
1750 | 1750 |
| |
1751 | 1751 |
| |
1752 |
| - | |
| 1752 | + | |
1753 | 1753 |
| |
1754 | 1754 |
| |
1755 |
| - | |
| 1755 | + | |
1756 | 1756 |
| |
1757 | 1757 |
| |
1758 | 1758 |
| |
| |||
1778 | 1778 |
| |
1779 | 1779 |
| |
1780 | 1780 |
| |
1781 |
| - | |
| 1781 | + | |
1782 | 1782 |
| |
1783 | 1783 |
| |
1784 | 1784 |
| |
|
Lines changed: 10 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
86 | 86 |
| |
87 | 87 |
| |
88 | 88 |
| |
89 |
| - | |
| 89 | + | |
90 | 90 |
| |
91 |
| - | |
| 91 | + | |
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
96 | 96 |
| |
97 | 97 |
| |
98 |
| - | |
| 98 | + | |
99 | 99 |
| |
100 |
| - | |
| 100 | + | |
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
107 |
| - | |
| 107 | + | |
108 | 108 |
| |
109 |
| - | |
| 109 | + | |
110 | 110 |
| |
111 | 111 |
| |
112 | 112 |
| |
| |||
121 | 121 |
| |
122 | 122 |
| |
123 | 123 |
| |
124 |
| - | |
125 |
| - | |
| 124 | + | |
| 125 | + | |
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
| |||
144 | 144 |
| |
145 | 145 |
| |
146 | 146 |
| |
147 |
| - | |
148 |
| - | |
| 147 | + | |
| 148 | + | |
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
|
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
81 |
| - | |
| 81 | + | |
82 | 82 |
| |
83 | 83 |
| |
84 |
| - | |
| 84 | + | |
85 | 85 |
| |
86 | 86 |
| |
87 | 87 |
| |
|
0 commit comments
Comments
(0)