File tree Expand file tree Collapse file tree 6 files changed +326
-15
lines changed
Expand file tree Collapse file tree 6 files changed +326
-15
lines changed Original file line number Diff line number Diff line change 11const config = require ( "../../utils/bullconfig" ) ;
22const CommonsQueue = config . getNewQueue ( "commons-queue" ) ;
33const winston = require ( "winston" ) ;
4- const { downloadFile, uploadToCommons } = require ( "../../utils/helper" ) ;
4+ const {
5+ downloadFile,
6+ uploadToCommons,
7+ uploadToWikiData,
8+ } = require ( "../../utils/helper" ) ;
59const logger = winston . loggers . get ( "defaultLogger" ) ;
610
711CommonsQueue . process ( async ( job , done ) => {
@@ -36,9 +40,26 @@ CommonsQueue.process(async (job, done) => {
3640 return done ( null , true ) ;
3741 // return done(new Error(`uploadToCommons: ${commonsResponse}`));
3842 }
39- process . emit ( `commonsJobComplete:${ job . id } ` , {
40- status : true ,
41- value : commonsResponse ,
42- } ) ;
43+ const wikiDataResponse = await uploadToWikiData (
44+ job . data . metadata ,
45+ commonsResponse . filename
46+ ) ;
47+ if ( wikiDataResponse !== 404 ) {
48+ process . emit ( `commonsJobComplete:${ job . id } ` , {
49+ status : true ,
50+ value : {
51+ commons : commonsResponse ,
52+ wikidata : wikiDataResponse ,
53+ } ,
54+ } ) ;
55+ } else {
56+ process . emit ( `commonsJobComplete:${ job . id } ` , {
57+ status : true ,
58+ value : {
59+ commons : commonsResponse ,
60+ wikidata : 404 ,
61+ } ,
62+ } ) ;
63+ }
4364 return done ( null , true ) ;
4465} ) ;
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ GoogleBooksQueue.process((job, done) => {
9595 }
9696 done ( new Error ( errorMessage ) ) ;
9797 } else {
98+ job . progress ( {
99+ step : "Upload To IA" ,
100+ value : `(${ 100 } %)` ,
101+ } ) ;
98102 if (
99103 job . data . isUploadCommons !== "true" &&
100104 job . data . isEmailNotification !== "true"
@@ -121,7 +125,11 @@ GoogleBooksQueue.process((job, done) => {
121125 step : "Upload to Wikimedia Commons" ,
122126 value : `(${ 100 } %)` ,
123127 wikiLinks : {
124- commons : await commonsResponse . value . filename ,
128+ commons : await commonsResponse . value . commons . filename ,
129+ wikidata :
130+ ( await commonsResponse . value . wikidata ) !== 404
131+ ? await commonsResponse . value . wikidata
132+ : 404 ,
125133 } ,
126134 } ) ;
127135 if ( job . data . isEmailNotification === "true" ) {
Original file line number Diff line number Diff line change @@ -103,6 +103,16 @@ TroveQueue.process((job, done) => {
103103 }
104104 done ( new Error ( errorMessage ) ) ;
105105 } else {
106+ job . progress ( {
107+ step : "Upload To IA" ,
108+ value : `(${ 100 } %)` ,
109+ } ) ;
110+ if (
111+ isEmailNotification !== "true" &&
112+ job . data . details . isUploadCommons !== "true"
113+ ) {
114+ done ( null , true ) ;
115+ }
106116 if (
107117 isEmailNotification === "true" &&
108118 job . data . details . isUploadCommons !== "true"
@@ -124,17 +134,25 @@ TroveQueue.process((job, done) => {
124134 if ( commonsResponse . status === true ) {
125135 job . progress ( {
126136 step : "Upload to Wikimedia Commons" ,
127- value : `(100%)` ,
137+ value : `(${ 100 } %)` ,
128138 wikiLinks : {
129- commons : await commonsResponse . value . filename ,
139+ commons : await commonsResponse . value . commons
140+ . filename ,
141+ wikidata :
142+ ( await commonsResponse . value . wikidata ) !== 404
143+ ? await commonsResponse . value . wikidata
144+ : 404 ,
130145 } ,
131146 } ) ;
132147 if ( job . data . isEmailNotification === "true" ) {
133148 const commonsLink = `https://commons.wikimedia.org/wiki/File:${ commonsResponse . value . filename } ` ;
134149 EmailProducer (
135150 userName ,
136151 name ,
137- { archiveLink : trueURI , commonsLink : commonsLink } ,
152+ {
153+ archiveLink : trueURI ,
154+ commonsLink : commonsLink ,
155+ } ,
138156 { archive : true , commons : true }
139157 ) ;
140158 }
Original file line number Diff line number Diff line change @@ -144,10 +144,10 @@ const ShowJobInformation = (props) => {
144144 </ CardActions >
145145
146146 < CardActions sx = { { marginTop : "-15px" } } >
147- { data . wikimedia_links !== "Not Integrated" ? (
147+ { data . wikimedia_links . commons !== "Not Integrated" ? (
148148 < Link
149149 passHref
150- href = { `https://commons.wikimedia.org/wiki/File:${ data . wikimedia_links } ` }
150+ href = { `https://commons.wikimedia.org/wiki/File:${ data . wikimedia_links . commons } ` }
151151 >
152152 < Button
153153 sx = { styles . button }
@@ -160,6 +160,23 @@ const ShowJobInformation = (props) => {
160160 </ Link >
161161 ) : null }
162162 </ CardActions >
163+ < CardActions sx = { { marginTop : "-15px" } } >
164+ { data . wikimedia_links . wikidata !== "Not Integrated" ? (
165+ < Link
166+ passHref
167+ href = { `https://www.wikidata.org/wiki/${ data . wikimedia_links . wikidata } ` }
168+ >
169+ < Button
170+ sx = { styles . button }
171+ target = "_blank"
172+ size = "large"
173+ color = "primary"
174+ >
175+ View on Wikidata
176+ </ Button >
177+ </ Link >
178+ ) : null }
179+ </ CardActions >
163180 </ Card >
164181 </ div >
165182 ) ;
Original file line number Diff line number Diff line change @@ -169,14 +169,21 @@ app
169169 ) ,
170170 uploadStatus : {
171171 uploadLink :
172- job . progress ( ) . step . includes ( "Upload To IA (100%)" ) && trueURI
172+ ( job . progress ( ) . step . includes ( "Upload To IA" ) ||
173+ job . progress ( ) . step . includes ( "Upload to Wikimedia" ) ) &&
174+ trueURI
173175 ? trueURI
174176 : "" ,
175177 isUploaded : jobState === "completed" ? true : false ,
176178 } ,
177- wikimedia_links : job . progress ( ) . wikiLinks ?. commons
178- ? job . progress ( ) . wikiLinks . commons
179- : "Not Integrated" ,
179+ wikimedia_links : {
180+ commons : job . progress ( ) . wikiLinks ?. commons
181+ ? job . progress ( ) . wikiLinks . commons
182+ : "Not Integrated" ,
183+ wikidata : job . progress ( ) . wikiLinks ?. wikidata
184+ ? job . progress ( ) . wikiLinks . wikidata
185+ : "Not Integrated" ,
186+ } ,
180187 } ;
181188 res . send (
182189 Object . assign (
You can’t perform that action at this time.
0 commit comments