Skip to content

Commit 020e1ad

Browse files
committed
docs: add user stats commands
1 parent b25a1a1 commit 020e1ad

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

backend/docs/useful_queries.md

+27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
# Useful dabase queries
22

33
## Remove duplicate articles (sqlite)
4+
45
```sql
56
DELETE FROM article WHERE rowid not in (select min(rowid) from article group by url);
67
```
8+
9+
## Get all read article titles from a user
10+
11+
```sql
12+
select title from article join userarticlelink on article.id = userarticlelink.article_id join user on userarticlelink.user_id = user.id where user.id = 'USERID';
13+
```
14+
15+
## User stats including how many days they have been active
16+
17+
```sql
18+
select id, created_at, last_request, Cast ((
19+
JulianDay(last_request) - JulianDay(created_at)
20+
) As Integer) from user order by last_request ;
21+
```
22+
23+
## Get all feeds for a user
24+
25+
```sql
26+
select title, url from feed join userfeedlink on feed.id = userfeedlink.feed_id join user on userfeedlink.user_id = user.id where user.id = 'USERID';
27+
```
28+
29+
## Get all read articles for a user
30+
31+
```sql
32+
select title, url from article join userarticlelink on article.id = userarticlelink.article_id join user on userarticlelink.user_id = user.id where user.id = 'USERID';
33+
```

0 commit comments

Comments
 (0)