1
1
import Grid from "@/components/Grid" ;
2
2
import Header from "@/components/Header" ;
3
3
import { db } from "@/lib/db/connection" ;
4
+ import fetchDomainsByTechnology from "@/lib/db/domains-by-technology" ;
4
5
import { GENRE_REGISTRY , REGISTRY } from "@/lib/services" ;
5
6
import * as Dialog from "@radix-ui/react-dialog" ;
6
7
7
- const PAGE_SIZE = 101 ;
8
-
9
8
const SHOVEL_PRO_URL = process . env . SHOVEL_PRO_URL ;
10
9
10
+ const PAGE_SIZE = 100 ;
11
+
11
12
import { Metadata , ResolvingMetadata } from "next" ;
12
13
13
14
type Props = {
@@ -35,27 +36,7 @@ export default async function TechnologyPage({
35
36
params : { identifier : string } ;
36
37
} ) {
37
38
const service = REGISTRY [ params . identifier ] ;
38
- const data = process . env . DISABLE_DATABASE
39
- ? { data : [ ] , moreCount : 0 }
40
- : await db
41
- . selectFrom ( "detected_technologies" )
42
- . where ( "technology" , "=" , params . identifier )
43
- . selectAll ( )
44
- . distinctOn ( "domain" )
45
- . execute ( )
46
- . then ( ( results ) => {
47
- if ( results . length > PAGE_SIZE ) {
48
- const moreCount = results . length - PAGE_SIZE ;
49
- return {
50
- data : results . slice ( 0 , PAGE_SIZE ) ,
51
- moreCount,
52
- } ;
53
- }
54
- return {
55
- data : results ,
56
- moreCount : 0 ,
57
- } ;
58
- } ) ;
39
+ const data = await fetchDomainsByTechnology ( params . identifier , PAGE_SIZE ) ;
59
40
60
41
const technologyCounts = process . env . DISABLE_DATABASE
61
42
? [ ]
@@ -118,10 +99,10 @@ export default async function TechnologyPage({
118
99
{ trancoCount > 0
119
100
? (
120
101
( trancoCount * 100 ) /
121
- ( data . data . length + data . moreCount )
102
+ ( data . count )
122
103
) . toFixed ( 2 )
123
104
: "0.00" }
124
- %) / { data . data . length + data . moreCount } total domains
105
+ %) / { data . count } total domains
125
106
</ div >
126
107
</ div >
127
108
</ >
@@ -139,14 +120,14 @@ export default async function TechnologyPage({
139
120
< div className = "text-xs" > { item . domain } </ div >
140
121
</ Grid . Item >
141
122
) ) }
142
- { data . moreCount > 0 && (
123
+ { data . count > PAGE_SIZE && (
143
124
< Grid . Item >
144
125
< div className = "text-xs opacity-50" >
145
126
{ /* Note: This component should be moved to a client-side component */ }
146
127
< Dialog . Root >
147
128
< Dialog . Trigger asChild >
148
129
< button className = "hover:underline focus:outline-none" >
149
- + { data . moreCount } more
130
+ + { data . count - PAGE_SIZE } more
150
131
</ button >
151
132
</ Dialog . Trigger >
152
133
< Dialog . Portal >
@@ -191,7 +172,7 @@ export default async function TechnologyPage({
191
172
{ item . count } (
192
173
{ (
193
174
( Number ( item . count ) * 100 ) /
194
- ( data . data . length + data . moreCount )
175
+ ( data . count )
195
176
) . toFixed ( 2 ) }
196
177
%)
197
178
</ div >
0 commit comments