Created
October 12, 2019 16:28
-
-
Save unisys12/4ee79854d13bf47f28e72bf371dd6444 to your computer and use it in GitHub Desktop.
Using MongoDB as a storage vessel for the D2 MobileWorldContentFile, I wanted to put together an aggregate of the activities...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'list_activities' | |
include Activities | |
puts Activities::list_all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler/setup' | |
require 'dotenv/load' | |
require 'mongo' | |
module Activities | |
def list_all | |
Mongo::Logger.level = Logger::FATAL | |
client = Mongo::Client.new(ENV['DB_URL']) | |
activity_defs = client[:DestinyActivityDefinition] | |
activity_defs.aggregate([ | |
{ "$match" => { 'isPvP' => false } }, | |
{ | |
"$lookup" => { | |
"localField" => "destinationHash", | |
"foreignField" => "hash", | |
"from" => "DestinyDestinationDefinition", | |
"as" => "destination" | |
} | |
}, | |
{ | |
"$lookup" => { | |
"localField" => "placeHash", | |
"foreignField" => "hash", | |
"from" => "DestinyPlaceDefinition", | |
"as" => "place" | |
} | |
}, | |
{ | |
"$lookup" => { | |
"localField" => "activityTypeHash", | |
"foreignField" => "hash", | |
"from" => "DestinyActivityTypeDefinition", | |
"as" => "activityType" | |
} | |
}, | |
{ | |
"$project" => { | |
"displayProperties" => 1, | |
"destination.displayProperties" => 1, | |
"place.displayProperties.name" => 1, | |
"activityType.displayProperties.name" => 1 | |
} | |
} | |
]).each do |activity| | |
activity | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id"=>BSON: :ObjectId('5d9e0fec5d0bdb2d2ccb0ed3'), | |
"displayProperties"=>{ | |
"description"=>"Defeat enemies.", | |
"name"=>"Defeat Enemies", | |
"icon"=>"/common/destiny2_content/icons/c60303e278aa5fc566a04e98c3d8024c.png", | |
"hasIcon"=>true | |
}, | |
"destination"=>[ | |
{ | |
"displayProperties"=>{ | |
"description"=>"Mars", | |
"name"=>"Hellas Basin", | |
"hasIcon"=>false | |
} | |
}, | |
{ | |
"displayProperties"=>{ | |
"description"=>"Mars", | |
"name"=>"Hellas Basin", | |
"hasIcon"=>false | |
} | |
} | |
], | |
"place"=>[ | |
{ | |
"displayProperties"=>{ | |
"name"=>"Mars" | |
} | |
} | |
], | |
"activityType"=>[ | |
{ | |
"displayProperties"=>{ | |
"name"=>"Explore" | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment