Open levaja opened 9 years ago
Just reuse your existing PR :-)
Good catch!
Okay. Don't merge it yet, I'll probably have something more to add :)
This bug occured again, with introduction of silent registration. Upcoming fix will solve it once and for all by initializing it before any plugin activity is started.
@Inventitech I've checked. All intervals (only 23) without "ide" field (in version 1.5.0) belong to 4 different users. All of them later on have intervals belonging to Eclipse.
Thus, this bug only happened in Eclipse.
Ok. Thanks for checking.
Add IDE field to all documents which do not already have one
db.intervals.update({"ide":{$exists:false}}, {$set:{"ide":"ec"}}, true, true)
Question: What do the last two false, true do? I cannot find that documented: https://docs.mongodb.org/v2.6/reference/method/db.collection.update/
and do the same for db.users, db.projects and so on.
And this command should update all the intervals in the database which don't have "ide" field, to have "ide":"ec":
db.intervals.update({"ide":{$exists:false}},{$set: {"ide":"ec"}}, true, true)
Note that it can take a while to execute it (on my laptop, it took 13 minutes to update 7.28 millions of intervals).
Oh, didn't see your comment before mine :-)
The first boolean is for "upsert" ('true' means to add a field if it doesn't exist). The second boolean is for "multi" ('true' if we want to apply command on all the intervals returned by query).
I've checked User registrations on server and tried to match them with existing intervals:
db.users.find({"ide":{$exists:false},"wdv":"1.5.0"}).forEach(function(item){printjson(db.intervals.distinct("ide",{"userId":item.id}));})
.
There are, however, some users of IntelliJ among them (just 5 out of 71) , but also users for which is not possible to determine the ide (probably users without intervals), 31 out of 71. I think it would be the easiest solution to manually update these IntelliJ Users with "ide":"ij", and all the others with "ide":"ec".
For projects:
db.projects.find({"ide":{$exists:false},"wdv":"1.5.0"}).forEach(function(item) {printjson(db.intervals.distinct("ide",{"projectId":item.id}));})
we have only 1 empty (that's good!), 5 IntelliJ and 53 Eclipse projects.
Check number of intervals with non-ide field:
> db.intervals.count({"ide":{$exists:false}}) 8298778
Then update them
db.intervals.update({"ide":{$exists:false}},{$set: {"ide":"ec"}}, true, true)
OK, this seems to have worked
> db.intervals.update({"ide":{$exists:false}},{$set: {"ide":"ec"}}, true, true) WriteResult({ "nMatched" : 8298778, "nUpserted" : 0, "nModified" : 8298778 })
and we get
> db.intervals.count({"ide":{$exists:false}}) 0
Note to myself: I still need to perform the user-to-IDE matching suggested by Igor in the last comment so that user accounts have the best possible IDE field.
Completed now.
Get the empty user/project registrations, perform this check: db.projects.find({"ide":{$exists:false},"wdv":"1.5.0"}).forEach(function(item) {printjson(db.intervals.distinct("ide",{"projectId":item.id}) + " "+ item.id);})
Do some Emacs-magic.
Put them in a var lli = [ "id1", "id2" ]
Then run:
lli.forEach( function(item) { db.projects.update({"id":item},{$set: {"ide":"ij"}}, true, true) })
I just discovered we still have this problem, and on a much larger scale now.
Intervals are often missing the ide field, but at least it is always present in the projects. We can thus do a write-over from the projects to the intervals
In
StartUpHandler
, instartWatchDog()
method, WD is first started and thenWatchDogGlobals.hostIDE
is set toIDE.ECLIPSE
. This causes some intervals not to have their IDE field initialized.I can add a fix for this in my already opened PR or I can submit a new one, @Inventitech just let me know what do you think.