File tree Expand file tree Collapse file tree 4 files changed +24
-10
lines changed
supabase/functions/fetch-scrobbles Expand file tree Collapse file tree 4 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 11name : Check
22
3- on : push
3+ on :
4+ - push
5+ - pull_request
46
57jobs :
68 qa :
Original file line number Diff line number Diff line change @@ -38,3 +38,8 @@ supabase start
3838supabase function serve --no-verify-jwt
3939```
4040
41+ ** deploy modified function**
42+
43+ ``` bash
44+ supabase functions deploy --project-ref xxx
45+ ```
Original file line number Diff line number Diff line change @@ -78,14 +78,16 @@ Deno.serve(async () => {
7878
7979 console . log ( `Fetching page ${ page } /${ totalPages } ` ) ;
8080
81- const toInsert : Row [ ] = tracks . map ( ( track ) => ( {
82- created_at : new Date ( ) . toISOString ( ) ,
83- listened_at : new Date ( track . date . uts * 1000 ) . toISOString ( ) ,
84- artist_name : track . artist . name ,
85- track_name : track . name ,
86- album_name : track . album [ "#text" ] ,
87- lastfm_data : track ,
88- } ) ) ;
81+ const toInsert : Row [ ] = tracks
82+ . filter ( ( track ) => ! ( track [ "@attr" ] && track [ "@attr" ] . nowplaying ) )
83+ . map ( ( track ) => ( {
84+ created_at : new Date ( ) . toISOString ( ) ,
85+ listened_at : new Date ( track . date ! . uts * 1000 ) . toISOString ( ) ,
86+ artist_name : track . artist . name ,
87+ track_name : track . name ,
88+ album_name : track . album [ "#text" ] ,
89+ lastfm_data : track ,
90+ } ) ) ;
8991
9092 const { error, message } = await table . save ( toInsert ) ;
9193 if ( error ) {
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ interface Artist {
1212
1313interface Track {
1414 artist : Artist ;
15- date : {
15+ // date is present only when the track is not playing right now...
16+ date ?: {
1617 uts : number ;
1718 "#text" : string ;
1819 } ;
@@ -26,6 +27,10 @@ interface Track {
2627 "#text" : string ;
2728 } ;
2829 loved : string ;
30+ // present only when it is playing, weird I know
31+ "@attr" ?: {
32+ nowplaying : boolean ;
33+ } ;
2934}
3035
3136interface Attributes {
You can’t perform that action at this time.
0 commit comments