Skip to content

Commit

Permalink
feat(scripts): update sample_datasets fetch url (#4364)
Browse files Browse the repository at this point in the history
Co-authored-by: shortcuts <[email protected]>
  • Loading branch information
LorrisSaintGenez and shortcuts authored Jan 23, 2025
1 parent 0e98f08 commit 62257d3
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion templates/csharp/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SaveObjectsMovies
public static async Task Main(string[] args)
{
// read json file from url
var url = "https://dashboard.algolia.com/sample_datasets/movie.json";
var url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie";
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(url);
var content = await response.Content.ReadAsStringAsync();
Expand Down
2 changes: 1 addition & 1 deletion templates/dart/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main() async {

// read json file from url
final datasetRequest = await http.get(
Uri.parse('https://dashboard.algolia.com/sample_datasets/movie.json'));
Uri.parse('https://dashboard.algolia.com/api/1/sample_datasets?type=movie'));

if (datasetRequest.statusCode == 200) {
final moviesData = jsonDecode(datasetRequest.body);
Expand Down
2 changes: 1 addition & 1 deletion templates/go/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func saveObjectsMovies() {
// read json file
url := "https://dashboard.algolia.com/sample_datasets/movie.json"
url := "https://dashboard.algolia.com/api/1/sample_datasets?type=movie"
response, err := http.Get(url)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion templates/java/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class saveObjectsMovies {
public static void main(String[] args) throws Exception {
// Fetch sample dataset
URL url = new URI("https://dashboard.algolia.com/sample_datasets/movie.json").toURL();
URL url = new URI("https://dashboard.algolia.com/api/1/sample_datasets?type=movie").toURL();
InputStream stream = url.openStream();
ObjectMapper mapper = new ObjectMapper();
List<JsonNode> movies = mapper.readValue(stream, new TypeReference<List<JsonNode>>() {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Fetch and index objects in Algolia
const processRecords = async () => {
const datasetRequest = await fetch('https://dashboard.algolia.com/sample_datasets/movie.json');
const datasetRequest = await fetch('https://dashboard.algolia.com/api/1/sample_datasets?type=movie');
const movies = await datasetRequest.json();
return {{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}}
};
Expand Down
2 changes: 1 addition & 1 deletion templates/kotlin/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.serialization.json.JsonObject
import java.net.URI

suspend fun main() {
val url = URI.create("https://dashboard.algolia.com/sample_datasets/movie.json")
val url = URI.create("https://dashboard.algolia.com/api/1/sample_datasets?type=movie")
val json = url.toURL().readText()
val movies: List<JsonObject> = Json.decodeFromString(ListSerializer(JsonObject.serializer()), json)
Expand Down
2 changes: 1 addition & 1 deletion templates/php/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require(__DIR__."/vendor/autoload.php");
{{> snippets/import}}

// Fetch sample dataset
$url = "https://dashboard.algolia.com/sample_datasets/movie.json";
$url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie";
$response = file_get_contents($url);
$movies = json_decode($response, true);

Expand Down
2 changes: 1 addition & 1 deletion templates/python/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import requests

async def main():
# Fetch sample dataset
url = "https://dashboard.algolia.com/sample_datasets/movie.json"
url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie"
movies = requests.get(url).json()

# Connect and authenticate with your Algolia app
Expand Down
2 changes: 1 addition & 1 deletion templates/ruby/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require 'uri'
{{> snippets/import}}

# Fetch sample dataset
uri = URI('https://dashboard.algolia.com/sample_datasets/movie.json')
uri = URI('https://dashboard.algolia.com/api/1/sample_datasets?type=movie')
response = Net::HTTP.get_response(uri)
movies = JSON.parse(response.body)

Expand Down
2 changes: 1 addition & 1 deletion templates/scala/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Main {
implicit val formats: org.json4s.Formats = org.json4s.DefaultFormats
// Fetch sample dataset
val url = "https://dashboard.algolia.com/sample_datasets/movie.json"
val url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie"
val result = Source.fromURL(url).mkString
val movies = JsonMethods.parse(result).extract[Seq[Map[String, Any]]]
Expand Down
2 changes: 1 addition & 1 deletion templates/swift/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Core
{{> snippets/import}}

func saveObjectsMovies() async throws {
let url = URL(string: "https://dashboard.algolia.com/sample_datasets/movie.json")!
let url = URL(string: "https://dashboard.algolia.com/api/1/sample_datasets?type=movie")!
var data: Data? = nil
#if os(Linux) // For linux interop
(data, _) = try await URLSession.shared.asyncData(for: URLRequest(url: url))
Expand Down

0 comments on commit 62257d3

Please sign in to comment.