Skip to content

Instantly share code, notes, and snippets.

@unisys12
Created October 12, 2019 16:28
Show Gist options
  • Save unisys12/4ee79854d13bf47f28e72bf371dd6444 to your computer and use it in GitHub Desktop.
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...
require_relative 'list_activities'
include Activities
puts Activities::list_all
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
{
"_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