cfahlgren1 HF staff commited on
Commit
1fad8d8
1 Parent(s): e8b3124

simplify query, add port

Browse files
Files changed (3) hide show
  1. Dockerfile +0 -1
  2. README.md +1 -0
  3. src/pages/index.tsx +9 -13
Dockerfile CHANGED
@@ -46,5 +46,4 @@ EXPOSE 3000
46
 
47
  ENV PORT 3000
48
  ENV HOSTNAME 0.0.0.0
49
-
50
  CMD ["bun", "run", "server.js"]
 
46
 
47
  ENV PORT 3000
48
  ENV HOSTNAME 0.0.0.0
 
49
  CMD ["bun", "run", "server.js"]
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: pink
5
  colorTo: pink
6
  sdk: docker
7
  pinned: false
 
8
  license: apache-2.0
9
  ---
10
 
 
5
  colorTo: pink
6
  sdk: docker
7
  pinned: false
8
+ app_port: 3000
9
  license: apache-2.0
10
  ---
11
 
src/pages/index.tsx CHANGED
@@ -34,21 +34,17 @@ export default function Home() {
34
  SELECT
35
  STRFTIME(DATE_TRUNC('day', CAST(createdAt AS DATE)), '%Y-%m-%d') AS date,
36
  CASE
37
- WHEN SPLIT_PART(id, '/', 1) IN ('meta-llama', 'facebook') THEN 'meta-llama'
38
- ELSE SPLIT_PART(id, '/', 1)
39
  END AS provider,
40
  COUNT(*) AS count
41
- FROM models
42
- WHERE CAST(createdAt AS DATE) >= DATE_TRUNC('year', CURRENT_DATE)
43
- AND (
44
- SPLIT_PART(id, '/', 1) IN (${Object.keys(PROVIDERS_MAP).map(provider => `'${provider}'`).join(', ')})
45
- OR SPLIT_PART(id, '/', 1) = 'facebook'
46
- )
47
- GROUP BY DATE_TRUNC('day', CAST(createdAt AS DATE)),
48
- CASE
49
- WHEN SPLIT_PART(id, '/', 1) IN ('meta-llama', 'facebook') THEN 'meta-llama'
50
- ELSE SPLIT_PART(id, '/', 1)
51
- END
52
  ORDER BY date
53
  `);
54
  return result.toArray().map((row: any) => ({
 
34
  SELECT
35
  STRFTIME(DATE_TRUNC('day', CAST(createdAt AS DATE)), '%Y-%m-%d') AS date,
36
  CASE
37
+ WHEN provider IN ('meta-llama', 'facebook') THEN 'meta-llama'
38
+ ELSE provider
39
  END AS provider,
40
  COUNT(*) AS count
41
+ FROM (
42
+ SELECT *, SPLIT_PART(id, '/', 1) AS provider
43
+ FROM models
44
+ WHERE CAST(createdAt AS DATE) >= DATE_TRUNC('year', CURRENT_DATE)
45
+ ) subquery
46
+ WHERE provider IN (${Object.keys(PROVIDERS_MAP).map(p => `'${p}'`).join(', ')}, 'facebook')
47
+ GROUP BY 1, 2
 
 
 
 
48
  ORDER BY date
49
  `);
50
  return result.toArray().map((row: any) => ({