enzostvs HF staff commited on
Commit
58dc3d3
β€’
1 Parent(s): 9b95710

update trending score

Browse files
src/routes/api/models/+server.ts CHANGED
@@ -78,7 +78,7 @@ export async function PATCH({ request } : RequestEvent) {
78
 
79
  let total_updates = 0;
80
  for (const model of models) {
81
- const hugging_face_request = await fetch(`https://huggingface.co/api/models?id=${model.id}`)
82
  const hugging_face_model = await hugging_face_request.json()?.catch(() => {})
83
 
84
  if (!hugging_face_model) {
 
78
 
79
  let total_updates = 0;
80
  for (const model of models) {
81
+ const hugging_face_request = await fetch(`https://huggingface.co/api/models?id=${model.id}&sort=likes7d`)
82
  const hugging_face_model = await hugging_face_request.json()?.catch(() => {})
83
 
84
  if (!hugging_face_model) {
src/routes/api/models/[id]/+server.ts CHANGED
@@ -124,7 +124,7 @@ export async function POST({ params, cookies, fetch } : RequestEvent) {
124
  }, { status: 404 })
125
  }
126
 
127
- const data = await fetch(`https://huggingface.co/api/models/${model.id}`)
128
  const hf_model = await data.json()
129
 
130
  await prisma.model.update({
@@ -133,6 +133,10 @@ export async function POST({ params, cookies, fetch } : RequestEvent) {
133
  },
134
  data: {
135
  isPublic: true,
 
 
 
 
136
  instance_prompt: hf_model?.cardData?.instance_prompt
137
  }
138
  })
 
124
  }, { status: 404 })
125
  }
126
 
127
+ const data = await fetch(`https://huggingface.co/api/models?id=${model.id}&sort=likes7d`)
128
  const hf_model = await data.json()
129
 
130
  await prisma.model.update({
 
133
  },
134
  data: {
135
  isPublic: true,
136
+ likes: hf_model?.likes,
137
+ downloads: hf_model?.downloads,
138
+ likes7d: hf_model?.trendingScore,
139
+ id: hf_model?.id,
140
  instance_prompt: hf_model?.cardData?.instance_prompt
141
  }
142
  })
src/routes/api/models/submit/+server.ts CHANGED
@@ -27,7 +27,7 @@ export async function POST({ request, fetch, cookies }) {
27
  }
28
 
29
  // get model on hugging face
30
- const res = await fetch(`https://huggingface.co/api/models/${model.id}`)
31
  const data = await res.json();
32
 
33
  if (data?.error) {
@@ -58,6 +58,7 @@ export async function POST({ request, fetch, cookies }) {
58
  image: model.image,
59
  likes: data.likes,
60
  downloads: data.downloads,
 
61
  isPublic: false,
62
  }
63
  })
 
27
  }
28
 
29
  // get model on hugging face
30
+ const res = await fetch(`https://huggingface.co/api/models?id=${model.id}&sort=likes7d`)
31
  const data = await res.json();
32
 
33
  if (data?.error) {
 
58
  image: model.image,
59
  likes: data.likes,
60
  downloads: data.downloads,
61
+ likes7d: data.trendingScore,
62
  isPublic: false,
63
  }
64
  })
src/routes/api/scrap-models/[slug]/+server.ts CHANGED
@@ -89,7 +89,7 @@ export async function PATCH({ request, params } : RequestEvent) {
89
  })
90
 
91
  for (const model of models) {
92
- const hf_model = await fetch(`https://huggingface.co/api/models?id=${model.id}`)
93
  const new_model = await hf_model.json();
94
  const update_data = {
95
  instance_prompt: model.instance_prompt,
 
89
  })
90
 
91
  for (const model of models) {
92
+ const hf_model = await fetch(`https://huggingface.co/api/models?id=${model.id}&sort=likes7d`)
93
  const new_model = await hf_model.json();
94
  const update_data = {
95
  instance_prompt: model.instance_prompt,