How to get the spotify id of a specific song with echonest api - api

I am trying to query echonest with both an Artist name and Song name and have it return the spotify ID of the song. Currently I can only get the artist to be returned.
I am reading the documentation but it makes no sense at all I think it might be out dated and was wondering if someone could help me.
Here is the link to the doc I am using (http://developer.echonest.com/sandbox/spotify.html) the API example is the 2nd from the last which is:
http://developer.echonest.com/api/v4/song/search?api_key=FILDTEOIK2HBORODV&format=json&results=1&artist=radiohead&title=karma%20police&bucket=id:spotify&bucket=tracks&limit=true
Artists: Radiohead
Song title: Karma Police
What is returned as the example in the document is
songs: [
{
title: "Karma Police"
artist_name: "Radiohead"
id: "SOHJOLH12A6310DFE5"
tracks: [
{
"catalog": "spotify",
"foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl",
"id": "TRAVAWH13386461C1A"
}
]
}
]
And I am trying to get the spotify:track:NUMBER_HERE
But when I actually run the api in my browser I get something totally different.
I get
{"response": {"status": {"version": "4.2", "code": 0, "message": "Success"}, "songs": [{"title": "Karma Police", "artist_name": "Radiohead", "artist_foreign_ids": [{"catalog": "spotify", "foreign_id": "spotify:artist:4Z8W4fKeB5YxbusRsdQVPb"}], "tracks": [{"album_type": "album", "album_date": "1997-07", "foreign_release_id": "spotify:album:4ofIyjnuLMspKVVEM5k7KA", "catalog": "spotify", "foreign_id": "spotify:track:0CheWtm72bDFyuqxxJm7Jl", "album_name": "Karma Police", "id": "TRMKRIH144D09912F7"}, {"album_type": "album", "album_date": "1997-07", "foreign_release_id": "spotify:album:3Y0KfwfHGnuuSqVQAxODb9", "catalog": "spotify", "foreign_id": "spotify:track:4MBMrG8UypQfADJTg3cfPl", "album_name": "Karma Police", "id": "TRTEKIH144D14B88AB"}, {"album_type": "unknown", "album_date": "1997-05-21", "foreign_release_id": "spotify:album:2fGCAYUMssLKiUAoNdxGLx", "catalog": "spotify", "foreign_id": "spotify:track:4toSP60xmDNCFuXly8ywNZ", "album_name": "OK Computer", "id": "TREZAIC144D16517CA"}, {"album_type": "other", "album_date": "1999-02-16", "foreign_release_id": "spotify:album:2xYrPRSUPI1Q33xbyFhEN2", "catalog": "spotify", "foreign_id": "spotify:track:5YtKNQRPr4WE4EW1q2KJ8y", "album_name": "Ka-Boom: 16 Rippin' Tunes!", "id": "TRJIACH144D1845ABD"}, {"album_type": "other", "album_date": "2006", "foreign_release_id": "spotify:album:2ravCeM1o3ZoDZkMbRA2Df", "catalog": "spotify", "foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl", "album_name": "Essential Bands", "id": "TRGUGNY144D11B4378"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:1ouYZxiEjRSlUdoldMJyNF", "catalog": "spotify", "foreign_id": "spotify:track:4NGagGvZxVZ1ox7NsOSMDU", "album_name": "The Best Of", "id": "TRITWZK144D147AB62"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:58ukFMtQgwjVD9vMlfnSi9", "catalog": "spotify", "foreign_id": "spotify:track:116R91XyWtWQUHw1VZD3pu", "album_name": "The Best Of", "id": "TRQZPLJ144D0B965CE"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:3hWomTJKGucGKv6EPpiHK9", "catalog": "spotify", "foreign_id": "spotify:track:36OTdTMwBC0SQvc0TMxqgf", "album_name": "The Best Of", "id": "TRMJVDN144D114268C"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:0YbEgKS7zN6HkDW8bATFn3", "catalog": "spotify", "foreign_id": "spotify:track:3FWvP216t2YLltarju8fIt", "album_name": "The Best Of", "id": "TRVHZKK144D1175CDB"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:30bTqpK0cUWDD4VxHVjv0f", "catalog": "spotify", "foreign_id": "spotify:track:57GM3IdxqmCX15rGBw7C0Q", "album_name": "The Best Of", "id": "TRUBASC144D1704E37"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:4ZbRrwQyYPoYLg689BLOdG", "catalog": "spotify", "foreign_id": "spotify:track:7afVhhphp8iwwb5c6zDD4M", "album_name": "The Best Of", "id": "TRHDXVW144D1D82BF6"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:40i2i4LZN75liVKAjbMKP5", "catalog": "spotify", "foreign_id": "spotify:track:4rl2PAW1pb9uvn5BrjCUPd", "album_name": "The Best Of", "id": "TRCOWWN144D1635B08"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:1WsOWlFxZ3u7bW2GigFhoS", "catalog": "spotify", "foreign_id": "spotify:track:0REhU4YzXin94yj5VIhfXR", "album_name": "The Best Of", "id": "TRVGGHY144D0A2A56F"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:4wciNwfgbL74SJG9BFlf2R", "catalog": "spotify", "foreign_id": "spotify:track:0hCW6LbmFCYwM1uGmnjjNe", "album_name": "The Best Of", "id": "TRFHBAP144D0AC7509"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:5lEQ9RF9W2jBIKT369b6XA", "catalog": "spotify", "foreign_id": "spotify:track:0w13hCzWc9x2ODo0lhW3AT", "album_name": "The Best Of", "id": "TRIJWLD144D0B70EB1"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:0kiElBKf2UH2AL51cSnjFs", "catalog": "spotify", "foreign_id": "spotify:track:7jglhg35UU1rHKo3TMMlhs", "album_name": "The Best Of", "id": "TRDAANY144D1DDC1B0"}, {"album_type": "other", "album_date": "2009-11-16", "foreign_release_id": "spotify:album:2ARSMRIAl1RrPIYODKpSvn", "catalog": "spotify", "foreign_id": "spotify:track:7IGdoYPZjwkFZObVrnhQwB", "album_name": "101 Indie Classics", "id": "TRATJQY144D1D34F86"}, {"album_type": "other", "foreign_release_id": "spotify:album:4VaGdGXKBYsDSOZpZb33YH", "catalog": "spotify", "foreign_id": "spotify:track:4TDPAhRJvIIxC2iOj3tfnJ", "album_name": "Personal Effects", "id": "TRODNEI144D15055F1"}, {"album_type": "other", "foreign_release_id": "spotify:album:3JVhCJ0KrRNNyqAbDtuUlR", "catalog": "spotify", "foreign_id": "spotify:track:7bm4xECd4E5BagR8tzshXR", "album_name": "L'album pop rock 1980-1999, Volume 2", "id": "TRIAUMZ144D1CE6B92"}, {"foreign_release_id": "spotify:album:37bbqRNY7TYPMVchZAkant", "catalog": "spotify", "foreign_id": "spotify:track:1H9Fdn0ufWXoaOZhaA3XhW", "id": "TRUOSTZ144D0C565DA"}, {"foreign_release_id": "spotify:album:2QlyISc2f7wPcwdggl8k6x", "catalog": "spotify", "foreign_id": "spotify:track:1Y6Nw0Xfh2hCBpu27F0Xce", "id": "TRLULHG144D0D0E0A8"}, {"foreign_release_id": "spotify:album:7vHLtDbWD2N2PUdWorYvL6", "catalog": "spotify", "foreign_id": "spotify:track:31VtM8plvEaBKEkwmJ5iVx", "id": "TRSAUZY144D110B9F0"}, {"foreign_release_id": "spotify:album:5VHphzoQ5AmAUv1NTXTgeA", "catalog": "spotify", "foreign_id": "spotify:track:4722k1npcMc5e1kBiWWIYI", "id": "TRBVBET144D1423032"}, {"foreign_release_id": "spotify:album:2bKod32TblM1nReRDi9gTG", "catalog": "spotify", "foreign_id": "spotify:track:6MRtrRQVOwyk6cMZY3Smnl", "id": "TRSEEQW144D1A7817C"}, {"foreign_release_id": "spotify:album:1ssRgLbh4dOEpu57bImChh", "catalog": "spotify", "foreign_id": "spotify:track:01puceOqImrzSfKDAcd1Ia", "id": "TRBHSFP144D0923CC6"}, {"foreign_release_id": "spotify:album:1EAJOr9xA3rHzhS5rWpziG", "catalog": "spotify", "foreign_id": "spotify:track:2Mvy2Ob0m1MIaOwjieDSdD", "id": "TRWBMXG144D0F402E2"}, {"foreign_release_id": "spotify:album:5bNn3KPcrlgLmhRXj4d2EX", "catalog": "spotify", "foreign_id": "spotify:track:4BFAWLRycYNSbhUgZFijc9", "id": "TRSXGVY144D1438433"}, {"foreign_release_id": "spotify:album:4195NRmc5jxkCw9jcmd4rt", "catalog": "spotify", "foreign_id": "spotify:track:5MIblG9hLxBnQcrDwdWF98", "id": "TRBLQPB144D17B11CC"}, {"foreign_release_id": "spotify:album:6vjzhxwIgTtDVW34bteGyG", "catalog": "spotify", "foreign_id": "spotify:track:10u0TOqp3bd1DAPNskHvK8", "id": "TRPIDKB144D0BA6CBC"}, {"foreign_release_id": "spotify:album:6uhBsv0PbcwolrbhgCDqDR", "catalog": "spotify", "foreign_id": "spotify:track:6XPGNyB95TZwYiqe2t964T", "id": "TRGUQDL144D1B040D8"}, {"foreign_release_id": "spotify:album:45wvzRUVtoEPsXsiNtO2TX", "catalog": "spotify", "foreign_id": "spotify:track:3u7TUfV1fjAvxJtqvtUbGO", "id": "TRNPOOC147B6E30B68"}, {"foreign_release_id": "spotify:album:3Hl5wRTlE9vNuXdZ54okbn", "catalog": "spotify", "foreign_id": "spotify:track:1vDio38orbAGqrXAR13RD3", "id": "TRHKSFX144D0E0D5DC"}, {"foreign_release_id": "spotify:album:3fjD2coxF2SQwLRcjm0ctg", "catalog": "spotify", "foreign_id": "spotify:track:6IJW8YFpoJ5DQ0YiBITqfq", "id": "TRTHCOU144D1A55B13"}, {"foreign_release_id": "spotify:album:4VYcoe0QDAGJmZA5zpgvgq", "catalog": "spotify", "foreign_id": "spotify:track:6oeIc0gfmKLlYe5gkJ3cJP", "id": "TRDVZZZ144D1B59768"}, {"foreign_release_id": "spotify:album:7eQtS9KqZmqCGkbieox4fV", "catalog": "spotify", "foreign_id": "spotify:track:6ZGOmPtSvx1hxwjwqpdKQ7", "id": "TRIBYGA144D1A9AF3B"}, {"foreign_release_id": "spotify:album:6Bjl48Ev6V97G6Uc37IRTw", "catalog": "spotify", "foreign_id": "spotify:track:6eomr7dBfWTGdRHuPwJFU6", "id": "TROCBGU14735BF0753"}, {"foreign_release_id": "spotify:album:1AAI2vNGAwA7DhCmEyYAwU", "catalog": "spotify", "foreign_id": "spotify:track:2NBB9erm0zzcM6i41Nrbux", "id": "TRDMBVL144D0F3D96F"}], "artist_id": "ARH6W4X1187B99274F", "id": "SOHJOLH12A6310DFE5"}]}}
Can someone point me in the right direction as to what I am overlooking please.
Any help guidance and suggestions is appreciated. My end state is that I can get the spotify track id so I can build my own playlist programmaticly. If there is a better way I am open to suggestions

Looking at the response you've got from The Echo Nest's API, the track URI is located in
response.songs[0].tracks[0].foreign_id. So the documentation is correct, it's just that it didn't cover the response object that the songs array lives inside.
Hope this helps!

Related

All data from first table is not showing proper data in sql

I am trying to add two tables, in which first table contains all the video details, and in second table details of video seen by the user with user_id and video_id. I just want to add both the tables and it will show all the list of videos from first table but if the video is seen by the user, status will show 1 else 1.
Here is my query,
SELECT
videos.id, videos.lang_id, videos.medical_type_id, videos.name,
videos.description, videos.thumbnail, videos.video, videos.video_type,
videos.delete_status,
CASE
WHEN video_quews.user_id = $user_id
THEN $user_id
ELSE 'ok'
END AS user_id,
video_quews.video_id, video_quews.created_at,
CASE
WHEN video_quews.video_id = videos.id
THEN 1
ELSE 0
END AS status
FROM
videos
LEFT JOIN
video_quews ON videos.id = video_quews.video_id
ORDER BY
video_quews.video_id DESC
Currently, videos are repeating.
Please help me out
here is my response,
{
"message": "All related videos",
"status": "success",
"code": 200,
"videos": [
{
"id": "30",
"lang_id": "2",
"medical_type_id": "15",
"name": "Fracture",
"thumbnail": "thumbnail_images/1579869167.png",
"video": "videos/fracture.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "6",
"video_id": "30",
"created_at": "2021-03-04 23:29:50",
"status": "1"
},
{
"id": "16",
"lang_id": "2",
"medical_type_id": "14",
"name": "Electrocution",
"thumbnail": "thumbnail_images/1579698529.png",
"video": "videos/ELECTROCUTION.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "16",
"created_at": "2021-03-05 08:19:29",
"status": "1"
},
{
"id": "15",
"lang_id": "2",
"medical_type_id": "13",
"name": "Adult CPR & AED(Cardiac Arrest)",
"thumbnail": "thumbnail_images/1579698505.png",
"video": "videos/CPR1.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "15",
"created_at": "2021-03-05 08:18:38",
"status": "1"
},
{
"id": "14",
"lang_id": "2",
"medical_type_id": "12",
"name": "Choking",
"thumbnail": "thumbnail_images/1579698405.png",
"video": "videos/Choking.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "14",
"created_at": "2021-03-05 08:17:47",
"status": "1"
},
{
"id": "13",
"lang_id": "2",
"medical_type_id": "11",
"name": "Chest pain",
"thumbnail": "thumbnail_images/1579698381.png",
"video": "videos/CHESTPAIN.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "13",
"created_at": "2021-03-05 08:17:20",
"status": "1"
},
{
"id": "12",
"lang_id": "2",
"medical_type_id": "10",
"name": "Burns",
"thumbnail": "thumbnail_images/1579698360.png",
"video": "videos/Burns.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "12",
"created_at": "2021-03-05 08:16:39",
"status": "1"
},
{
"id": "11",
"lang_id": "2",
"medical_type_id": "9",
"name": "Breathing Difficulties",
"thumbnail": "thumbnail_images/1579698344.png",
"video": "videos/BreathingDifficulties.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "11",
"created_at": "2021-03-05 08:16:19",
"status": "1"
},
{
"id": "8",
"lang_id": "2",
"medical_type_id": "6",
"name": "Asthma",
"thumbnail": "thumbnail_images/1579698286.png",
"video": "videos/ASTHMA.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "8",
"created_at": "2021-03-05 08:15:59",
"status": "1"
},
{
"id": "24",
"lang_id": "2",
"medical_type_id": "22",
"name": "Fits/Seizures",
"thumbnail": "thumbnail_images/1579698775.png",
"video": "videos/SEIZURES.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "26",
"lang_id": "2",
"medical_type_id": "24",
"name": "Sprain, strain",
"thumbnail": "thumbnail_images/1579698853.png",
"video": "videos/SPRAIN&STRAIN.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "28",
"lang_id": "2",
"medical_type_id": "26",
"name": "Disposing Glove",
"thumbnail": "thumbnail_images/1579698903.png",
"video": "videos/disposingglove.mp4",
"video_type": "1",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "31",
"lang_id": "2",
"medical_type_id": "8",
"name": "Bleeding",
"thumbnail": "thumbnail_images/1581498917.png",
"video": "videos/bleeding.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "18",
"lang_id": "2",
"medical_type_id": "16",
"name": "Gunshot Wound",
"thumbnail": "thumbnail_images/1579698550.png",
"video": "videos/Gunshot.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "20",
"lang_id": "2",
"medical_type_id": "18",
"name": "Hypoglycemia",
"thumbnail": "thumbnail_images/1579698684.png",
"video": "videos/Hypoglycemia.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "22",
"lang_id": "2",
"medical_type_id": "20",
"name": "Nose Bleeding",
"thumbnail": "thumbnail_images/1579698728.png",
"video": "videos/nosebleeding.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "25",
"lang_id": "2",
"medical_type_id": "23",
"name": "Snake Bite",
"thumbnail": "thumbnail_images/1579698801.png",
"video": "videos/SnakeBite.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "27",
"lang_id": "2",
"medical_type_id": "25",
"name": "Stroke",
"thumbnail": "thumbnail_images/1579698879.png",
"video": "videos/STROKE.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "29",
"lang_id": "2",
"medical_type_id": "27",
"name": "Dog Bite",
"thumbnail": "thumbnail_images/1579698934.png",
"video": "videos/Dogbite.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "32",
"lang_id": "2",
"medical_type_id": "7",
"name": "Allergy",
"thumbnail": "thumbnail_images/1581580973.png",
"video": "videos/Allergy.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "19",
"lang_id": "2",
"medical_type_id": "17",
"name": "Hyperthermia(Heat Exhaustion)",
"thumbnail": "thumbnail_images/1579698575.png",
"video": "videos/Hyperthermia.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "21",
"lang_id": "2",
"medical_type_id": "19",
"name": "Introduction",
"thumbnail": "thumbnail_images/1579698707.png",
"video": "videos/intro.mp4",
"video_type": "1",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "23",
"lang_id": "2",
"medical_type_id": "21",
"name": "Recovery Position",
"thumbnail": "thumbnail_images/1579698747.png",
"video": "videos/RecoveryPosition.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
}
],
}
Below is my database,
enter image description here
I just want to add both the tables and it will show all the list of videos from first table but if the video is seen by the user, status will show 1 else 1.
I think you want a flag indicating if a user has seen a video. For this, I suggest EXISTS:
select v.*,
(case when exists (select 1
from video_quews vq
where v.id = vq.video_id and vq.user_id = $user_id
)
then 1 else 0
end) as has_user_flag
from videos v

CosmosDB GeoSpatial Points Invalid

I'm using Azure's cosmos DB, and testing via the sqlquery in the Azure portal. Some points in my collection are valid, some are not. I am unable to tell from the GeoJSON spec if I am missing requirements. All my points pass the geojsonlint test: https://geojsonlint.com/
What could be causing invalid points? The locations are setup the same as far as I can tell.
My Query:
SELECT *
FROM events1 e
WHERE ST_ISVALID(e.location)
Running the query returns that these are valid:
[
{
"id": "b4b49b65-dfad-40f3-943b-753553507d2c",
"name": "OG Olympics",
"location": {
"type": "Point",
"coordinates": [
41.900697426935544,
12.480266913771628
]
},
"events": "Hockey",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Senior",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoHAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoHAAAAAAAAAA==/",
"_etag": "\"11003fb9-0000-0700-0000-5f2f15cf0000\"",
"_attachments": "attachments/",
"_ts": 1596921295
},
{
"id": "f2d063e3-5654-475d-8e97-7412dc77fcfb",
"name": "Test Event DenverCC",
"location": {
"type": "Point",
"coordinates": [
100.2093,
-15.868
]
},
"events": "Basketball",
"time": "18:00:00",
"recurring": null,
"date": null,
"difficulty": "Intermediate",
"ages": "Senior",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoJAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoJAAAAAAAAAA==/",
"_etag": "\"1300a79d-0000-0700-0000-5f304fc80000\"",
"_attachments": "attachments/",
"_ts": 1597001672
},
{
"id": "10000",
"name": "OG Olympics 2",
"location": {
"type": "Point",
"coordinates": [
41.000697426935545,
-12.080266913771627
]
},
"events": "Hockey",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Senior",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoKAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoKAAAAAAAAAA==/",
"_etag": "\"13003499-0000-0700-0000-5f304d580000\"",
"_attachments": "attachments/",
"_ts": 1597001048
}
]
But it returns that these are invalid:
{
"id": "1000",
"name": "Sunday Morning Hockey",
"location": {
"type": "Point",
"coordinates": [
39,
-105
]
},
"events": "hockey",
"time": "09:00",
"recurring": "true",
"date": "2020-08-02",
"difficulty": "all levels",
"ages": "all ages",
"admin": "1000",
"private": "false",
"_rid": "Maw1AIaRiRoBAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoBAAAAAAAAAA==/",
"_etag": "\"13008c9f-0000-0700-0000-5f3050d70000\"",
"_attachments": "attachments/",
"_ts": 1597001943
}
{
"id": "9f373e04-0cfc-4121-927d-a6256dbe06c6",
"name": "test1",
"location": {
"type": "Point",
"coordinates": [
39.731441899363105,
-104.98381230980158
]
},
"events": "Basketball",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Adult",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoLAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoLAAAAAAAAAA==/",
"_etag": "\"13005999-0000-0700-0000-5f304d760000\"",
"_attachments": "attachments/",
"_ts": 1597001078
}
{
"id": "be01bc12-d28e-4368-b6de-0f3e84dbe13c",
"name": "test2",
"location": {
"type": "Point",
"coordinates": [
39.72082849205111,
-104.98461395502092
]
},
"events": "Hockey",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Adult",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoMAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoMAAAAAAAAAA==/",
"_etag": "\"1300219a-0000-0700-0000-5f304de10000\"",
"_attachments": "attachments/",
"_ts": 1597001185
}
Took a while to realize, but GeoJSON expects flipped coordinates in the Point.
So while Maps return me a point type with [ latitude, longitude ]. GeoJSON expects [longitude, latitude]

Vega-lite difference between Firefox and Chrome

I have a vega-lite chart that shows up as expected in Chrome (72.0.3626.96), but not in Firefox (70.0.1). I have checked the spec in the Vega Editor. Does anyone know why this might be?
Here are the rendered charts:
Firefox:
Chrome:
Here is the spec:
Any help you might be able to give would be much appreciated.
Apologies, but I do not know how to collapse this code.
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.2.1.json",
"background": "white",
"config": {"mark": {"tooltip": null}, "view": {"height": 300, "width": 400}},
"datasets": {
"data-511198e25d4dbee99248144390684caa": [
{
"counts": 338,
"filter_method": "greater than",
"grade": "9",
"index": 3,
"perc": 0.2669826224328594,
"school_code": "Board",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 414,
"filter_method": "greater than",
"grade": "9",
"index": 4,
"perc": 0.30689399555226093,
"school_code": "Board",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
],
"data-72a083843a98847e44077116c495e448": [
{
"counts": 49,
"filter_method": "greater than",
"grade": "9",
"index": 0,
"perc": 0.3356164383561644,
"school_code": "KING",
"threshold": "8",
"year": 20142015,
"year_lab": "2014/15",
"year_lab_q": "2014"
},
{
"counts": 62,
"filter_method": "greater than",
"grade": "9",
"index": 5,
"perc": 0.3668639053254438,
"school_code": "MLTS",
"threshold": "8",
"year": 20162017,
"year_lab": "2016/17",
"year_lab_q": "2016"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 6,
"perc": 0.29608938547486036,
"school_code": "KING",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 44,
"filter_method": "greater than",
"grade": "9",
"index": 7,
"perc": 0.25882352941176473,
"school_code": "MLTS",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 8,
"perc": 0.3212121212121212,
"school_code": "KING",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
},
{
"counts": 61,
"filter_method": "greater than",
"grade": "9",
"index": 9,
"perc": 0.25206611570247933,
"school_code": "MLTS",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
]
},
"height": 400,
"layer": [
{
"data": {"name": "data-72a083843a98847e44077116c495e448"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {
"axis": {"format": "%Y", "tickCount": 5},
"field": "year_lab_q",
"scale": {"domain": ["2013.9", "2018.5"]},
"title": "School Year (beginning)",
"type": "temporal"
},
"y": {
"axis": {"format": ".0%"},
"field": "perc",
"title": "Percentage",
"type": "quantitative"
}
},
"mark": {"point": true, "type": "line"},
"selection": {
"selector001": {
"bind": "scales",
"encodings": ["x", "y"],
"type": "interval"
}
}
},
{
"data": {"name": "data-511198e25d4dbee99248144390684caa"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"scale": {"domain": ["Board"], "range": ["black"]},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {"field": "year_lab_q", "type": "temporal"},
"y": {"field": "perc", "type": "quantitative"}
},
"mark": {"point": true, "type": "line"}
}
],
"resolve": {"scale": {"color": "independent"}},
"title": "A title!",
"width": 700
}
It appears that your temporal values are not being parsed correctly in firefox (details of javascript date parsing behavior is often browser-dependent). You could try forcing the correct parsing by changing your data specification (in both places) to:
"data": {
"name": "data-72a083843a98847e44077116c495e448",
"format": {"parse": {"year_lab_q": "date:%Y"}}
}
This should ensure that the year string is parsed as a year, rather than e.g. a unix timestamp.
The other place date parsing is happening is in your domain specification. You might try changing those to a more standard time format, e.g.
"domain": ["2013-11-01", "2018-06-01"]

how to view a object without name object in react native?

Object {
"0": 200,
"result": Array [
Object {
"created_at": "1572602716",
"description": "i am description ",
"id": "1",
"title": "gulsan",
"updated_at": "1572602716",
"user_id": "27",
},
Object {
"created_at": "1572603684",
"description": "i am description ",
"id": "2",
"title": "kunal",
"updated_at": "1572603684",
"user_id": "27",
},
Object {
"created_at": "1572603975",
"description": "i am description ",
"id": "3",
"title": "nil",
"updated_at": "1572603975",
"user_id": "27",
},
Object {
"created_at": "1572854783",
"description": "i am description ",
"id": "7",
"title": "nilakash",
"updated_at": "1572854783",
"user_id": "27",
},
Object {
"created_at": "1573114400",
"description": "123",
"id": "8",
"title": "Tapan#gmail.com",
"updated_at": "1573114400",
"user_id": "27",
},
Object {
"created_at": "1573114522",
"description": "Test",
"id": "9",
"title": "Test",
"updated_at": "1573114522",
"user_id": "27",
},
Object {
"created_at": "1573114525",
"description": "Test",
"id": "10",
"title": "Test",
"updated_at": "1573114525",
"user_id": "27",
},
],
}
how to view it component
const obj = state.find((p) => p.title === "nil");
console.log(obj)
output
Object {
"created_at": "1572603975",
"description": "i am description ",
"id": "3",
"title": "nil",
"updated_at": "1572603975",
"user_id": "27",
}
i want show it component
Try the below snippet, you can view the object using this way.
var obj = "{\"0\": 200,\"result\": [{\"created_at\": \"1572602716\",\"description\": \"i am description \",\"id\": \"1\",\"title\": \"gulsan\",\"updated_at\": \"1572602716\",\"user_id\": \"27\"}, {\"created_at\": \"1572603684\",\"description\": \"i am description \",\"id\": \"2\",\"title\": \"kunal\",\"updated_at\": \"1572603684\",\"user_id\": \"27\"}, {\"created_at\": \"1572603975\",\"description\": \"i am description \",\"id\": \"3\",\"title\": \"nil\",\"updated_at\": \"1572603975\",\"user_id\": \"27\"}, {\"created_at\": \"1572854783\",\"description\": \"i am description \",\"id\": \"7\",\"title\": \"nilakash\",\"updated_at\": \"1572854783\",\"user_id\": \"27\"}, {\"created_at\": \"1573114400\",\"description\": \"123\",\"id\": \"8\",\"title\": \"Tapan#gmail.com\",\"updated_at\": \"1573114400\",\"user_id\": \"27\"}, {\"created_at\": \"1573114522\",\"description\": \"Test\",\"id\": \"9\",\"title\": \"Test\",\"updated_at\": \"1573114522\",\"user_id\": \"27\"}, {\"created_at\": \"1573114525\",\"description\": \"Test\",\"id\": \"10\",\"title\": \"Test\",\"updated_at\": \"1573114525\",\"user_id\": \"27\"}]}";
var jsonObj = JSON.parse(obj);
console.log(jsonObj.result[0]);

Combining MediaWiki API:Users and API:Usercontribs

I have a list of users. I am trying to retrieve their registration, editcount and gender using API:Users, and contribution data using API:Usercontribs.
Because of being gentle with the API, I have to put a bunch of usernames in each request, and I need to match their userIDs in order to be able to merge the results from the two APIs.
I faced an strange problem: there are a fair number of users with different userIDs retrieved by each method. E.g., if you query data for username "December21st2012Freak" from API:Users, you'll get userID 14281125, but requesting the same username from API:Usercontribs, the userID returns as 10141256.
Another example is username "The Sunshine Man", which has userID 4857299 retrieved bu API:Users and userID 4302884 retrieved by API:Usercontribs.
I don't understand why there is such an inconsistency.
Here are exact queries:
https://en.wikipedia.org/w/api.php?action=query&list=users&ususers=December21st2012Freak|The%20Sunshine%20Man&usprop=blockinfo%7Cgroups%7Ceditcount%7Cregistration%7Cemailable%7Cgender
which returns:
{
"query": {
"users": [
{
"userid": 14281125,
"name": "December21st2012Freak",
"editcount": 0,
"registration": "2011-03-29T02:14:36Z",
"groups": [
"*",
"user"
],
"emailable": "",
"gender": "unknown"
},
{
"userid": 4857299,
"name": "The Sunshine Man",
"editcount": 0,
"registration": "2007-07-13T20:00:58Z",
"groups": [
"*",
"user"
],
"gender": "unknown"
}
]
}
}
And the Usercontribs query:
https://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=December21st2012Freak&uclimit=3&ucdir=newer&continue=
which results:
{
"batchcomplete": "",
"continue": {
"uccontinue": "20090904033705|311775264",
"continue": "-||"
},
"query": {
"usercontribs": [
{
"userid": 10141256,
"user": "December21st2012Freak",
"pageid": 24217201,
"revid": 311775169,
"parentid": 0,
"ns": 3,
"title": "User talk:MsD723",
"timestamp": "2009-09-04T03:36:13Z",
"new": "",
"minor": "",
"top": "",
"comment": "Added welcome template to user talk page. using [[WP:FRIENDLY|Friendly]]",
"size": 1458
},
{
"userid": 10141256,
"user": "December21st2012Freak",
"pageid": 24217203,
"revid": 311775198,
"parentid": 0,
"ns": 3,
"title": "User talk:Oneseeker2",
"timestamp": "2009-09-04T03:36:32Z",
"new": "",
"minor": "",
"top": "",
"comment": "Added welcome template to user talk page. using [[WP:FRIENDLY|Friendly]]",
"size": 1458
},
{
"userid": 10141256,
"user": "December21st2012Freak",
"pageid": 24217208,
"revid": 311775231,
"parentid": 0,
"ns": 3,
"title": "User talk:Carolynhinchey",
"timestamp": "2009-09-04T03:36:46Z",
"new": "",
"minor": "",
"top": "",
"comment": "Added welcome template to user talk page. using [[WP:FRIENDLY|Friendly]]",
"size": 1458
}
]
}
}
And
https://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=The%20Sunshine%20Man&uclimit=3&ucdir=newer&continue=
which results:
{
"batchcomplete": "",
"continue": {
"uccontinue": "20070517145725|131549160",
"continue": "-||"
},
"query": {
"usercontribs": [
{
"userid": 4302884,
"user": "The Sunshine Man",
"pageid": 11271016,
"revid": 131518067,
"parentid": 131517319,
"ns": 4,
"title": "Wikipedia:Miscellany for deletion/Portal:Aquinas College, Perth",
"timestamp": "2007-05-17T11:48:17Z",
"comment": "/* [[Portal:Aquinas College, Perth]] */ Delete",
"size": 1773
},
{
"userid": 4302884,
"user": "The Sunshine Man",
"pageid": 7797923,
"revid": 131547208,
"parentid": 131525587,
"ns": 3,
"title": "User talk:Ryan Postlethwaite",
"timestamp": "2007-05-17T14:47:29Z",
"comment": "HeHe",
"size": 49019
},
{
"userid": 4302884,
"user": "The Sunshine Man",
"pageid": 11247929,
"revid": 131547970,
"parentid": 131543922,
"ns": 4,
"title": "Wikipedia:Requests for adminship/Bobak",
"timestamp": "2007-05-17T14:51:19Z",
"comment": "Support",
"size": 16492
}
]
}
}
As reported by Tgr: this is a bug, please be patient and wait for it to be fixed. https://phabricator.wikimedia.org/T99929