TestRoots / watchdog

IntelliJ & Eclipse plugin for monitoring how Java applications are developed and tested
http://www.testroots.org
Other
19 stars 10 forks source link

In Eclipse IDE "Eclipse Open" interval does not have "ide" field #191

Open levaja opened 9 years ago

levaja commented 9 years ago

In StartUpHandler, in startWatchDog() method, WD is first started and then WatchDogGlobals.hostIDE is set to IDE.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.

Inventitech commented 9 years ago

Just reuse your existing PR :-)

Inventitech commented 9 years ago

Good catch!

levaja commented 9 years ago

Okay. Don't merge it yet, I'll probably have something more to add :)

levaja commented 9 years ago

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.

levaja commented 9 years ago

@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.

Inventitech commented 9 years ago

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.

levaja commented 9 years ago

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).

levaja commented 9 years ago

Oh, didn't see your comment before mine :-)

https://docs.mongodb.org/manual/reference/method/db.collection.update/#combine-the-upsert-and-multi-options

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).

levaja commented 9 years ago

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.

Inventitech commented 8 years ago

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)

Inventitech commented 8 years ago

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

Inventitech commented 8 years ago

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.

Inventitech commented 8 years ago

Completed now.

Inventitech commented 8 years ago

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) })

Inventitech commented 7 years ago

I just discovered we still have this problem, and on a much larger scale now.

Inventitech commented 7 years ago

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