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

update routes

Browse files
src/routes/api/models/+server.ts CHANGED
@@ -77,9 +77,8 @@ export async function PATCH({ request } : RequestEvent) {
77
  });
78
 
79
  let total_updates = 0;
80
-
81
  for (const model of models) {
82
- const hugging_face_request = await fetch(`https://huggingface.co/api/models/${model.id}`)
83
  const hugging_face_model = await hugging_face_request.json()?.catch(() => {})
84
 
85
  if (!hugging_face_model) {
@@ -92,7 +91,8 @@ export async function PATCH({ request } : RequestEvent) {
92
  data: {
93
  likes: hugging_face_model.likes,
94
  downloads: hugging_face_model.downloads,
95
- likes7d: hugging_face_model.likes7d,
 
96
  }
97
  })
98
  .then(() => {
 
77
  });
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) {
 
91
  data: {
92
  likes: hugging_face_model.likes,
93
  downloads: hugging_face_model.downloads,
94
+ likes7d: hugging_face_model.trendingScore,
95
+ id: hugging_face_model.id,
96
  }
97
  })
98
  .then(() => {
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/${model.id}`)
93
  const new_model = await hf_model.json();
94
  const update_data = {
95
  instance_prompt: model.instance_prompt,
@@ -116,6 +116,8 @@ export async function PATCH({ request, params } : RequestEvent) {
116
  ...update_data,
117
  likes: new_model.likes,
118
  downloads: new_model.downloads,
 
 
119
  }
120
  })
121
  }
 
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,
 
116
  ...update_data,
117
  likes: new_model.likes,
118
  downloads: new_model.downloads,
119
+ likes7d: new_model.trendingScore,
120
+ id: new_model.id,
121
  }
122
  })
123
  }