File tree Expand file tree Collapse file tree 4 files changed +1561
-998
lines changed
manager-dashboard/app/views/NewProject Expand file tree Collapse file tree 4 files changed +1561
-998
lines changed Original file line number Diff line number Diff line change 1717 "axios" : " ^0.25.0" ,
1818 "cookie-parser" : " ^1.4.4" ,
1919 "firebase-admin" : " ^10.0.2" ,
20- "firebase-functions" : " ^3.18.0 " ,
20+ "firebase-functions" : " ^3.24.1 " ,
2121 "request" : " ^2.88.2" ,
2222 "request-promise-native" : " ^1.0.8" ,
2323 "simple-oauth2" : " 3.3.0"
3535 "typescript" : " ^4.5.4"
3636 },
3737 "engines" : {
38- "node" : " 16 "
38+ "node" : " 18 "
3939 },
4040 "private" : true
4141}
Original file line number Diff line number Diff line change @@ -343,3 +343,34 @@ exports.incProjectProgress = functions.database.ref('/v2/projects/{projectId}/re
343343exports . decProjectProgress = functions . database . ref ( '/v2/projects/{projectId}/requiredResults/' ) . onUpdate ( ( ) => {
344344 return null ;
345345} ) ;
346+
347+ exports . addProjectTopicKey = functions . https . onRequest ( async ( _ , res ) => {
348+ try {
349+ const projectRef = admin . database ( ) . ref ( 'v2/projects' ) ;
350+ const snapshot = projectRef . once ( 'value' ) ;
351+ const data = ( await snapshot ) . val ( ) ;
352+
353+ if ( data ) {
354+ const newProjectData : { [ key : string ] : string } = { } ;
355+
356+ Object . keys ( data ) . forEach ( ( id ) => {
357+ if ( data [ id ] ?. projectTopic ) {
358+ const newProjectTopicKey = data [ id ] ?. projectTopic ?. toLowerCase ( ) as string ;
359+ newProjectData [ `v2/projects/${ id } /projectTopicKey` ] = newProjectTopicKey ;
360+ }
361+ } ) ;
362+ // NOTE: Update database with the new topic key
363+ await admin . database ( ) . ref ( ) . update ( newProjectData ) ;
364+
365+ // Fetch updated data
366+ const updatedSnapshot = await admin . database ( ) . ref ( 'v2/projects' ) . once ( 'value' ) ;
367+ const updatedProjectData = updatedSnapshot . val ( ) ;
368+
369+ res . status ( 200 ) . send ( updatedProjectData ) ;
370+ } else {
371+ res . status ( 404 ) . send ( 'No projects found' ) ;
372+ }
373+ } catch ( error ) {
374+ res . status ( 500 ) . send ( 'Error fetching projects data' ) ;
375+ }
376+ } ) ;
You can’t perform that action at this time.
0 commit comments